Home | History | Annotate | Line # | Download | only in lint1
debug.c revision 1.55
      1  1.55  rillig /* $NetBSD: debug.c,v 1.55 2023/07/13 23:27:20 rillig Exp $ */
      2   1.1  rillig 
      3   1.1  rillig /*-
      4   1.1  rillig  * Copyright (c) 2021 The NetBSD Foundation, Inc.
      5   1.1  rillig  * All rights reserved.
      6   1.1  rillig  *
      7   1.1  rillig  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1  rillig  * by Roland Illig <rillig (at) NetBSD.org>.
      9   1.1  rillig  *
     10   1.1  rillig  * Redistribution and use in source and binary forms, with or without
     11   1.1  rillig  * modification, are permitted provided that the following conditions
     12   1.1  rillig  * are met:
     13   1.1  rillig  * 1. Redistributions of source code must retain the above copyright
     14   1.1  rillig  *    notice, this list of conditions and the following disclaimer.
     15   1.1  rillig  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1  rillig  *    notice, this list of conditions and the following disclaimer in the
     17   1.1  rillig  *    documentation and/or other materials provided with the distribution.
     18   1.1  rillig  *
     19   1.1  rillig  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1  rillig  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1  rillig  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.1  rillig  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.1  rillig  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1  rillig  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1  rillig  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1  rillig  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1  rillig  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1  rillig  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1  rillig  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1  rillig  */
     31   1.1  rillig 
     32   1.1  rillig #if HAVE_NBTOOL_CONFIG_H
     33   1.1  rillig #include "nbtool_config.h"
     34   1.1  rillig #endif
     35   1.1  rillig 
     36   1.1  rillig #include <sys/cdefs.h>
     37  1.18  rillig #if defined(__RCSID)
     38  1.55  rillig __RCSID("$NetBSD: debug.c,v 1.55 2023/07/13 23:27:20 rillig Exp $");
     39   1.1  rillig #endif
     40   1.1  rillig 
     41   1.2  rillig #include <stdlib.h>
     42   1.2  rillig 
     43   1.1  rillig #include "lint1.h"
     44   1.9  rillig #include "cgram.h"
     45   1.1  rillig 
     46   1.1  rillig 
     47   1.1  rillig #ifdef DEBUG
     48   1.1  rillig 
     49   1.1  rillig static int debug_indentation = 0;
     50   1.1  rillig 
     51   1.1  rillig 
     52  1.32  rillig static FILE *
     53  1.32  rillig debug_file(void)
     54  1.32  rillig {
     55  1.32  rillig 	/*
     56  1.32  rillig 	 * Using stdout preserves the order between the debug messages and
     57  1.32  rillig 	 * lint's diagnostics.
     58  1.32  rillig 	 */
     59  1.48  rillig 	return yflag ? stderr : stdout;
     60  1.32  rillig }
     61  1.32  rillig 
     62  1.34  rillig void
     63   1.1  rillig debug_printf(const char *fmt, ...)
     64   1.1  rillig {
     65   1.1  rillig 	va_list va;
     66   1.1  rillig 
     67   1.1  rillig 	va_start(va, fmt);
     68  1.32  rillig 	(void)vfprintf(debug_file(), fmt, va);
     69   1.1  rillig 	va_end(va);
     70   1.1  rillig }
     71   1.1  rillig 
     72   1.1  rillig void
     73   1.7  rillig debug_print_indent(void)
     74   1.1  rillig {
     75   1.1  rillig 
     76  1.48  rillig 	debug_printf("%s%*s", yflag ? "| " : "", 2 * debug_indentation, "");
     77   1.1  rillig }
     78   1.1  rillig 
     79   1.1  rillig void
     80   1.1  rillig debug_indent_inc(void)
     81   1.1  rillig {
     82   1.1  rillig 
     83   1.1  rillig 	debug_indentation++;
     84   1.1  rillig }
     85   1.1  rillig 
     86   1.1  rillig void
     87   1.1  rillig debug_indent_dec(void)
     88   1.1  rillig {
     89   1.1  rillig 
     90   1.1  rillig 	debug_indentation--;
     91   1.1  rillig }
     92   1.1  rillig 
     93   1.1  rillig void
     94   1.1  rillig debug_step(const char *fmt, ...)
     95   1.1  rillig {
     96   1.1  rillig 	va_list va;
     97   1.1  rillig 
     98   1.7  rillig 	debug_print_indent();
     99   1.1  rillig 	va_start(va, fmt);
    100  1.32  rillig 	(void)vfprintf(debug_file(), fmt, va);
    101   1.1  rillig 	va_end(va);
    102  1.32  rillig 	fprintf(debug_file(), "\n");
    103   1.1  rillig }
    104   1.1  rillig 
    105   1.1  rillig void
    106  1.48  rillig debug_enter_func(const char *func)
    107  1.48  rillig {
    108  1.48  rillig 
    109  1.48  rillig 	debug_step("+ %s", func);
    110  1.48  rillig 	debug_indent_inc();
    111  1.48  rillig }
    112  1.48  rillig 
    113  1.48  rillig void
    114  1.28  rillig debug_leave_func(const char *func)
    115   1.1  rillig {
    116   1.1  rillig 
    117  1.48  rillig 	debug_indent_dec();
    118  1.48  rillig 	debug_step("- %s", func);
    119   1.1  rillig }
    120   1.1  rillig 
    121  1.22  rillig static void
    122  1.22  rillig debug_type_details(const type_t *tp)
    123  1.22  rillig {
    124  1.22  rillig 
    125  1.22  rillig 	if (is_struct_or_union(tp->t_tspec)) {
    126  1.22  rillig 		debug_indent_inc();
    127  1.38  rillig 		debug_step("size %u bits, align %u bits, %s",
    128  1.44  rillig 		    tp->t_sou->sou_size_in_bits, tp->t_sou->sou_align_in_bits,
    129  1.38  rillig 		    tp->t_sou->sou_incomplete ? "incomplete" : "complete");
    130  1.38  rillig 
    131  1.29  rillig 		for (const sym_t *mem = tp->t_sou->sou_first_member;
    132  1.22  rillig 		     mem != NULL; mem = mem->s_next) {
    133  1.22  rillig 			debug_sym("", mem, "\n");
    134  1.22  rillig 			debug_type_details(mem->s_type);
    135  1.22  rillig 		}
    136  1.22  rillig 		debug_indent_dec();
    137  1.22  rillig 	}
    138  1.22  rillig 	if (tp->t_is_enum) {
    139  1.22  rillig 		debug_indent_inc();
    140  1.22  rillig 		for (const sym_t *en = tp->t_enum->en_first_enumerator;
    141  1.22  rillig 		     en != NULL; en = en->s_next) {
    142  1.22  rillig 			debug_sym("", en, "\n");
    143  1.22  rillig 		}
    144  1.22  rillig 		debug_indent_dec();
    145  1.22  rillig 	}
    146  1.22  rillig }
    147  1.22  rillig 
    148  1.22  rillig void
    149  1.22  rillig debug_type(const type_t *tp)
    150  1.22  rillig {
    151  1.22  rillig 
    152  1.22  rillig 	debug_step("type details for '%s':", type_name(tp));
    153  1.22  rillig 	debug_type_details(tp);
    154  1.22  rillig }
    155  1.22  rillig 
    156   1.1  rillig void
    157  1.10  rillig debug_node(const tnode_t *tn) // NOLINT(misc-no-recursion)
    158   1.1  rillig {
    159   1.1  rillig 	op_t op;
    160   1.1  rillig 
    161   1.1  rillig 	if (tn == NULL) {
    162   1.2  rillig 		debug_step("null");
    163   1.1  rillig 		return;
    164   1.1  rillig 	}
    165   1.1  rillig 
    166   1.1  rillig 	op = tn->tn_op;
    167   1.7  rillig 	debug_print_indent();
    168  1.20  rillig 	debug_printf("'%s'",
    169  1.49  rillig 	    op == CVT && !tn->tn_cast ? "convert" : op_name(op));
    170  1.20  rillig 	if (op == NAME)
    171  1.20  rillig 		debug_printf(" '%s' with %s",
    172  1.20  rillig 		    tn->tn_sym->s_name,
    173  1.20  rillig 		    storage_class_name(tn->tn_sym->s_scl));
    174  1.20  rillig 	else
    175  1.20  rillig 		debug_printf(" type");
    176  1.20  rillig 	debug_printf(" '%s'", type_name(tn->tn_type));
    177  1.20  rillig 	if (tn->tn_lvalue)
    178  1.20  rillig 		debug_printf(", lvalue");
    179  1.20  rillig 	if (tn->tn_parenthesized)
    180  1.20  rillig 		debug_printf(", parenthesized");
    181  1.20  rillig 	if (tn->tn_sys)
    182  1.20  rillig 		debug_printf(", sys");
    183   1.1  rillig 
    184  1.24  rillig 	switch (op) {
    185  1.24  rillig 	case NAME:
    186  1.20  rillig 		debug_printf("\n");
    187  1.24  rillig 		break;
    188  1.24  rillig 	case CON:
    189  1.24  rillig 		if (is_floating(tn->tn_type->t_tspec))
    190  1.45  rillig 			debug_printf(", value %Lg", tn->tn_val.u.floating);
    191  1.24  rillig 		else if (is_uinteger(tn->tn_type->t_tspec))
    192  1.27  rillig 			debug_printf(", value %llu",
    193  1.45  rillig 			    (unsigned long long)tn->tn_val.u.integer);
    194  1.24  rillig 		else if (is_integer(tn->tn_type->t_tspec))
    195  1.27  rillig 			debug_printf(", value %lld",
    196  1.45  rillig 			    (long long)tn->tn_val.u.integer);
    197  1.27  rillig 		else {
    198  1.27  rillig 			lint_assert(tn->tn_type->t_tspec == BOOL);
    199  1.27  rillig 			debug_printf(", value %s",
    200  1.45  rillig 			    tn->tn_val.u.integer != 0 ? "true" : "false");
    201  1.27  rillig 		}
    202  1.36  rillig 		if (tn->tn_val.v_unsigned_since_c90)
    203  1.27  rillig 			debug_printf(", unsigned_since_c90");
    204  1.36  rillig 		if (tn->tn_val.v_char_constant)
    205  1.35  rillig 			debug_printf(", char_constant");
    206  1.27  rillig 		debug_printf("\n");
    207  1.24  rillig 		break;
    208  1.24  rillig 	case STRING:
    209  1.24  rillig 		if (tn->tn_string->st_char)
    210  1.24  rillig 			debug_printf(", length %zu, \"%s\"\n",
    211  1.24  rillig 			    tn->tn_string->st_len,
    212  1.24  rillig 			    (const char *)tn->tn_string->st_mem);
    213  1.24  rillig 		else {
    214  1.24  rillig 			size_t n = MB_CUR_MAX * (tn->tn_string->st_len + 1);
    215  1.24  rillig 			char *s = xmalloc(n);
    216  1.24  rillig 			(void)wcstombs(s, tn->tn_string->st_mem, n);
    217  1.24  rillig 			debug_printf(", length %zu, L\"%s\"\n",
    218  1.24  rillig 			    tn->tn_string->st_len, s);
    219  1.24  rillig 			free(s);
    220  1.24  rillig 		}
    221  1.24  rillig 		break;
    222  1.24  rillig 	default:
    223   1.2  rillig 		debug_printf("\n");
    224   1.1  rillig 
    225   1.2  rillig 		debug_indent_inc();
    226  1.30  rillig 		lint_assert(tn->tn_left != NULL);
    227   1.2  rillig 		debug_node(tn->tn_left);
    228  1.33  rillig 		if (op != INCBEF && op != INCAFT
    229  1.47  rillig 		    && op != DECBEF && op != DECAFT
    230  1.52  rillig 		    && op != CALL && op != ICALL && op != PUSH)
    231  1.33  rillig 			lint_assert(is_binary(tn) == (tn->tn_right != NULL));
    232  1.30  rillig 		if (tn->tn_right != NULL)
    233   1.2  rillig 			debug_node(tn->tn_right);
    234   1.2  rillig 		debug_indent_dec();
    235   1.1  rillig 	}
    236   1.1  rillig }
    237   1.1  rillig 
    238   1.9  rillig static const char *
    239   1.9  rillig def_name(def_t def)
    240   1.9  rillig {
    241   1.9  rillig 	static const char *const name[] = {
    242   1.9  rillig 		"not-declared",
    243   1.9  rillig 		"declared",
    244   1.9  rillig 		"tentative-defined",
    245   1.9  rillig 		"defined",
    246   1.9  rillig 	};
    247   1.9  rillig 
    248   1.9  rillig 	return name[def];
    249   1.9  rillig }
    250   1.9  rillig 
    251   1.9  rillig const char *
    252  1.40  rillig decl_level_kind_name(decl_level_kind kind)
    253  1.17  rillig {
    254  1.17  rillig 	static const char *const name[] = {
    255  1.17  rillig 		"extern",
    256  1.40  rillig 		"struct",
    257  1.40  rillig 		"union",
    258  1.40  rillig 		"enum",
    259  1.40  rillig 		"old-style-function-arguments",
    260  1.40  rillig 		"prototype-parameters",
    261  1.17  rillig 		"auto",
    262  1.17  rillig 		"abstract",
    263  1.17  rillig 	};
    264  1.17  rillig 
    265  1.40  rillig 	return name[kind];
    266  1.17  rillig }
    267  1.17  rillig 
    268  1.17  rillig const char *
    269   1.9  rillig scl_name(scl_t scl)
    270   1.9  rillig {
    271   1.9  rillig 	static const char *const name[] = {
    272   1.9  rillig 		"none",
    273   1.9  rillig 		"extern",
    274   1.9  rillig 		"static",
    275   1.9  rillig 		"auto",
    276   1.9  rillig 		"register",
    277   1.9  rillig 		"typedef",
    278  1.53  rillig 		"thread_local",
    279   1.9  rillig 		"struct",
    280   1.9  rillig 		"union",
    281   1.9  rillig 		"enum",
    282   1.9  rillig 		"member-of-struct",
    283   1.9  rillig 		"member-of-union",
    284   1.9  rillig 		"abstract",
    285   1.9  rillig 		"old-style-function-argument",
    286   1.9  rillig 		"prototype-argument",
    287   1.9  rillig 	};
    288   1.9  rillig 
    289   1.9  rillig 	return name[scl];
    290   1.9  rillig }
    291   1.9  rillig 
    292   1.9  rillig const char *
    293   1.9  rillig symt_name(symt_t kind)
    294   1.9  rillig {
    295   1.9  rillig 	static const char *const name[] = {
    296   1.9  rillig 		"var-func-type",
    297   1.9  rillig 		"member",
    298   1.9  rillig 		"tag",
    299   1.9  rillig 		"label",
    300   1.9  rillig 	};
    301   1.9  rillig 
    302   1.9  rillig 	return name[kind];
    303   1.9  rillig }
    304   1.9  rillig 
    305   1.9  rillig const char *
    306  1.54  rillig type_qualifiers_string(type_qualifiers tq)
    307   1.9  rillig {
    308  1.54  rillig 	static char buf[32];
    309   1.9  rillig 
    310  1.54  rillig 	snprintf(buf, sizeof(buf), "%s%s%s%s",
    311  1.54  rillig 	    tq.tq_const ? " const" : "",
    312  1.54  rillig 	    tq.tq_restrict ? " restrict" : "",
    313  1.54  rillig 	    tq.tq_volatile ? " volatile" : "",
    314  1.54  rillig 	    tq.tq_atomic ? " atomic" : "");
    315  1.54  rillig 	return buf[0] != '\0' ? buf + 1 : "none";
    316   1.9  rillig }
    317   1.9  rillig 
    318  1.50  rillig const char *
    319  1.50  rillig function_specifier_name(function_specifier spec)
    320  1.50  rillig {
    321  1.50  rillig 	static const char *const name[] = {
    322  1.50  rillig 		"inline",
    323  1.51  rillig 		"_Noreturn",
    324  1.50  rillig 	};
    325  1.50  rillig 
    326  1.50  rillig 	return name[spec];
    327  1.50  rillig }
    328  1.50  rillig 
    329   1.9  rillig static void
    330   1.9  rillig debug_word(bool flag, const char *name)
    331   1.9  rillig {
    332   1.9  rillig 
    333   1.9  rillig 	if (flag)
    334   1.9  rillig 		debug_printf(" %s", name);
    335   1.9  rillig }
    336   1.9  rillig 
    337   1.9  rillig void
    338  1.10  rillig debug_sym(const char *prefix, const sym_t *sym, const char *suffix)
    339   1.9  rillig {
    340   1.9  rillig 
    341  1.21  rillig 	if (suffix[0] == '\n')
    342  1.21  rillig 		debug_print_indent();
    343  1.10  rillig 	debug_printf("%s%s", prefix, sym->s_name);
    344   1.9  rillig 	if (sym->s_type != NULL)
    345   1.9  rillig 		debug_printf(" type='%s'", type_name(sym->s_type));
    346   1.9  rillig 	if (sym->s_rename != NULL)
    347   1.9  rillig 		debug_printf(" rename=%s", sym->s_rename);
    348   1.9  rillig 	debug_printf(" %s", symt_name(sym->s_kind));
    349   1.9  rillig 	debug_word(sym->s_keyword != NULL, "keyword");
    350   1.9  rillig 	debug_word(sym->s_bitfield, "bit-field");
    351   1.9  rillig 	debug_word(sym->s_set, "set");
    352   1.9  rillig 	debug_word(sym->s_used, "used");
    353   1.9  rillig 	debug_word(sym->s_arg, "argument");
    354   1.9  rillig 	debug_word(sym->s_register, "register");
    355   1.9  rillig 	debug_word(sym->s_defarg, "old-style-undefined");
    356   1.9  rillig 	debug_word(sym->s_return_type_implicit_int, "return-int");
    357   1.9  rillig 	debug_word(sym->s_osdef, "old-style");
    358   1.9  rillig 	debug_word(sym->s_inline, "inline");
    359   1.9  rillig 	debug_word(sym->s_ext_sym != NULL, "has-external");
    360   1.9  rillig 	debug_word(sym->s_scl != NOSCL, scl_name(sym->s_scl));
    361   1.9  rillig 	debug_word(sym->s_keyword == NULL, def_name(sym->s_def));
    362   1.9  rillig 
    363   1.9  rillig 	if (sym->s_def_pos.p_file != NULL)
    364   1.9  rillig 		debug_printf(" defined-at=%s:%d",
    365   1.9  rillig 		    sym->s_def_pos.p_file, sym->s_def_pos.p_line);
    366   1.9  rillig 	if (sym->s_set_pos.p_file != NULL)
    367   1.9  rillig 		debug_printf(" set-at=%s:%d",
    368   1.9  rillig 		    sym->s_set_pos.p_file, sym->s_set_pos.p_line);
    369   1.9  rillig 	if (sym->s_use_pos.p_file != NULL)
    370   1.9  rillig 		debug_printf(" used-at=%s:%d",
    371   1.9  rillig 		    sym->s_use_pos.p_file, sym->s_use_pos.p_line);
    372   1.9  rillig 
    373  1.14  rillig 	if (sym->s_type != NULL && sym->s_type->t_is_enum)
    374  1.14  rillig 		debug_printf(" value=%d", sym->u.s_enum_constant);
    375  1.14  rillig 	if (sym->s_type != NULL && sym->s_type->t_tspec == BOOL)
    376  1.14  rillig 		debug_printf(" value=%s",
    377  1.14  rillig 		    sym->u.s_bool_constant ? "true" : "false");
    378   1.9  rillig 
    379  1.39  rillig 	if (is_member(sym)) {
    380  1.42  rillig 		struct_or_union *sou = sym->u.s_member.sm_containing_type;
    381  1.42  rillig 		const char *tag = sou->sou_tag->s_name;
    382  1.42  rillig 		const sym_t *def = sou->sou_first_typedef;
    383   1.9  rillig 		if (tag == unnamed && def != NULL)
    384   1.9  rillig 			debug_printf(" sou='typedef %s'", def->s_name);
    385   1.9  rillig 		else
    386  1.42  rillig 			debug_printf(" sou='%s'", tag);
    387   1.9  rillig 	}
    388   1.9  rillig 
    389   1.9  rillig 	if (sym->s_keyword != NULL) {
    390  1.14  rillig 		int t = sym->u.s_keyword.sk_token;
    391   1.9  rillig 		if (t == T_TYPE || t == T_STRUCT_OR_UNION)
    392  1.14  rillig 			debug_printf(" %s",
    393  1.50  rillig 			    tspec_name(sym->u.s_keyword.u.sk_tspec));
    394  1.42  rillig 		if (t == T_QUAL)
    395  1.54  rillig 			debug_printf(" %s", type_qualifiers_string(
    396  1.54  rillig 			    sym->u.s_keyword.u.sk_type_qualifier));
    397  1.50  rillig 		if (t == T_FUNCTION_SPECIFIER)
    398  1.50  rillig 			debug_printf(" %s", function_specifier_name(
    399  1.50  rillig 			    sym->u.s_keyword.u.function_specifier));
    400   1.9  rillig 	}
    401   1.9  rillig 
    402  1.12  rillig 	debug_word(sym->s_osdef && sym->u.s_old_style_args != NULL,
    403  1.12  rillig 	    "old-style-args");
    404   1.9  rillig 
    405  1.10  rillig 	debug_printf("%s", suffix);
    406  1.10  rillig }
    407  1.10  rillig 
    408  1.43  rillig static void
    409  1.43  rillig debug_decl_level(const decl_level *dl)
    410  1.10  rillig {
    411  1.10  rillig 
    412  1.10  rillig 	debug_print_indent();
    413  1.40  rillig 	debug_printf("decl_level: %s", decl_level_kind_name(dl->d_kind));
    414  1.40  rillig 	if (dl->d_scl != NOSCL)
    415  1.40  rillig 		debug_printf(" %s", scl_name(dl->d_scl));
    416  1.40  rillig 	if (dl->d_type != NULL)
    417  1.40  rillig 		debug_printf(" '%s'", type_name(dl->d_type));
    418  1.40  rillig 	else {
    419  1.40  rillig 		if (dl->d_abstract_type != NO_TSPEC)
    420  1.40  rillig 			debug_printf(" %s", tspec_name(dl->d_abstract_type));
    421  1.40  rillig 		if (dl->d_complex_mod != NO_TSPEC)
    422  1.40  rillig 			debug_printf(" %s", tspec_name(dl->d_complex_mod));
    423  1.40  rillig 		if (dl->d_sign_mod != NO_TSPEC)
    424  1.40  rillig 			debug_printf(" %s", tspec_name(dl->d_sign_mod));
    425  1.40  rillig 		if (dl->d_rank_mod != NO_TSPEC)
    426  1.40  rillig 			debug_printf(" %s", tspec_name(dl->d_rank_mod));
    427  1.10  rillig 	}
    428  1.40  rillig 	if (dl->d_redeclared_symbol != NULL)
    429  1.40  rillig 		debug_sym(" redeclared=(", dl->d_redeclared_symbol, ")");
    430  1.46  rillig 	if (dl->d_sou_size_in_bits != 0)
    431  1.46  rillig 		debug_printf(" size=%u", dl->d_sou_size_in_bits);
    432  1.40  rillig 	if (dl->d_sou_align_in_bits != 0)
    433  1.44  rillig 		debug_printf(" align=%u", dl->d_sou_align_in_bits);
    434  1.40  rillig 
    435  1.55  rillig 	debug_word(dl->d_qual.tq_const, "const");
    436  1.55  rillig 	debug_word(dl->d_qual.tq_restrict, "restrict");
    437  1.55  rillig 	debug_word(dl->d_qual.tq_volatile, "volatile");
    438  1.55  rillig 	debug_word(dl->d_qual.tq_atomic, "atomic");
    439  1.40  rillig 	debug_word(dl->d_inline, "inline");
    440  1.40  rillig 	debug_word(dl->d_multiple_storage_classes, "multiple_storage_classes");
    441  1.40  rillig 	debug_word(dl->d_invalid_type_combination, "invalid_type_combination");
    442  1.40  rillig 	debug_word(dl->d_nonempty_decl, "nonempty_decl");
    443  1.40  rillig 	debug_word(dl->d_vararg, "vararg");
    444  1.40  rillig 	debug_word(dl->d_prototype, "prototype");
    445  1.40  rillig 	debug_word(dl->d_no_type_specifier, "no_type_specifier");
    446  1.40  rillig 	debug_word(dl->d_asm, "asm");
    447  1.40  rillig 	debug_word(dl->d_packed, "packed");
    448  1.40  rillig 	debug_word(dl->d_used, "used");
    449  1.40  rillig 
    450  1.40  rillig 	if (dl->d_tag_type != NULL)
    451  1.40  rillig 		debug_printf(" tag_type='%s'", type_name(dl->d_tag_type));
    452  1.40  rillig 	for (const sym_t *arg = dl->d_func_args;
    453  1.10  rillig 	     arg != NULL; arg = arg->s_next)
    454  1.10  rillig 		debug_sym(" arg(", arg, ")");
    455  1.40  rillig 	if (dl->d_func_def_pos.p_file != NULL)
    456  1.41  rillig 		debug_printf(" func_def_pos=%s:%d:%d",
    457  1.40  rillig 		    dl->d_func_def_pos.p_file, dl->d_func_def_pos.p_line,
    458  1.40  rillig 		    dl->d_func_def_pos.p_uniq);
    459  1.40  rillig 	for (const sym_t *sym = dl->d_func_proto_syms;
    460  1.10  rillig 	     sym != NULL; sym = sym->s_next)
    461  1.23  rillig 		debug_sym(" func_proto_sym(", sym, ")");
    462   1.9  rillig 	debug_printf("\n");
    463  1.43  rillig }
    464  1.10  rillig 
    465  1.43  rillig void
    466  1.43  rillig debug_dcs(bool all)
    467  1.43  rillig {
    468  1.43  rillig 	int prev_indentation = debug_indentation;
    469  1.43  rillig 	for (const decl_level *dl = dcs; dl != NULL; dl = dl->d_enclosing) {
    470  1.43  rillig 		debug_decl_level(dl);
    471  1.43  rillig 		if (!all)
    472  1.43  rillig 			return;
    473  1.43  rillig 		debug_indentation++;
    474  1.10  rillig 	}
    475  1.43  rillig 	debug_indentation = prev_indentation;
    476   1.9  rillig }
    477   1.1  rillig #endif
    478