Module Name: src
Committed By: rillig
Date: Sun Aug 1 06:40:37 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c func.c lex.c main1.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.352 -r1.353 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.215 -r1.216 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/xlint/lint1/main1.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.352 src/usr.bin/xlint/lint1/cgram.y:1.353
--- src/usr.bin/xlint/lint1/cgram.y:1.352 Sat Jul 31 17:09:21 2021
+++ src/usr.bin/xlint/lint1/cgram.y Sun Aug 1 06:40:37 2021
@@ -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 sym_t *symbolrename(sym_t *, sbuf
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 @@ static void
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 @@ RESTORE_WARN_FLAGS(const char *file, siz
{
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);
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.215 src/usr.bin/xlint/lint1/decl.c:1.216
--- src/usr.bin/xlint/lint1/decl.c:1.215 Sat Jul 31 19:52:44 2021
+++ src/usr.bin/xlint/lint1/decl.c Sun Aug 1 06:40:37 2021
@@ -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 @@ check_usage(dinfo_t *di)
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);
}
/*
Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.117 src/usr.bin/xlint/lint1/func.c:1.118
--- src/usr.bin/xlint/lint1/func.c:1.117 Sat Jul 31 19:07:52 2021
+++ src/usr.bin/xlint/lint1/func.c Sun Aug 1 06:40:37 2021
@@ -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 @@ end_control_statement(control_statement_
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 @@ void
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;
}
Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.58 src/usr.bin/xlint/lint1/lex.c:1.59
--- src/usr.bin/xlint/lint1/lex.c:1.58 Sat Jul 31 19:07:52 2021
+++ src/usr.bin/xlint/lint1/lex.c Sun Aug 1 06:40:37 2021
@@ -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 @@ void
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 @@ rmsyms(sym_t *syms)
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 @@ inssym(int bl, sym_t *sym)
{
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 @@ pushdown(const sym_t *sym)
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);
Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.50 src/usr.bin/xlint/lint1/main1.c:1.51
--- src/usr.bin/xlint/lint1/main1.c:1.50 Sat Jul 31 19:07:52 2021
+++ src/usr.bin/xlint/lint1/main1.c Sun Aug 1 06:40:37 2021
@@ -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 @@ main(int argc, char *argv[])
/* 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();