Re: gdb breakpoint on x86

Jean-Marc Saffroy
2006-10-16T14:42:52Z

On Mon, 16 Oct 2006, s88 wrote:

> 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!!

Use mprotect to change your own mappings:

char *p = target;

p -= (unsigned long)p % PAGE_SIZE;
if(mprotect(p, PAGE_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC)) {
perror("mprotect");
exit(1);
}

> let's see the default_memory_insert_breakpoint (CORE_ADDR addr,
> bfd_byte *contents_cache) in the mem-break.c
> first, the program "determine appropriate breakpoint contents and size
> for this address".
> I don't know, the sizeof the int3 is 1 byte, right? why need to detect
> the "appropriate" breakpoint size?

This size is architecture-specific, people use gdb on other CPU
architectures as well. Look at i386_breakpoint_from_pc or
ia64_breakpoint_from_pc for wildly different sizes (1 byte vs. 8 bytes).

--
saffroy@gmail.com