scc

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

commit a75d6253fd88d03d1f1948461f08cb035809070e
parent e3c35eb76e3151c9d6eed88bf288cbf109d21ffd
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 28 May 2015 16:07:22 +0200

Add debug information about macro expansion

It is known that the macro expansion process is broken,
so it is useful to have this information for debugging.

Diffstat:
Mcc1/cpp.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -218,6 +218,7 @@ expand(Symbol *sym) char *arglist[NR_MACROARG], arguments[INPUTSIZ], buffer[BUFSIZE]; char prevc, c, *bp, *lim, *arg, *s = sym->u.s; + fprintf(stderr, "macro %s:%s\n", sym->name, sym->u.s); if (sym == symfile) { sprintf(buffer, "\"%s\"", getfname()); goto add_macro; @@ -231,6 +232,9 @@ expand(Symbol *sym) if ((r = parsepars(arguments, arglist, atoi(s))) < 1) return r; + for (int n = 0; n < atoi(s); ++n) + fprintf(stderr, "PAR%d:%s\n", n, arglist[n]); + len = INPUTSIZ-1; bp = buffer; for (prevc = '\0', s += 3; c = *s; prevc = c, ++s) { @@ -260,6 +264,7 @@ expand(Symbol *sym) } } *bp = '\0'; + fprintf(stderr, "macro expanded:%s\n", buffer); add_macro: addinput(NULL, sym, buffer); return 1;