2012-01-17 Pedro Alves <palves@redhat.com>
* tracepoint.c (initialize_tracepoint): Use mmap instead of memalign plus mprotect to allocate the scratch buffer.
This commit is contained in:
parent
c0bf857deb
commit
fc1ab1a0ff
2 changed files with 25 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2012-01-17 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* tracepoint.c (initialize_tracepoint): Use mmap instead of
|
||||||
|
memalign plus mprotect to allocate the scratch buffer.
|
||||||
|
|
||||||
2012-01-13 Pedro Alves <palves@redhat.com>
|
2012-01-13 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* server.c (attach_inferior): Clear `cont_thread'.
|
* server.c (attach_inferior): Clear `cont_thread'.
|
||||||
|
|
|
@ -8251,23 +8251,35 @@ initialize_tracepoint (void)
|
||||||
|
|
||||||
#ifdef IN_PROCESS_AGENT
|
#ifdef IN_PROCESS_AGENT
|
||||||
{
|
{
|
||||||
|
uintptr_t addr;
|
||||||
int pagesize;
|
int pagesize;
|
||||||
|
|
||||||
pagesize = sysconf (_SC_PAGE_SIZE);
|
pagesize = sysconf (_SC_PAGE_SIZE);
|
||||||
if (pagesize == -1)
|
if (pagesize == -1)
|
||||||
fatal ("sysconf");
|
fatal ("sysconf");
|
||||||
|
|
||||||
gdb_tp_heap_buffer = xmalloc (5 * 1024 * 1024);
|
gdb_tp_heap_buffer = xmalloc (5 * 1024 * 1024);
|
||||||
|
|
||||||
/* Allocate scratch buffer aligned on a page boundary. */
|
#define SCRATCH_BUFFER_NPAGES 20
|
||||||
gdb_jump_pad_buffer = memalign (pagesize, pagesize * 20);
|
|
||||||
gdb_jump_pad_buffer_end = gdb_jump_pad_buffer + pagesize * 20;
|
|
||||||
|
|
||||||
/* Make it writable and executable. */
|
/* Allocate scratch buffer aligned on a page boundary, at a low
|
||||||
if (mprotect (gdb_jump_pad_buffer, pagesize * 20,
|
address (close to the main executable's code). */
|
||||||
PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
|
for (addr = pagesize; addr != 0; addr += pagesize)
|
||||||
|
{
|
||||||
|
gdb_jump_pad_buffer = mmap ((void *) addr, pagesize * SCRATCH_BUFFER_NPAGES,
|
||||||
|
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
|
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
|
||||||
|
-1, 0);
|
||||||
|
if (gdb_jump_pad_buffer != MAP_FAILED)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr == 0)
|
||||||
fatal ("\
|
fatal ("\
|
||||||
initialize_tracepoint: mprotect(%p, %d, PROT_READ|PROT_EXEC) failed with %s",
|
initialize_tracepoint: mmap'ing jump pad buffer failed with %s",
|
||||||
gdb_jump_pad_buffer, pagesize * 20, strerror (errno));
|
strerror (errno));
|
||||||
|
|
||||||
|
gdb_jump_pad_buffer_end = gdb_jump_pad_buffer + pagesize * SCRATCH_BUFFER_NPAGES;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_trampoline_buffer = gdb_trampoline_buffer_end = 0;
|
gdb_trampoline_buffer = gdb_trampoline_buffer_end = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue