This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: gdb breakpoint on x86
On Mon, 2006-10-16 at 09:15 +0800, s88 wrote:
> > > 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.
> >
> Thank gor your reply...
>
> I have a new question, how to remove the memory protection? I'm trying
> to find out this part in gdb, but I do not find anything!!
On Linux, GDB uses the ptrace(2) API to get access to another process'
address space. This API allows a debugger process to modify the memory
of another (debuggee) process.
Looking at your segmentation fault issue, it's not a breakpoint issue,
it's a simple C issue AFAICT. You do:
int *len=0;
b = (my_byte *)i386_breakpoint_from_pc ((CORE_ADDR *)(t), len);
and in i386_breakpoint_from_pc:
*len = sizeof (break_insn);
which is *0 = sizeof (break_insn);
That's also a memory protection error, but not due to editing executable
memory pages, it's simply a NULL pointer dereference.
Fred.