debugger enhancements
This commit is contained in:
parent
13d3825d73
commit
f3e234d9d3
2 changed files with 50 additions and 14 deletions
2
cpu.cpp
2
cpu.cpp
|
@ -1336,7 +1336,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
|
||||||
|
|
||||||
set_flags = a != ADDR_PSW;
|
set_flags = a != ADDR_PSW;
|
||||||
|
|
||||||
b -> write(a, false, v, true); // put in '13/12' address space
|
b->write(a, false, v, true); // put in '13/12' address space
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set_flags) {
|
if (set_flags) {
|
||||||
|
|
62
debugger.cpp
62
debugger.cpp
|
@ -120,6 +120,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
{
|
{
|
||||||
int32_t trace_start_addr = -1;
|
int32_t trace_start_addr = -1;
|
||||||
bool tracing = tracing_in;
|
bool tracing = tracing_in;
|
||||||
|
int n_single_step = 1;
|
||||||
|
|
||||||
cpu *const c = b->getCpu();
|
cpu *const c = b->getCpu();
|
||||||
|
|
||||||
|
@ -137,8 +138,14 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
|
|
||||||
if (cmd == "go")
|
if (cmd == "go")
|
||||||
single_step = false;
|
single_step = false;
|
||||||
else if (cmd == "single" || cmd == "s")
|
else if (parts[0] == "single" || parts[0] == "s") {
|
||||||
single_step = true;
|
single_step = true;
|
||||||
|
|
||||||
|
if (parts.size() == 2)
|
||||||
|
n_single_step = atoi(parts[1].c_str());
|
||||||
|
else
|
||||||
|
n_single_step = 1;
|
||||||
|
}
|
||||||
else if ((parts[0] == "sbp" || parts[0] == "cbp") && parts.size() == 2){
|
else if ((parts[0] == "sbp" || parts[0] == "cbp") && parts.size() == 2){
|
||||||
uint16_t pc = std::stoi(parts[1].c_str(), nullptr, 8);
|
uint16_t pc = std::stoi(parts[1].c_str(), nullptr, 8);
|
||||||
|
|
||||||
|
@ -211,21 +218,50 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
continue;
|
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)
|
||||||
cnsl->put_string_lf("parameter missing");
|
cnsl->put_string_lf("parameter missing");
|
||||||
else {
|
else {
|
||||||
int addr = std::stoi(parts[2], nullptr, 8);
|
int addr = std::stoi(parts[2], nullptr, 8);
|
||||||
int val = -1;
|
int val = -1;
|
||||||
|
|
||||||
if (parts[1] == "B" || parts[1] == "b")
|
int n = parts.size() == 4 ? atoi(parts[3].c_str()) : 1;
|
||||||
val = b->read(addr, true, false, true);
|
bool word = parts[1] == "w";
|
||||||
else if (parts[1] == "W" || parts[1] == "w")
|
|
||||||
val = b->read(addr, false, false, true);
|
if (parts[1] != "w" && parts[1] != "b") {
|
||||||
else
|
|
||||||
cnsl->put_string_lf("expected b or w");
|
cnsl->put_string_lf("expected b or w");
|
||||||
|
|
||||||
if (val != -1)
|
continue;
|
||||||
cnsl->put_string_lf(format("value at %06o, octal: %o, hex: %x, dec: %d\n", addr, val, val, val));
|
}
|
||||||
|
|
||||||
|
std::string out;
|
||||||
|
|
||||||
|
for(int i=0; i<n; i++) {
|
||||||
|
if (!word)
|
||||||
|
val = b->read(addr + i, true, false, true);
|
||||||
|
else if (word)
|
||||||
|
val = b->read(addr + i, false, false, true);
|
||||||
|
|
||||||
|
if (val == -1) {
|
||||||
|
cnsl->put_string_lf(format("Can't read from %06o\n", addr + i));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n == 1)
|
||||||
|
cnsl->put_string_lf(format("value at %06o, octal: %o, hex: %x, dec: %d\n", addr + i, val, val, val));
|
||||||
|
|
||||||
|
if (n > 1) {
|
||||||
|
if (i > 0)
|
||||||
|
out += " ";
|
||||||
|
|
||||||
|
if (word)
|
||||||
|
out += format("%06o", val);
|
||||||
|
else
|
||||||
|
out += format("%03o", val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n > 1)
|
||||||
|
cnsl->put_string_lf(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -252,7 +288,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
#if !defined(ESP32)
|
#if !defined(ESP32)
|
||||||
cnsl->put_string_lf("quit/q - stop emulator");
|
cnsl->put_string_lf("quit/q - stop emulator");
|
||||||
#endif
|
#endif
|
||||||
cnsl->put_string_lf("examine/e - show memory address (<b|w> <octal address>)");
|
cnsl->put_string_lf("examine/e - show memory address (<b|w> <octal address> [<n>])");
|
||||||
cnsl->put_string_lf("reset/r - reset cpu/bus/etc");
|
cnsl->put_string_lf("reset/r - reset cpu/bus/etc");
|
||||||
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)");
|
||||||
|
@ -287,7 +323,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
|
|
||||||
c->step_b();
|
c->step_b();
|
||||||
|
|
||||||
if (single_step)
|
if (single_step && --n_single_step == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue