4986 - spending some time improving SubX traces
Now that our test runs are getting longer, debugging is again becoming a bottleneck. Time to start using trace depths along with `mu browse-trace` from the top-level.
This commit is contained in:
parent
ed4e645306
commit
e5998f74ac
|
@ -297,13 +297,12 @@ void run_one_instruction() {
|
|||
uint8_t op=0, op2=0, op3=0;
|
||||
// Run One Instruction
|
||||
if (Dump_trace) {
|
||||
cerr << "registers: ";
|
||||
dump_registers();
|
||||
//? dump_stack(); // for debugging; not defined until later layer
|
||||
// End Dump Info for Instruction
|
||||
}
|
||||
trace(90, "run") << "inst: 0x" << HEXWORD << EIP << end();
|
||||
op = next();
|
||||
if (Dump_trace) cerr << "opcode: " << HEXBYTE << NUM(op) << '\n';
|
||||
trace(90, "run") << "opcode: " << HEXBYTE << NUM(op) << end();
|
||||
switch (op) {
|
||||
case 0xf4: // hlt
|
||||
EIP = End_of_program;
|
||||
|
@ -366,11 +365,14 @@ inline uint8_t next() {
|
|||
}
|
||||
|
||||
void dump_registers() {
|
||||
ostringstream out;
|
||||
out << "registers: ";
|
||||
for (int i = 0; i < NUM_INT_REGISTERS; ++i) {
|
||||
if (i > 0) cerr << "; ";
|
||||
cerr << " " << i << ": " << std::hex << std::setw(8) << std::setfill('_') << Reg[i].u;
|
||||
if (i > 0) out << "; ";
|
||||
out << " " << i << ": " << std::hex << std::setw(8) << std::setfill('_') << Reg[i].u;
|
||||
}
|
||||
cerr << " -- SF: " << SF << "; ZF: " << ZF << "; OF: " << OF << '\n';
|
||||
out << " -- SF: " << SF << "; ZF: " << ZF << "; OF: " << OF;
|
||||
trace(90, "run") << out.str() << end();
|
||||
}
|
||||
|
||||
//: start tracking supported opcodes
|
||||
|
|
|
@ -137,14 +137,17 @@ const int DATA_SEGMENT = 0x0a000000; // keep sync'd with `Heap.limit` in alloca
|
|||
const int STACK_SEGMENT = 0x0b000000;
|
||||
const int AFTER_STACK = 0x0c000000;
|
||||
const int ARGV_DATA_SEGMENT = 0x0c000000;
|
||||
:(before "End Dump Info for Instruction")
|
||||
//? dump_stack(); // slow
|
||||
:(code)
|
||||
void dump_stack() {
|
||||
cerr << "stack:\n";
|
||||
ostringstream out;
|
||||
trace(91, "run") << "stack:" << end();
|
||||
for (uint32_t a = AFTER_STACK-4; a > Reg[ESP].u; a -= 4)
|
||||
cerr << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << '\n';
|
||||
cerr << " 0x" << HEXWORD << Reg[ESP].u << " => 0x" << HEXWORD << read_mem_u32(Reg[ESP].u) << " <=== ESP\n";
|
||||
trace(91, "run") << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << end();
|
||||
trace(91, "run") << " 0x" << HEXWORD << Reg[ESP].u << " => 0x" << HEXWORD << read_mem_u32(Reg[ESP].u) << " <=== ESP" << end();
|
||||
for (uint32_t a = Reg[ESP].u-4; a > Reg[ESP].u-40; a -= 4)
|
||||
cerr << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << '\n';
|
||||
trace(91, "run") << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << end();
|
||||
}
|
||||
|
||||
inline uint32_t u32_in(uint8_t* p) {
|
||||
|
|
Loading…
Reference in New Issue