ref: 2a872329eddbee463a4150cfb6082feacb0761c0
parent: 0f7ab686171677c9d8e7e6d6c5c518038c8e25cb
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue May 26 04:21:35 EDT 2015
Add dumpstab() This function dumps the content of the symbol table hash and it is useful for debugging.
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -251,6 +251,7 @@
extern Type *mktype(Type *tp, unsigned op, short nelem, void *data);
/* symbol.c */
+extern void dumpstab(char *msg);
extern Symbol *lookup(unsigned ns);
extern Symbol *install(unsigned ns);
extern Symbol *newsym(unsigned ns);
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -16,6 +16,26 @@
static Symbol *head;
static Symbol *htab[NR_SYM_HASH];
+#ifndef NDEBUG
+#include <stdio.h>
+void
+dumpstab(char *msg)
+{
+ Symbol **bp, *sym;
+
+ fputs(msg, stderr);
+ putc('\n', stderr);
+ for (bp = htab; bp < &htab[NR_SYM_HASH]; ++bp) {
+ if (*bp == NULL)
+ continue;
+ fprintf(stderr, "%d", bp - htab);
+ for (sym = *bp; sym; sym = sym->hash)
+ fprintf(stderr, "->%d:%s", sym->ns, sym->name);
+ putc('\n', stderr);
+ }
+}
+#endif
+
static inline unsigned
hash(const char *s)
{