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: extend debugging for initializing ...
details: https://anonhg.NetBSD.org/src/rev/4fbec6ba1904
branches: trunk
changeset: 952881:4fbec6ba1904
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Feb 20 16:34:57 2021 +0000
description:
lint: extend debugging for initializing objects
No functional change outside debug mode.
diffstat:
usr.bin/xlint/lint1/externs1.h | 7 ++++++-
usr.bin/xlint/lint1/init.c | 18 ++++++++----------
usr.bin/xlint/lint1/tree.c | 26 +++++++++++++-------------
3 files changed, 27 insertions(+), 24 deletions(-)
diffs (157 lines):
diff -r adc7f1c9f26e -r 4fbec6ba1904 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Sat Feb 20 16:03:56 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Sat Feb 20 16:34:57 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.67 2021/02/20 16:03:56 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.68 2021/02/20 16:34:57 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -222,6 +222,11 @@
extern bool constant_addr(tnode_t *, sym_t **, ptrdiff_t *);
extern strg_t *cat_strings(strg_t *, strg_t *);
extern int64_t tsize(type_t *);
+#ifdef DEBUG
+extern void debug_node(const tnode_t *);
+#else
+#define debug_node(tn) (void)0
+#endif
/*
* func.c
diff -r adc7f1c9f26e -r 4fbec6ba1904 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Sat Feb 20 16:03:56 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Sat Feb 20 16:34:57 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.69 2021/02/20 16:03:56 rillig Exp $ */
+/* $NetBSD: init.c,v 1.70 2021/02/20 16:34:57 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.69 2021/02/20 16:03:56 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.70 2021/02/20 16:34:57 rillig Exp $");
#endif
#include <stdlib.h>
@@ -171,7 +171,9 @@
{
namlist_t *nam = xcalloc(1, sizeof (namlist_t));
nam->n_name = sb->sb_name;
+
debug_step("%s: %s %p", __func__, nam->n_name, nam);
+
if (namedmem == NULL) {
/*
* XXX: Why is this a circular list?
@@ -239,7 +241,7 @@
free(istk);
}
- debug_step("%s", __func__);
+ debug_enter();
/*
* If the type which is to be initialized is an incomplete type,
@@ -251,6 +253,8 @@
istk = initstk = xcalloc(1, sizeof (istk_t));
istk->i_subt = initsym->s_type;
istk->i_remaining = 1;
+
+ debug_leave();
}
static void
@@ -624,16 +628,10 @@
tnode_t *ln;
struct mbl *tmem;
scl_t sc;
-#ifdef DEBUG
- char sbuf[64];
-#endif
debug_enter();
-
- debug_step("type=%s, value=%s",
- type_name(tn->tn_type),
- print_tnode(sbuf, sizeof(sbuf), tn));
debug_named_member();
+ debug_node(tn);
if (initerr || tn == NULL) {
debug_leave();
diff -r adc7f1c9f26e -r 4fbec6ba1904 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Feb 20 16:03:56 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Feb 20 16:34:57 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.209 2021/02/19 22:27:49 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.210 2021/02/20 16:34:57 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.209 2021/02/19 22:27:49 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.210 2021/02/20 16:34:57 rillig Exp $");
#endif
#include <float.h>
@@ -98,8 +98,8 @@
extern sig_atomic_t fpe;
#ifdef DEBUG
-static void
-dprint_node(const tnode_t *tn)
+void
+debug_node(const tnode_t *tn)
{
static int indent = 0;
@@ -120,6 +120,12 @@
if (op == NAME)
printf(" %s\n", tn->tn_sym->s_name);
+ else if (op == CON && is_floating(tn->tn_type->t_tspec))
+ printf(" value=%Lg", tn->tn_val->v_ldbl);
+ else if (op == CON && is_uinteger(tn->tn_type->t_tspec))
+ printf(" value=%llu\n", (unsigned long long)tn->tn_val->v_quad);
+ else if (op == CON && is_integer(tn->tn_type->t_tspec))
+ printf(" value=%lld\n", (long long)tn->tn_val->v_quad);
else if (op == CON)
printf(" value=?\n");
else if (op == STRING)
@@ -128,18 +134,12 @@
printf("\n");
indent += 2;
- dprint_node(tn->tn_left);
+ debug_node(tn->tn_left);
if (modtab[op].m_binary || tn->tn_right != NULL)
- dprint_node(tn->tn_right);
+ debug_node(tn->tn_right);
indent -= 2;
}
}
-#else
-/*ARGSUSED*/
-static void
-dprint_node(const tnode_t *tn)
-{
-}
#endif
/*
@@ -4344,7 +4344,7 @@
if (!hflag)
return;
- dprint_node(tn);
+ debug_node(tn);
lint_assert(modtab[tn->tn_op].m_binary);
for (ln = tn->tn_left; ln->tn_op == CVT; ln = ln->tn_left)
Home |
Main Index |
Thread Index |
Old Index