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: clean up debug logging
details: https://anonhg.NetBSD.org/src/rev/4f5cb6eebf9b
branches: trunk
changeset: 984929:4f5cb6eebf9b
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jul 31 19:07:52 2021 +0000
description:
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses
enough other features from C99 that it essentially requires this
standard, which supports varargs macro arguments. Among these features
are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step.
Evaluating the arguments had caused an internal error when running the
test op_shl_lp64. This is indeed a bug since initdecl should have
initialized the type table for __uint128_t. This had been forgotten
when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
diffstat:
usr.bin/xlint/lint1/decl.c | 25 +++++++++----------------
usr.bin/xlint/lint1/err.c | 8 +++-----
usr.bin/xlint/lint1/externs1.h | 17 +++++------------
usr.bin/xlint/lint1/func.c | 20 ++++++++------------
usr.bin/xlint/lint1/init.c | 14 +++++++-------
usr.bin/xlint/lint1/lex.c | 8 +++-----
usr.bin/xlint/lint1/main1.c | 9 ++++-----
7 files changed, 39 insertions(+), 62 deletions(-)
diffs (truncated from 312 to 300 lines):
diff -r c6d4c37e29d1 -r 4f5cb6eebf9b usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sat Jul 31 18:16:42 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sat Jul 31 19:07:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.212 2021/07/31 17:09:21 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 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.212 2021/07/31 17:09:21 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 rillig Exp $");
#endif
#include <sys/param.h>
@@ -289,9 +289,8 @@
add_type(type_t *tp)
{
tspec_t t;
-#ifdef DEBUG
- printf("%s: %s\n", __func__, type_name(tp));
-#endif
+
+ debug_step("%s: %s", __func__, type_name(tp));
if (tp->t_typedef) {
/*
* something like "typedef int a; int a b;"
@@ -801,9 +800,7 @@
l = dcs->d_rank_mod; /* SHORT, LONG or QUAD */
tp = dcs->d_type;
-#ifdef DEBUG
- printf("%s: %s\n", __func__, type_name(tp));
-#endif
+ debug_step("%s: %s", __func__, type_name(tp));
if (t == NOTSPEC && s == NOTSPEC && l == NOTSPEC && c == NOTSPEC &&
tp == NULL)
dcs->d_notyp = true;
@@ -3011,17 +3008,13 @@
mklwarn = lwarn;
lwarn = LWARN_ALL;
-#ifdef DEBUG
- printf("%s, %d: >temp lwarn = %d\n", curr_pos.p_file, curr_pos.p_line,
- lwarn);
-#endif
+ debug_step("%s, %d: >temp lwarn = %d",
+ curr_pos.p_file, curr_pos.p_line, lwarn);
for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt)
check_usage_sym(di->d_asm, sym);
lwarn = mklwarn;
-#ifdef DEBUG
- printf("%s, %d: <temp lwarn = %d\n", curr_pos.p_file, curr_pos.p_line,
- lwarn);
-#endif
+ debug_step("%s, %d: <temp lwarn = %d",
+ curr_pos.p_file, curr_pos.p_line, lwarn);
}
/*
diff -r c6d4c37e29d1 -r 4f5cb6eebf9b usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sat Jul 31 18:16:42 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sat Jul 31 19:07:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.131 2021/07/25 10:39:10 rillig Exp $ */
+/* $NetBSD: err.c,v 1.132 2021/07/31 19:07:52 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.131 2021/07/25 10:39:10 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.132 2021/07/31 19:07:52 rillig Exp $");
#endif
#include <sys/types.h>
@@ -511,9 +511,7 @@
if (ERR_ISSET(msgid, &msgset))
return;
-#ifdef DEBUG
- printf("%s: lwarn=%d msgid=%d\n", __func__, lwarn, msgid);
-#endif
+ debug_step("%s: lwarn=%d msgid=%d", __func__, lwarn, msgid);
if (lwarn == LWARN_NONE || lwarn == msgid)
/* this warning is suppressed by a LINTED comment */
return;
diff -r c6d4c37e29d1 -r 4f5cb6eebf9b usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sat Jul 31 18:16:42 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sat Jul 31 19:07:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.124 2021/07/31 18:16:42 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.125 2021/07/31 19:07:52 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -123,27 +123,20 @@
void debug_indent_dec(void);
void debug_enter(const char *);
void debug_step(const char *fmt, ...) __printflike(1, 2);
-#define debug_step0 debug_step
-#define debug_step1 debug_step
-#define debug_step2 debug_step
void debug_leave(const char *);
#define debug_enter() (debug_enter)(__func__)
#define debug_leave() (debug_leave)(__func__)
#else
#define debug_noop() do { } while (false)
-#define debug_node(tn, indent) debug_noop()
-/* ARGSUSED */
-static inline void __printflike(1, 2) debug_printf(const char *fmt, ...) {}
-#define debug_indent() debug_noop()
-/* ARGSUSED */
+#define debug_node(tn, indent) debug_noop()
+#define debug_printf(...) debug_noop()
+#define debug_indent() debug_noop()
static inline void __printflike(1, 2) debug_step(const char *fmt, ...) {}
+/*#define debug_step(...) debug_noop()*/
#define debug_indent() debug_noop()
#define debug_indent_inc() debug_noop()
#define debug_indent_dec() debug_noop()
#define debug_enter() debug_noop()
-#define debug_step0(fmt) debug_noop()
-#define debug_step1(fmt, arg0) debug_noop()
-#define debug_step2(fmt, arg1, arg2) debug_noop()
#define debug_leave() debug_noop()
#endif
diff -r c6d4c37e29d1 -r 4f5cb6eebf9b usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Sat Jul 31 18:16:42 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Sat Jul 31 19:07:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.116 2021/07/31 11:03:04 rillig Exp $ */
+/* $NetBSD: func.c,v 1.117 2021/07/31 19:07:52 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.116 2021/07/31 11:03:04 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.117 2021/07/31 19:07:52 rillig Exp $");
#endif
#include <stdlib.h>
@@ -192,11 +192,10 @@
static void
set_reached(bool new_reached)
{
-#ifdef DEBUG
- printf("%s:%d: %s -> %s\n", curr_pos.p_file, curr_pos.p_line,
+ debug_step("%s:%d: %s -> %s",
+ curr_pos.p_file, curr_pos.p_line,
reached ? "reachable" : "unreachable",
new_reached ? "reachable" : "unreachable");
-#endif
reached = new_reached;
warn_about_unreachable = true;
}
@@ -1328,9 +1327,8 @@
linted(int n)
{
-#ifdef DEBUG
- printf("%s, %d: lwarn = %d\n", curr_pos.p_file, curr_pos.p_line, n);
-#endif
+ debug_step("%s, %d: lwarn = %d",
+ curr_pos.p_file, curr_pos.p_line, n);
lwarn = n;
}
@@ -1342,10 +1340,8 @@
bitfieldtype(int n)
{
-#ifdef DEBUG
- printf("%s, %d: bitfieldtype_ok = true\n", curr_pos.p_file,
- curr_pos.p_line);
-#endif
+ debug_step("%s, %d: bitfieldtype_ok = true",
+ curr_pos.p_file, curr_pos.p_line);
bitfieldtype_ok = true;
}
diff -r c6d4c37e29d1 -r 4f5cb6eebf9b usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sat Jul 31 18:16:42 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sat Jul 31 19:07:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.205 2021/07/31 18:16:42 rillig Exp $ */
+/* $NetBSD: init.c,v 1.206 2021/07/31 19:07:52 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.205 2021/07/31 18:16:42 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.206 2021/07/31 19:07:52 rillig Exp $");
#endif
#include <stdlib.h>
@@ -346,7 +346,7 @@
lt = ln->tn_type->t_tspec;
rt = tn->tn_type->t_tspec;
- debug_step2("typeok '%s', '%s'",
+ debug_step("typeok '%s', '%s'",
type_name(ln->tn_type), type_name(tn->tn_type));
if (!typeok(INIT, 0, ln, tn))
return;
@@ -828,7 +828,7 @@
if (in->in_sym->s_type->t_tspec == ARRAY)
return false;
- debug_step0("handing over to ASSIGN");
+ debug_step("handing over to ASSIGN");
ln = build_name(in->in_sym, 0);
ln->tn_type = expr_unqualified_type(ln->tn_type);
@@ -929,7 +929,7 @@
goto done;
}
- debug_step2("expecting '%s', expression has '%s'",
+ debug_step("expecting '%s', expression has '%s'",
type_name(tp), type_name(tn->tn_type));
check_init_expr(tp, in->in_sym, tn);
@@ -968,7 +968,7 @@
{
struct initialization *in;
- debug_step1("begin initialization of '%s'", type_name(sym->s_type));
+ debug_step("begin initialization of '%s'", type_name(sym->s_type));
debug_indent_inc();
in = initialization_new(sym);
@@ -986,7 +986,7 @@
initialization_free(in);
debug_indent_dec();
- debug_step0("end initialization");
+ debug_step("end initialization");
}
void
diff -r c6d4c37e29d1 -r 4f5cb6eebf9b usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Jul 31 18:16:42 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Jul 31 19:07:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.57 2021/07/31 13:47:19 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.58 2021/07/31 19:07:52 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.57 2021/07/31 13:47:19 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.58 2021/07/31 19:07:52 rillig Exp $");
#endif
#include <ctype.h>
@@ -82,9 +82,7 @@
{
curr_pos.p_line++;
curr_pos.p_uniq = 0;
-#ifdef DEBUG
- printf("parsing %s:%d\n", curr_pos.p_file, curr_pos.p_line);
-#endif
+ debug_step("parsing %s:%d", curr_pos.p_file, curr_pos.p_line);
if (curr_pos.p_file == csrc_pos.p_file) {
csrc_pos.p_line++;
csrc_pos.p_uniq = 0;
diff -r c6d4c37e29d1 -r 4f5cb6eebf9b usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c Sat Jul 31 18:16:42 2021 +0000
+++ b/usr.bin/xlint/lint1/main1.c Sat Jul 31 19:07:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.49 2021/07/04 05:49:20 rillig Exp $ */
+/* $NetBSD: main1.c,v 1.50 2021/07/31 19:07:52 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.49 2021/07/04 05:49:20 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.50 2021/07/31 19:07:52 rillig Exp $");
#endif
#include <sys/types.h>
Home |
Main Index |
Thread Index |
Old Index