software breakpoint in gdb

Xin Tong xerox.time.tech@gmail.com
Sun Jan 29 16:48:00 GMT 2012


Hello

I have 2 questions on how software breakpoint is done in gdb.

One of the most commonly used feature is breakpoint. Breakpoint can be
implemented in two ways, hardware breakpoint and software breakpoint.

Hardware breakpoint requires hardware support. Typically, x86
processors come with some debugging register and when a breakpoint is
required, the pc of the instruction is stored into the debug register
and checked whenever an instruction executes.

Software breakpoint, on x86 if no hardware breakpoint register is
supported or the machine runs out of hardware registers. It will fall
back to software breakpoint. Software breakpoint involves replacing
the breakpointed instruction with an interrupt instruction.

What if the interrupt instruction is bigger than breakpointed
instruction ? Where is the breakpointed instruction kept after it is
overwritten by an interrupt instruction in gdb ?


Thanks



More information about the Gdb mailing list