shithub: scc

Download patch

ref: a75d6253fd88d03d1f1948461f08cb035809070e
parent: e3c35eb76e3151c9d6eed88bf288cbf109d21ffd
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu May 28 12:07:22 EDT 2015

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.

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -218,6 +218,7 @@
 	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 @@
 	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 @@
 		}
 	}
 	*bp = '\0';
+	fprintf(stderr, "macro expanded:%s\n", buffer);
 add_macro:
 	addinput(NULL, sym, buffer);
 	return 1;