software breakpoint in gdb

Kevin Pouget
Mon Jan 30 05:54:00 GMT 2012

On Mon, Jan 30, 2012 at 1:53 AM, Robert Dewar <> wrote:
> On 1/29/2012 11:53 AM, Jan Kratochvil wrote:
>> On Sun, 29 Jan 2012 17:48:30 +0100, Xin Tong wrote:
>>> What if the interrupt instruction is bigger than breakpointed
>>> instruction ?
>> I do not know about such architecture, it probably does not exist.
> It sure would be a disastrous mistake to make in any architectural
> design. the x86 of course has a one byte interrupt instruction
> precisely for this purpose.


I would be curious about why it would be "a disastrous mistake".
Please correct me if I'm wrong in my understanding:
- gdb sets a breakpoint at a given PC, save corresponding instruction,
instructionS or part of instruction,
- when the OS hits the breakpoint, GDB receives a SIGTRAP,
- GDB rewrites the original memory content and moves back the PC to
the BP address
- GDB continues the inferior step-by-step, *until the PCs steps out of
the breakpoint area* -- one step only if not(interrupt instruction is
bigger than breakpointed instruction)
- GDB re-set the breakpoint inst at the BP address, and continues the execution

so, is it doing 2 steps to jump over the breakpoint which is complicated?



More information about the Gdb mailing list