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 struct and e...



details:   https://anonhg.NetBSD.org/src/rev/15adc3b7b8af
branches:  trunk
changeset: 368294:15adc3b7b8af
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 03 14:15:38 2022 +0000

description:
lint: add debug logging for struct and enum details

diffstat:

 usr.bin/xlint/lint1/debug.c    |  35 +++++++++++++++++++++++++++++++++--
 usr.bin/xlint/lint1/externs1.h |   4 +++-
 usr.bin/xlint/lint1/tree.c     |   6 ++++--
 3 files changed, 40 insertions(+), 5 deletions(-)

diffs (108 lines):

diff -r 41baefe00bc8 -r 15adc3b7b8af usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sun Jul 03 14:09:22 2022 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sun Jul 03 14:15:38 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.21 2022/05/26 16:45:25 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.22 2022/07/03 14:15:38 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.21 2022/05/26 16:45:25 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.22 2022/07/03 14:15:38 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -106,6 +106,37 @@
        printf("%*s- %s\n", 2 * --debug_indentation, "", func);
 }
 
+static void
+debug_type_details(const type_t *tp)
+{
+
+       if (is_struct_or_union(tp->t_tspec)) {
+               debug_indent_inc();
+               for (const sym_t *mem = tp->t_str->sou_first_member;
+                    mem != NULL; mem = mem->s_next) {
+                       debug_sym("", mem, "\n");
+                       debug_type_details(mem->s_type);
+               }
+               debug_indent_dec();
+       }
+       if (tp->t_is_enum) {
+               debug_indent_inc();
+               for (const sym_t *en = tp->t_enum->en_first_enumerator;
+                    en != NULL; en = en->s_next) {
+                       debug_sym("", en, "\n");
+               }
+               debug_indent_dec();
+       }
+}
+
+void
+debug_type(const type_t *tp)
+{
+
+       debug_step("type details for '%s':", type_name(tp));
+       debug_type_details(tp);
+}
+
 void
 debug_node(const tnode_t *tn) // NOLINT(misc-no-recursion)
 {
diff -r 41baefe00bc8 -r 15adc3b7b8af usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Sun Jul 03 14:09:22 2022 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Sun Jul 03 14:15:38 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.163 2022/07/01 21:25:39 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.164 2022/07/03 14:15:38 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -122,6 +122,7 @@
 const char *tqual_name(tqual_t);
 void   debug_dinfo(const dinfo_t *);
 void   debug_node(const tnode_t *);
+void   debug_type(const type_t *);
 void   debug_sym(const char *, const sym_t *, const char *);
 void   debug_symtab(void);
 void   debug_printf(const char *fmt, ...) __printflike(1, 2);
@@ -139,6 +140,7 @@
 #define        debug_sym(p, sym, s)    debug_noop()
 #define        debug_symtab()          debug_noop()
 #define        debug_node(tn)          debug_noop()
+#define        debug_type(tp)          debug_noop()
 #define        debug_printf(...)       debug_noop()
 #define        debug_print_indent()    debug_noop()
 #define        debug_indent_inc()      debug_noop()
diff -r 41baefe00bc8 -r 15adc3b7b8af usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jul 03 14:09:22 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jul 03 14:15:38 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.469 2022/07/02 10:47:29 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.470 2022/07/03 14:15:38 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.469 2022/07/02 10:47:29 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.470 2022/07/03 14:15:38 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2546,6 +2546,8 @@
 
        /* Allow cast between pointers to sockaddr variants. */
        if (nst == STRUCT && ost == STRUCT) {
+               debug_type(nstp);
+               debug_type(ostp);
                const sym_t *nmem = nstp->t_str->sou_first_member;
                const sym_t *omem = ostp->t_str->sou_first_member;
                while (nmem != NULL && omem != NULL &&



Home | Main Index | Thread Index | Old Index