schierlm/Oberon2013Modifications

DebugServer.DefaultBreakpointHandler

Closed this issue · 2 comments

When ‘rbp’ is used, does it not override ‘sbp’ set for stepping, leaving the latter marked as ‘used’, but not actually “armed” via a branch to its trampoline, since that branch was overwritten for ‘rbp’?

I cannot really follow your argument here, sorry.

I assume you are talking about the scenario when your code is stopped at a real breakpoint at address X and you "step into" without disabling the breakpoint. For simplicity I assume that the instruction at address X is not a jump instruction, but the same argument holds if it is a jump instruction.

This is what should happen:

  • StepInto will create a step breakpoint at X+4 and enable it, storing the real instruction in the step breakpoint's pcValue field.
  • End of DefaultBreakpointHandler will detect that breakpoint at X is still active, temporarily disabling it (restoring real instruction at X), and adding a restore breakpoint at X+4 as well. The branch to sbp's trampoline is stored in the restore breakpoint's pcValue field.
  • The real instruction at address X gets executed
  • The restore breakpoint at address X+4 gets executed, restoring the trampoline to the step breakpoint at X+4 and re-enabling the breakpoint at X
  • The step breakpoint at address X+4 gets executed, restoring the original instruction for X+4 and returning into the default breakpoint handler so you can continue stepping

Now both temporary breakpoints (rbp and sbp) are unused again, and the memory contents is the same as before issuing the "step into" command. The only change is that the instruction at address X got executed and the program counter has advanced.

If you experience any other behaviour, it is a bug and should get fixed.

Feel free to ask if anything is unclear, or to close the issue when it is clarified now.

Thank you for your detailed explanations. Which resulted in me slapping my forehead: of course! “Breakpoint chaining”. :)