Re: gdb breakpoint on x86

Daniel Jacobowitz
2006-10-16T00:39:35Z

On Mon, Oct 16, 2006 at 08:12:29AM +0800, s88 wrote:
> Hi all:
> I'm trying to build up a simple breakpoint insertor by myself. I also
> tracing the gdb source code and reference it!!!
> But I feel confused about the int 3(0xcc), the function
> "i386_breakpoint_from_pc" has 2 parameters, one of the parameter is a
> program counter. I'm not sure the meaning of this program counter.
> Does this program counter perform an ISR? Once the 0xcc trig, the
> current program counter will replace by this one?

No, it's the address at which the breakpoint will be placed. On i386
that doesn't matter, but on some other platforms it can affect which
instruction is used as a breakpoint.

> By the way, the following code can compile without any error. But the
> sizeof which in the "i386_breakpoint_from_pc" derives segmentation
> fault.

You need to read up on memory protection. You can't modify a running
program directly this way on most platforms.

--
Daniel Jacobowitz
CodeSourcery