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