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