scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 84dc5931c9833ed6b0421c2077e3589a9e541366
parent 680f022d8d445105d7164cf9e45925e62c8458d3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 29 Sep 2017 21:43:38 +0200

[as] Add dumpstab()

This function is very important to debug symbol table problems.

Diffstat:
Mas/as.h | 1+
Mas/symbol.c | 21+++++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/as/as.h b/as/as.h @@ -109,6 +109,7 @@ extern Section *section(char *name); extern Symbol *tmpsym(TUINT val); extern void killtmp(void); extern int toobig(Node *np, int type); +extern void dumpstab(char *msg); /* main.c */ extern Symbol *lookup(char *name, int type); diff --git a/as/symbol.c b/as/symbol.c @@ -43,6 +43,27 @@ static Alloc *tmpalloc; Symbol *linesym; +#ifndef NDEBUG +void +dumpstab(char *msg) +{ + Symbol **bp, *sym; + + fprintf(stderr, "%s\n", msg); + for (bp = hashtbl; bp < &hashtbl[HASHSIZ]; ++bp) { + if (*bp == NULL) + continue; + + fprintf(stderr, "[%d]", (int) (bp - hashtbl)); + for (sym = *bp; sym; sym = sym->next) { + fprintf(stderr, " -> %s:%0X:%0X", + sym->name, sym->flags, sym->argtype); + } + putc('\n', stderr); + } +} +#endif + Symbol * lookup(char *name, int type) {