Breakpoints
Breakpoints allow a user to specify a point in a program where execution should pause. This allows the user to inspect registers, memory, and generial program state.
Breakpoints need hardware support to work correctly. The basics steps are:
- Replace instruction with break/trap instruction (backup original instruction)
- Exception handler will be entered
- The user can inspect the program at this point
- When resumed, put the original instruction back
- Restart execution at the original instruction
- Somehow, restore the breakpoint
- Some processesors can step one instruction
- Otherwise, put a new breakpoint at the 'next' instruction
- Once inside the exception handler, put original instruction back
- Do any cleanup needed to fix restore breakpoint