strace -> start tracing from address

This commit is contained in:
folkert van heusden 2022-06-09 08:47:54 +02:00
parent 73be8514ba
commit 23a87309e3

View file

@ -74,6 +74,7 @@ std::map<std::string, std::string> split(const std::vector<std::string> & kv_arr
void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interrupt_emulation, const bool tracing_in) void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interrupt_emulation, const bool tracing_in)
{ {
int32_t trace_start_addr = -1;
bool tracing = tracing_in; bool tracing = tracing_in;
cpu *const c = b->getCpu(); cpu *const c = b->getCpu();
@ -144,6 +145,22 @@ void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interru
tracing = !tracing; tracing = !tracing;
cnsl->put_string_lf(format("Tracing set to %s", tracing ? "ON" : "OFF")); cnsl->put_string_lf(format("Tracing set to %s", tracing ? "ON" : "OFF"));
continue;
}
else if (parts[0] == "strace") {
if (parts.size() != 2) {
trace_start_addr = -1;
cnsl->put_string_lf("Tracing start address reset");
}
else {
trace_start_addr = std::stoi(parts[1], nullptr, 8);
cnsl->put_string_lf(format("Tracing start address set to %06o", trace_start_addr));
}
continue;
} }
else if (parts[0] == "examine" || parts[0] == "e") { else if (parts[0] == "examine" || parts[0] == "e") {
if (parts.size() != 3) if (parts.size() != 3)
@ -192,6 +209,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interru
cnsl->put_string_lf("single/s - run 1 instruction (implicit 'disassemble' command)"); cnsl->put_string_lf("single/s - run 1 instruction (implicit 'disassemble' command)");
cnsl->put_string_lf("sbp/cbp/lbp - set/clear/list breakpoint(s)"); cnsl->put_string_lf("sbp/cbp/lbp - set/clear/list breakpoint(s)");
cnsl->put_string_lf("trace/t - toggle tracing"); cnsl->put_string_lf("trace/t - toggle tracing");
cnsl->put_string_lf("strace - start tracing from address - invoke without address to disable");
continue; continue;
} }
@ -207,6 +225,9 @@ void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interru
while(!event && !*interrupt_emulation) { while(!event && !*interrupt_emulation) {
c->step_a(); c->step_a();
if (trace_start_addr != -1 && c->getPC() == trace_start_addr)
tracing = true;
if (tracing || single_step) if (tracing || single_step)
disassemble(c, single_step ? cnsl : nullptr, c->getPC(), false); disassemble(c, single_step ? cnsl : nullptr, c->getPC(), false);