Skip to content

Commit 0f734bc

Browse files
committed
Step debugger in a better way
1 parent d17fc2d commit 0f734bc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/debugger/debugger.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@ extern "C" {
55
}
66

77
std::unordered_map<u64, Breakpoint> breakpoints;
8+
// The debugger was just stepped - we should break on the next instruction
9+
bool break_for_step = false;
810

911
bool check_breakpoint(u64 address) {
10-
bool hit = breakpoints.find(address) != breakpoints.end();
12+
bool hit = breakpoints.find(address) != breakpoints.end() || break_for_step;
1113
if (hit) {
1214
n64sys.debugger_state.broken = true;
13-
if (breakpoints[address].temporary) {
15+
if (breakpoints.find(address) != breakpoints.end() && breakpoints[address].temporary) {
1416
breakpoints.erase(address);
1517
}
18+
break_for_step = false;
1619
}
1720
return hit;
1821
}
1922

2023
void debugger_step() {
21-
// To step once, set a temporary breakpoint at the next PC and unpause
22-
// If a breakpoint already exists at the address, just unpause and we'll hit it.
23-
if (breakpoints.find(N64CPU.next_pc) == breakpoints.end()) {
24-
breakpoints[N64CPU.next_pc] = {N64CPU.next_pc, true};
25-
}
24+
break_for_step = true;
2625
n64sys.debugger_state.broken = false;
2726
}
2827

0 commit comments

Comments
 (0)