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: improve debug logging for the symb...



details:   https://anonhg.NetBSD.org/src/rev/f66bfa93a09a
branches:  trunk
changeset: 363484:f66bfa93a09a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 13 15:08:41 2022 +0000

description:
lint: improve debug logging for the symbol table

Only print the heading for the symbol table level if there is actually a
symbol on that level.

Ensure that no symbol with block level -1 is ever in the symbol table
(see rmsym).

diffstat:

 usr.bin/xlint/lint1/lex.c |  25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diffs (53 lines):

diff -r 79d3a7634376 -r f66bfa93a09a usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Mar 13 14:49:18 2022 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Mar 13 15:08:41 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.110 2022/03/13 14:49:18 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.111 2022/03/13 15:08:41 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.110 2022/03/13 14:49:18 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.111 2022/03/13 15:08:41 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -339,9 +339,7 @@
 {
        struct syms syms = { xcalloc(64, sizeof(syms.items[0])), 0, 64 };
 
-       for (int level = 0;; level++) {
-               debug_printf("symbol table level %d\n", level);
-
+       for (int level = -1;; level++) {
                bool more = false;
                size_t n = sizeof(symtab) / sizeof(symtab[0]);
 
@@ -357,12 +355,17 @@
                        }
                }
 
-               debug_indent_inc();
-               qsort(syms.items, syms.len, sizeof(syms.items[0]),
-                   sym_by_name);
-               for (size_t i = 0; i < syms.len; i++)
-                       debug_sym(syms.items[i]);
-               debug_indent_dec();
+               if (syms.len > 0) {
+                       debug_printf("symbol table level %d\n", level);
+                       debug_indent_inc();
+                       qsort(syms.items, syms.len, sizeof(syms.items[0]),
+                           sym_by_name);
+                       for (size_t i = 0; i < syms.len; i++)
+                               debug_sym(syms.items[i]);
+                       debug_indent_dec();
+
+                       lint_assert(level != -1);
+               }
 
                if (!more)
                        break;



Home | Main Index | Thread Index | Old Index