akkartik / mu

Soul of a tiny new machine. More thorough tests → More comprehensible and rewrite-friendly software → More resilient society.
http://akkartik.name/akkartik-convivial-20200607.pdf
Other
1.38k stars 47 forks source link

SubX: Would be nice to have a --quiet flag to turn off tracing #12

Closed tekknolagi closed 6 years ago

akkartik commented 6 years ago

It's quiet, I thought? What are you doing when it's noisy?

tekknolagi commented 6 years ago
willow% ./subx run ex2                 
1 entries in the program header, each 20 bytes long
program header at offset 34: type 1
blitting file offsets (54, 66) to addresses (8048054, 8048066)
willow% 
akkartik commented 6 years ago

Ah, got it. That's not the tracing, just prints using cerr. We can just comment them out, no problem. Wanna do a PR? Just scan for all cerrs in the repo.

tekknolagi commented 6 years ago
willow% ack cerr 0*.cc
000organization.cc
154:    cerr << "SubX requires a little-endian processor. Do you have Intel (or AMD or Atom) inside?\n";
160:using std::cerr;

001help.cc
8:  cerr << get(Help, "usage");
14:    cerr << "help on what?\n";
21:    cerr << get(Help, key);
25:    cerr << "No help found for '" << key << "'\n";
27:    cerr << "Please check your command for typos.\n";
34:  cerr << "Available top-level topics:\n";
35:  cerr << "  usage\n";
149://? cerr << INT_MAX+1 << '\n';  // test overflow
165:        cerr << "SIGABRT: might be an integer overflow if it wasn't an assert() failure\n";
171:        cerr << "SIGILL: most likely caused by integer overflow\n";
189://? cerr << "ε: " << smallest_subnormal_f << '\n';
190://? cerr << "ε/2: " << smallest_subnormal_f/2 << " (underflow)\n";  // test SIGFPE
252:using std::cerr;

002test.cc
26:    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << '\n'; \
33:    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << " == " << #Y << '\n'; \
34:    cerr << "  got " << (X) << '\n';  /* BEWARE: multiple eval */ \
55:  cerr << "C tests: " << ctime(&t);
57://?     cerr << "running " << Test_names[i] << '\n';
59:    if (Passed) cerr << '.';
62:  cerr << '\n';
65:    cerr << num_failures << " failure"
76:    cerr << "no test " << i << '\n';
98:    if (Passed) cerr << ".\n";

003trace.cc
134:      cerr << curr_label << ": " << curr_contents << '\n';
160:#define trace(...)  !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(__VA_ARGS__)
164:#define DUMP(label)  if (Trace_stream) cerr << Trace_stream->readable_contents(label);
167:#define raise  (!Trace_stream ? (++Trace_errors,cerr) /*do print*/ : Trace_stream->stream(Error_depth, "error"))
222:    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \
230:    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \
231:    cerr << "  got " << trace_count(label) << '\n';  /* multiple eval */ \
261:    cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): line [" << label << ": " << contents << "] out of order in trace:\n";
265:    cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << contents << "] in trace:\n";

010vm.cc
35:cerr << "  registers\n";
150://?   cerr << "inst: 0x" << EIP << '\n';
160:      cerr << "unrecognized second opcode after 0f: " << HEXBYTE << NUM(op2) << '\n';
172:        cerr << "unrecognized third opcode after f3 0f: " << HEXBYTE << NUM(op3) << '\n';
178:      cerr << "unrecognized second opcode after f3: " << HEXBYTE << NUM(op2) << '\n';
184:    cerr << "unrecognized opcode: " << HEXBYTE << NUM(op) << '\n';
210:  cerr << "Opcodes currently supported by SubX:\n";
212:    cerr << "  " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
214:    cerr << "  0f " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
216:    cerr << "  f3 " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
218:    cerr << "  f3 0f " << HEXBYTE << NUM(p->first) << ": " << p->second << '\n';
219:  cerr << "Run `subx help instructions` for details on words like 'r32' and 'disp8'.\n";
223:cerr << "  opcodes\n";

011parse.cc
36:cerr << "  syntax\n";

012direct_addressing.cc
43:    cerr << "unrecognized mod bits: " << NUM(mod) << '\n';

014immediate_addressing.cc
31:    cerr << "unrecognized sub-opcode after 81: " << NUM(subop) << '\n';

020elf.cc
10:  cerr << std::hex;

021translate.cc
29:    cerr << "could not open " << argv[2] << '\n';
33:  cerr << "DONE NOW FUCK THIS (parse)" << std::endl;
36:  cerr << "DONE NOW FUCK THIS (transform)" << std::endl;

022check_instruction.cc
51:cerr << "  instructions\n";
279://?     cerr << "comparing " << HEXBYTE << NUM(bitvector) << " with " << NUM(expected) << '\n';