Fixes for compiling ego with -DTRACE

- In share/debug.c, undo my mistake in commit 9037d13 by changing
   vfprintf back to fprintf in OUTTRACE.

 - In ud/ud.c, move the trace output from stdout to stderr, because
   stdout has ego's output file, which becomes opt2's input file.  If
   trace output goes to stdout, it gets prepended to the output file,
   and opt2 errors with "wrong input file".

I also edit both build.lua files so ego depends on its header files;
this part isn't needed for -DTRACE.

One can now use -DTRACE by adding it to the cflags in both build.lua
files.
This commit is contained in:
George Koehler 2018-03-01 13:19:38 -05:00
parent 0a6d3de7fe
commit a7bb4ec4b1
4 changed files with 24 additions and 23 deletions

View file

@ -3,6 +3,7 @@ local function build_ego(name)
name = name, name = name,
srcs = { "./"..name.."/*.c" }, srcs = { "./"..name.."/*.c" },
deps = { deps = {
"./"..name.."/*.h",
"util/ego/share+lib", "util/ego/share+lib",
"modules/src/em_data+lib", "modules/src/em_data+lib",
"h+emheaders", "h+emheaders",

View file

@ -48,6 +48,7 @@ clibrary {
"./init_glob.c", "./init_glob.c",
}, },
deps = { deps = {
"./*.h",
"+classdefs_h", "+classdefs_h",
"+pop_push_h", "+pop_push_h",
"h+emheaders", "h+emheaders",
@ -57,5 +58,3 @@ clibrary {
["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"} ["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"}
} }
} }

View file

@ -45,7 +45,7 @@ void error(const char *s, ...)
void OUTTRACE(const char *s, int n) void OUTTRACE(const char *s, int n)
{ {
fprintf(stderr,"> "); fprintf(stderr,"> ");
vfprintf(stderr,s,n); fprintf(stderr,s,n);
fprintf(stderr,"\n"); fprintf(stderr,"\n");
} }
#endif #endif

View file

@ -269,13 +269,13 @@ pr_localtab() {
short i; short i;
local_p lc; local_p lc;
printf("LOCAL-TABLE (%d)\n\n",nrlocals); fprintf(stderr,"LOCAL-TABLE (%d)\n\n",nrlocals);
for (i = 1; i <= nrlocals; i++) { for (i = 1; i <= nrlocals; i++) {
lc = locals[i]; lc = locals[i];
printf("LOCAL %d\n",i); fprintf(stderr,"LOCAL %d\n",i);
printf(" offset= %ld\n",lc->lc_off); fprintf(stderr,"\toffset= %ld\n",lc->lc_off);
printf(" size= %d\n",lc->lc_size); fprintf(stderr,"\tsize= %d\n",lc->lc_size);
printf(" flags= %d\n",lc->lc_flags); fprintf(stderr,"\tflags= %d\n",lc->lc_flags);
} }
} }
@ -284,12 +284,13 @@ pr_globals()
dblock_p d; dblock_p d;
obj_p obj; obj_p obj;
printf("GLOBALS (%d)\n\n",nrglobals); fprintf(stderr,"GLOBALS (%d)\n\n",nrglobals);
printf("ID GLOBNR\n"); fprintf(stderr,"ID\tGLOBNR\n");
for (d = fdblock; d != (dblock_p) 0; d = d->d_next) { for (d = fdblock; d != (dblock_p) 0; d = d->d_next) {
for (obj = d->d_objlist; obj != (obj_p) 0; obj = obj->o_next) { for (obj = d->d_objlist; obj != (obj_p) 0; obj = obj->o_next) {
if (obj->o_globnr != 0) { if (obj->o_globnr != 0) {
printf("%d %d\n", obj->o_id,obj->o_globnr); fprintf(stderr,"%d\t%d\n",
obj->o_id,obj->o_globnr);
} }
} }
} }
@ -302,20 +303,20 @@ pr_defs()
short i; short i;
line_p l; line_p l;
printf("DEF TABLE\n\n"); fprintf(stderr,"DEF TABLE\n\n");
for (i = 1; i <= nrexpldefs; i++) { for (i = 1; i <= nrexpldefs; i++) {
l = defs[i]; l = defs[i];
printf("%d %s ",EXPL_TO_DEFNR(i), fprintf(stderr,"%d\t%s ",EXPL_TO_DEFNR(i),
&em_mnem[(INSTR(l)-sp_fmnem)*4]); &em_mnem[(INSTR(l)-sp_fmnem)*4]);
switch(TYPE(l)) { switch(TYPE(l)) {
case OPSHORT: case OPSHORT:
printf("%d\n",SHORT(l)); fprintf(stderr,"%d\n",SHORT(l));
break; break;
case OPOFFSET: case OPOFFSET:
printf("%ld\n",OFFSET(l)); fprintf(stderr,"%ld\n",OFFSET(l));
break; break;
case OPOBJECT: case OPOBJECT:
printf("%d\n",OBJ(l)->o_id); fprintf(stderr,"%d\n",OBJ(l)->o_id);
break; break;
default: default:
assert(FALSE); assert(FALSE);
@ -331,13 +332,13 @@ pr_set(name,k,s,n)
{ {
short i; short i;
printf("%s(%d) = {",name,k); fprintf(stderr,"%s(%d) =\t{",name,k);
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
if (Cis_elem(i,s)) { if (Cis_elem(i,s)) {
printf("%d ",i); fprintf(stderr,"%d ",i);
} }
} }
printf ("}\n"); fprintf(stderr,"}\n");
} }
pr_blocks(p) pr_blocks(p)
@ -347,7 +348,7 @@ pr_blocks(p)
short n; short n;
for (b = p->p_start; b != 0; b = b->b_next) { for (b = p->p_start; b != 0; b = b->b_next) {
printf ("\n"); fprintf(stderr,"\n");
n = b->b_id; n = b->b_id;
pr_set("GEN",n,GEN(b),nrdefs); pr_set("GEN",n,GEN(b),nrdefs);
pr_set("KILL",n,KILL(b),nrdefs); pr_set("KILL",n,KILL(b),nrdefs);
@ -361,10 +362,10 @@ pr_copies()
{ {
short i; short i;
printf("\nCOPY TABLE\n\n"); fprintf(stderr,"\nCOPY TABLE\n\n");
for (i = 1; i <= nrdefs; i++) { for (i = 1; i <= nrdefs; i++) {
if (def_to_copynr[i] != 0) { if (def_to_copynr[i] != 0) {
printf("%d %d\n",i,def_to_copynr[i]); fprintf(stderr,"%d\t%d\n",i,def_to_copynr[i]);
} }
} }
} }
@ -376,7 +377,7 @@ pr_cblocks(p)
short n; short n;
for (b = p->p_start; b != 0; b = b->b_next) { for (b = p->p_start; b != 0; b = b->b_next) {
printf ("\n"); fprintf(stderr,"\n");
n = b->b_id; n = b->b_id;
pr_set("CGEN",n,C_GEN(b),nrcopies); pr_set("CGEN",n,C_GEN(b),nrcopies);
pr_set("CKILL",n,C_KILL(b),nrcopies); pr_set("CKILL",n,C_KILL(b),nrcopies);