Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: in debug mode, print name of the "...



details:   https://anonhg.NetBSD.org/src/rev/380c1630bdfb
branches:  trunk
changeset: 984035:380c1630bdfb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jun 19 14:08:45 2021 +0000

description:
lint: in debug mode, print name of the "storage class"

This helps in tracking down the internal errors related to declarations,
found by running afl.

diffstat:

 usr.bin/xlint/lint1/decl.c     |  10 +++++-----
 usr.bin/xlint/lint1/externs1.h |   3 ++-
 usr.bin/xlint/lint1/print.c    |  18 ++++++++++++++++--
 3 files changed, 23 insertions(+), 8 deletions(-)

diffs (91 lines):

diff -r 26d3a5f81c0a -r 380c1630bdfb usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jun 19 13:56:34 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Jun 19 14:08:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.183 2021/06/19 11:01:23 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.184 2021/06/19 14:08:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.183 2021/06/19 11:01:23 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.184 2021/06/19 14:08:45 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -601,8 +601,7 @@
        di->d_ctx = sc;
        di->d_ldlsym = &di->d_dlsyms;
        if (dflag)
-               (void)printf("%s(%p %d)\n", __func__, dcs, (int)sc);
-
+               (void)printf("%s(%p %s)\n", __func__, dcs, scl_name(sc));
 }
 
 /*
@@ -614,7 +613,8 @@
        dinfo_t *di;
 
        if (dflag)
-               (void)printf("%s(%p %d)\n", __func__, dcs, (int)dcs->d_ctx);
+               (void)printf("%s(%p %s)\n",
+                   __func__, dcs, scl_name(dcs->d_ctx));
 
        lint_assert(dcs->d_next != NULL);
        di = dcs;
diff -r 26d3a5f81c0a -r 380c1630bdfb usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Sat Jun 19 13:56:34 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Sat Jun 19 14:08:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.109 2021/06/15 20:46:45 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.110 2021/06/19 14:08:45 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -339,6 +339,7 @@
  * print.c
  */
 extern char    *print_tnode(char *, size_t, const tnode_t *);
+const char     *scl_name(scl_t);
 
 /*
  * ckbool.c
diff -r 26d3a5f81c0a -r 380c1630bdfb usr.bin/xlint/lint1/print.c
--- a/usr.bin/xlint/lint1/print.c       Sat Jun 19 13:56:34 2021 +0000
+++ b/usr.bin/xlint/lint1/print.c       Sat Jun 19 14:08:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.11 2021/03/20 20:56:58 rillig Exp $        */
+/*     $NetBSD: print.c,v 1.12 2021/06/19 14:08:45 rillig Exp $        */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: print.c,v 1.11 2021/03/20 20:56:58 rillig Exp $");
+__RCSID("$NetBSD: print.c,v 1.12 2021/06/19 14:08:45 rillig Exp $");
 #endif
 
 #include <stdio.h>
@@ -87,3 +87,17 @@
        }
        return buf;
 }
+
+/* Return the name of the "storage class" in the wider sense. */
+const char *
+scl_name(scl_t scl)
+{
+       static const char *const names[] = {
+           "none", "extern", "static", "auto", "register", "typedef",
+           "struct", "union", "enum", "member of struct", "member of union",
+           "compile-time constant", "abstract", "argument",
+           "prototype argument", "inline"
+       };
+
+       return names[scl];
+}



Home | Main Index | Thread Index | Old Index