I thought breakpoint implementation like this (roughly) :
The NOP Placeholder Model
- Create a program with "empty spaces" (nop instructions) where you might want to set breakpoints.
- When you want to set a breakpoint, replace a nop instruction with an interrupt instruction that will stop the program execution.
- When the breakpoint is hit, the program stops.
- Debugger reads the program's information, providing you with details of the execution state.
- If the program continues execution, the instructions after the breakpoint (which was a nop) are executed as normal.
But a true fact looks like this :
The Standard Breakpoint Model (how breakpoints are usually implemented):
- Start with the normal compiled code of the program.
- When a breakpoint is set, the debugger replaces the instruction at that point in the code with an interrupt instruction (INT 3 on x86).
- When the breakpoint is hit, the program execution is interrupted and control is transferred to the debugger.
- The debugger reads the program's state and displays it to the user.
- Before continuing execution, the debugger replaces the interrupt instruction with the original instruction, ensuring the correct program behavior.
Question
If second model is true then, how does debugging in RTOS + jtag be possible?