scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 7961958fd5f94b21d4c1c136d064bedb337303a4
parent 3cc5a49bf9108eb49ed5032e587221286ea11357
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 19 Feb 2017 08:42:04 +0100

[cc1] Pass table  as parameter to dumpstab()

This function can be used for debugging the cpp and lexcial tables.

Diffstat:
Mcc1/cc1.h | 2+-
Mcc1/symbol.c | 10++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -389,7 +389,7 @@ extern void typesize(Type *tp); extern void flushtypes(void); /* symbol.c */ -extern void dumpstab(char *msg); +extern void dumpstab(Symbol **tbl, char *msg); extern Symbol *lookup(int ns, char *name, int alloc); extern Symbol *nextsym(Symbol *sym, int ns); extern Symbol *install(int ns, Symbol *sym); diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -20,12 +20,12 @@ static Symbol *htabcpp[NR_SYM_HASH]; #ifndef NDEBUG void -dumpstab(char *msg) +dumpstab(Symbol **tbl, char *msg) { Symbol **bp, *sym; fprintf(stderr, "Symbol Table dump at ctx=%u\n%s\n", curctx, msg); - for (bp = htab; bp < &htab[NR_SYM_HASH]; ++bp) { + for (bp = tbl; bp < &tbl[NR_SYM_HASH]; ++bp) { if (*bp == NULL) continue; fprintf(stderr, "%d", (int) (bp - htab)); @@ -40,6 +40,12 @@ dumpstab(char *msg) sym->ns, sym->ctx, (sym->name) ? sym->name : "", (void *) sym); } + fputs("\nlabels:", stderr); + for (sym = labels; sym; sym = sym->next) { + fprintf(stderr, "->[%d,%d:'%s'=%p]", + sym->ns, sym->ctx, + (sym->name) ? sym->name : "", (void *) sym); + } putc('\n', stderr); } #endif