From 23a87309e34e3ed7550ca6566cff5704212732a2 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Thu, 9 Jun 2022 08:47:54 +0200 Subject: [PATCH] strace -> start tracing from address --- debugger.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/debugger.cpp b/debugger.cpp index 524b7a2..0295382 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -74,7 +74,8 @@ std::map split(const std::vector & kv_arr void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interrupt_emulation, const bool tracing_in) { - bool tracing = tracing_in; + int32_t trace_start_addr = -1; + bool tracing = tracing_in; cpu *const c = b->getCpu(); @@ -144,6 +145,22 @@ void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interru tracing = !tracing; 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") { 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("sbp/cbp/lbp - set/clear/list breakpoint(s)"); cnsl->put_string_lf("trace/t - toggle tracing"); + cnsl->put_string_lf("strace - start tracing from address - invoke without address to disable"); continue; } @@ -207,6 +225,9 @@ void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interru while(!event && !*interrupt_emulation) { c->step_a(); + if (trace_start_addr != -1 && c->getPC() == trace_start_addr) + tracing = true; + if (tracing || single_step) disassemble(c, single_step ? cnsl : nullptr, c->getPC(), false);