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: add debug logging for symbol table...



details:   https://anonhg.NetBSD.org/src/rev/0948f2e44612
branches:  trunk
changeset: 1022662:0948f2e44612
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 01 06:40:37 2021 +0000

description:
lint: add debug logging for symbol table, clean up debug logging

When I tried to fix msg_115, I quickly ran into a segmentation fault,
probably related to the symbol table.  To better understand this part,
log insertions and deletions.

The other debug log messages do not need to mention the current file
position anymore, this is what lex_next_line takes care of since scan.l
1.113 from 2021-01-05.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  13 +++++--------
 usr.bin/xlint/lint1/decl.c  |  10 ++++------
 usr.bin/xlint/lint1/func.c  |  10 ++++------
 usr.bin/xlint/lint1/lex.c   |  13 +++++++++++--
 usr.bin/xlint/lint1/main1.c |   7 +++----
 5 files changed, 27 insertions(+), 26 deletions(-)

diffs (204 lines):

diff -r 194f70a1c4c3 -r 0948f2e44612 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Jul 31 20:55:45 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Aug 01 06:40:37 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.352 2021/07/31 17:09:21 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.352 2021/07/31 17:09:21 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -75,8 +75,7 @@
 static void
 CLEAR_WARN_FLAGS(const char *file, size_t line)
 {
-       printf("%s:%d: %s:%zu: clearing flags\n",
-           curr_pos.p_file, curr_pos.p_line, file, line);
+       printf("%s:%zu: clearing flags\n", file, line);
        clear_warn_flags();
        olwarn = LWARN_BAD;
 }
@@ -85,8 +84,7 @@
 SAVE_WARN_FLAGS(const char *file, size_t line)
 {
        lint_assert(olwarn == LWARN_BAD);
-       printf("%s:%d: %s:%zu: saving flags %d\n",
-           curr_pos.p_file, curr_pos.p_line, file, line, lwarn);
+       printf("%s:%zu: saving flags %d\n", file, line, lwarn);
        olwarn = lwarn;
 }
 
@@ -95,8 +93,7 @@
 {
        if (olwarn != LWARN_BAD) {
                lwarn = olwarn;
-               printf("%s:%d: %s:%zu: restoring flags %d\n",
-                   curr_pos.p_file, curr_pos.p_line, file, line, lwarn);
+               printf("%s:%zu: restoring flags %d\n", file, line, lwarn);
                olwarn = LWARN_BAD;
        } else
                CLEAR_WARN_FLAGS(file, line);
diff -r 194f70a1c4c3 -r 0948f2e44612 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jul 31 20:55:45 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Aug 01 06:40:37 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.215 2021/07/31 19:52:44 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 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.215 2021/07/31 19:52:44 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -3015,13 +3015,11 @@
        mklwarn = lwarn;
        lwarn = LWARN_ALL;
 
-       debug_step("%s, %d: >temp lwarn = %d",
-           curr_pos.p_file, curr_pos.p_line, lwarn);
+       debug_step("begin lwarn %d", lwarn);
        for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt)
                check_usage_sym(di->d_asm, sym);
        lwarn = mklwarn;
-       debug_step("%s, %d: <temp lwarn = %d",
-           curr_pos.p_file, curr_pos.p_line, lwarn);
+       debug_step("end lwarn %d", lwarn);
 }
 
 /*
diff -r 194f70a1c4c3 -r 0948f2e44612 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Sat Jul 31 20:55:45 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Sun Aug 01 06:40:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.117 2021/07/31 19:07:52 rillig Exp $        */
+/*     $NetBSD: func.c,v 1.118 2021/08/01 06:40:37 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.117 2021/07/31 19:07:52 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.118 2021/08/01 06:40:37 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -192,8 +192,7 @@
 static void
 set_reached(bool new_reached)
 {
-       debug_step("%s:%d: %s -> %s",
-           curr_pos.p_file, curr_pos.p_line,
+       debug_step("%s -> %s",
            reached ? "reachable" : "unreachable",
            new_reached ? "reachable" : "unreachable");
        reached = new_reached;
@@ -1327,8 +1326,7 @@
 linted(int n)
 {
 
-       debug_step("%s, %d: lwarn = %d",
-           curr_pos.p_file, curr_pos.p_line, n);
+       debug_step("set lwarn %d", n);
        lwarn = n;
 }
 
diff -r 194f70a1c4c3 -r 0948f2e44612 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Jul 31 20:55:45 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Aug 01 06:40:37 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.58 2021/07/31 19:07:52 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.59 2021/08/01 06:40:37 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: lex.c,v 1.58 2021/07/31 19:07:52 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.59 2021/08/01 06:40:37 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1506,6 +1506,8 @@
 rmsym(sym_t *sym)
 {
 
+       debug_step("rmsym '%s' %d '%s'",
+           sym->s_name, (int)sym->s_kind, type_name(sym->s_type));
        if ((*sym->s_rlink = sym->s_link) != NULL)
                sym->s_link->s_rlink = sym->s_rlink;
        sym->s_block_level = -1;
@@ -1523,6 +1525,9 @@
 
        for (sym = syms; sym != NULL; sym = sym->s_dlnxt) {
                if (sym->s_block_level != -1) {
+                       debug_step("rmsyms '%s' %d '%s'",
+                           sym->s_name, (int)sym->s_kind,
+                           type_name(sym->s_type));
                        if ((*sym->s_rlink = sym->s_link) != NULL)
                                sym->s_link->s_rlink = sym->s_rlink;
                        sym->s_link = NULL;
@@ -1539,6 +1544,8 @@
 {
        int     h;
 
+       debug_step("inssym '%s' %d '%s'",
+           sym->s_name, sym->s_kind, type_name(sym->s_type));
        h = hash(sym->s_name);
        if ((sym->s_link = symtab[h]) != NULL)
                symtab[h]->s_rlink = &sym->s_link;
@@ -1585,6 +1592,8 @@
        int     h;
        sym_t   *nsym;
 
+       debug_step("pushdown '%s' %d '%s'",
+           sym->s_name, (int)sym->s_kind, type_name(sym->s_type));
        h = hash(sym->s_name);
        nsym = getblk(sizeof(*nsym));
        lint_assert(sym->s_block_level <= block_level);
diff -r 194f70a1c4c3 -r 0948f2e44612 usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c       Sat Jul 31 20:55:45 2021 +0000
+++ b/usr.bin/xlint/lint1/main1.c       Sun Aug 01 06:40:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main1.c,v 1.50 2021/07/31 19:07:52 rillig Exp $        */
+/*     $NetBSD: main1.c,v 1.51 2021/08/01 06:40:37 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.50 2021/07/31 19:07:52 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.51 2021/08/01 06:40:37 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -284,8 +284,7 @@
 
        /* Following warnings cannot be suppressed by LINTED */
        lwarn = LWARN_ALL;
-       debug_step("%s, %d: lwarn = %d",
-           curr_pos.p_file, curr_pos.p_line, lwarn);
+       debug_step("main lwarn = %d", lwarn);
 
        check_global_symbols();
 



Home | Main Index | Thread Index | Old Index