shithub: scc

Download patch

ref: 83efd585c4f9bb54bceb3e83a754be443c662e88
parent: 8bee0cb1862bc8c92ac43a8cee1ee21afad070b4
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Feb 19 03:42:04 EST 2017

[cc1] Pass table  as parameter to dumpstab()

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

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -389,7 +389,7 @@
 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);
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -20,12 +20,12 @@
 
 #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));
@@ -36,6 +36,12 @@
 	}
 	fputs("head:", stderr);
 	for (sym = head; sym; sym = sym->next) {
+		fprintf(stderr, "->[%d,%d:'%s'=%p]",
+		        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);