ref: 29ce560862d68477b95bc6d1898facadc5421ffa
parent: caa829c88284e8ac2c213d178f62943548d9b7ad
author: Ori Bernstein <[email protected]>
date: Sat Jan 19 10:52:03 EST 2013
Make debug dumps less verbose and more controllable The '-d' option now requires a debug flag.
--- a/6/isel.c
+++ b/6/isel.c
@@ -920,7 +920,7 @@
epilogue(&is);
regalloc(&is);
- if (debug)
+ if (debugopt['i'])
writeasm(stdout, &is, fn);
writeasm(fd, &is, fn);
}
--- a/6/main.c
+++ b/6/main.c
@@ -17,7 +17,6 @@
/* FIXME: move into one place...? */
Node *file;
-int debug;
char debugopt[128];
char *outfile;
char **incpaths;
@@ -58,7 +57,7 @@
Stab *globls;
char buf[1024];
- while ((opt = getopt(argc, argv, "d::hSo:I:")) != -1) {
+ while ((opt = getopt(argc, argv, "d:hSo:I:")) != -1) {
switch (opt) {
case 'o':
outfile = optarg;
@@ -68,7 +67,6 @@
exit(0);
break;
case 'd':
- debug = 1;
while (optarg && *optarg) {
if (*optarg == 'y')
yydebug = 1;
@@ -100,7 +98,7 @@
dump(file, stdout);
infer(file);
/* after all processing */
- if (debug)
+ if (debugopt['t'])
dump(file, stdout);
swapsuffix(buf, 1024, argv[i], ".myr", ".s");
--- a/6/simp.c
+++ b/6/simp.c
@@ -1197,7 +1197,7 @@
assert(n->type == Ndecl);
s->stksz += size(n);
s->stksz = align(s->stksz, min(size(n), Ptrsz));
- if (debug)
+ if (debugopt['i'])
printf("declare %s:%s(%zd) at %zd\n", declname(n), tystr(decltype(n)), n->decl.did, s->stksz);
htput(s->locs, n, (void*)s->stksz);
}
@@ -1206,7 +1206,7 @@
{
assert(n->type == Ndecl);
s->argsz = align(s->argsz, min(size(n), Ptrsz));
- if (debug)
+ if (debugopt['i'])
printf("declare %s(%zd) at %zd\n", declname(n), n->decl.did, -(s->argsz + 2*Ptrsz));
htput(s->locs, n, (void*)-(s->argsz + 2*Ptrsz));
s->argsz += size(n);
@@ -1304,7 +1304,7 @@
Func *fn;
Cfg *cfg;
- if(debug)
+ if(debugopt['i'])
printf("\n\nfunction %s\n", name);
if (!n->decl.init)
@@ -1317,7 +1317,7 @@
flatten(s, n);
popstab();
- if (debug)
+ if (debugopt['f'])
for (i = 0; i < s->nstmts; i++)
dump(s->stmts[i], stdout);
for (i = 0; i < s->nstmts; i++) {
@@ -1329,14 +1329,14 @@
}
s->stmts[i] = fold(s->stmts[i]);
if (debugopt['f']) {
- printf("FOLD TO ------------\n");
+ printf("TO ------------\n");
dump(s->stmts[i], stdout);
- printf("END ----------------\n");
+ printf("DONE ----------------\n");
}
}
cfg = mkcfg(s->stmts, s->nstmts);
- if (debug)
+ if (debugopt['t'])
dumpcfg(cfg, stdout);
fn = zalloc(sizeof(Func));
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -249,7 +249,6 @@
};
/* globals */
-extern int debug;
extern char *filename;
extern int ignorenl; /* are '\n' chars currently stmt separators? */
extern Tok *curtok; /* the last token we tokenized */
@@ -472,7 +471,6 @@
char *swapsuffix(char *buf, size_t sz, char *s, char *suf, char *swap);
/* Options to control the compilation */
-extern int debug;
extern int yydebug;
extern char debugopt[128];
extern int asmonly;