shithub: scc

Download patch

ref: d95c5300d65d7416a1b0d31d34d648c6a1a70373
parent: ae6540fbe147eb182f05e94cd4072dc55b806196
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Nov 1 05:20:00 EDT 2021

cc1: Add an additional parameter to prtree()

This parameter helps to add more sensible information
in the debug output.

--- a/src/cmd/cc/cc1/cc1.h
+++ b/src/cmd/cc/cc1/cc1.h
@@ -458,7 +458,7 @@
 #define accept(t) ((yytoken == (t)) ? next() : 0)
 
 /* code.c */
-extern void prtree(Node *np);
+extern void prtree(char *s, Node *np);
 extern void emit(int, void *);
 extern Node *node(int op, Type *tp, Node *left, Node *rigth);
 extern Node *varnode(Symbol *sym);
--- a/src/cmd/cc/cc1/code.c
+++ b/src/cmd/cc/cc1/code.c
@@ -165,10 +165,10 @@
 }
 
 void
-prtree(Node *np)
+prtree(char *s, Node *np)
 {
 	outfp = stderr;
-	fputs("DBG prtree", outfp);
+	fprintf(outfp, "DBG prtree %s", s);
 	emitnode(np);
 	putc('\n', outfp);
 	outfp = stdout;
--- a/src/cmd/cc/cc1/fold.c
+++ b/src/cmd/cc/cc1/fold.c
@@ -637,8 +637,9 @@
 
 	if (!np)
 		return NULL;
+
 	if (enadebug)
-		prtree(np);
+		prtree("simplify", np);
 
 	l = np->left = simplify(np->left);
 	r = np->right = simplify(np->right);