Open mooskagh opened 3 years ago
Right, on_set_pc()
does not look to be the best handler to catch breakpoints. And I have doubts about on_fetch_cycle()
and even on_m1_fetch_cycle()
. on_step()
maybe?
But it won't stop at 40150 anyway, if you set a breakpoint at that address. The general approach is that for a breakpoint or watchpoint to be hit, the instruction has to be actually executed. It's the debugger's job to then figure out which breakpoint it is.
In the end I did it in run(), in other places it had issues (especially given that I need to breakpoint before the instruction, like other libs do):
void Machine::run(uint64_t max_ops) {
for (uint64_t op = 0; op < max_ops; ++op) {
events_ = 0;
on_step();
if (events_ & kEventInterrupt) {
++interrupts;
on_handle_active_int();
}
if (breakpoints_[get_pc()]) events_ |= kEventBreakpoint;
if (event_mask_ & events_) break;
}
}
Yep, this should do. We couldn't do the same for watchpoints and other kinds of breakpoints, however, so we still might want to give this all a proper thought...
Possibly that's bug on my side, I'll look into it from my side further.
So, I'm trying to implement breakpoints, in a way similar to one in
z80.h
.What I do:
Now I have the following code:
When I do:
I expect it to stop at 40150, but instead 41055 is output.