From 6b16e74cdcf1203b8c1622b1a77739078dae886a Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Thu, 14 Apr 2011 09:55:14 -0700 Subject: Fix GDB JIT registration on Linux. --- src/upb_decoder.c | 2 +- src/upb_decoder_x86.dasc | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/upb_decoder.c b/src/upb_decoder.c index 9ae3659..0ce18e7 100644 --- a/src/upb_decoder.c +++ b/src/upb_decoder.c @@ -249,7 +249,7 @@ void upb_decoder_decode(upb_decoder *d, upb_status *status) { #ifdef UPB_USE_JIT_X64 void (*upb_jit_decode)(upb_decoder *d) = (void*)d->jit_code; if (d->jit_code && d->dispatcher.top == d->dispatcher.stack && d->ptr < d->jit_end) { - const char *before = d->ptr; + //const char *before = d->ptr; //fprintf(stderr, "Entering JIT, JIT bytes left: %zd\n", d->jit_end - d->ptr); upb_jit_decode(d); //fprintf(stderr, "Exiting JIT, parsed %zd bytes\n", d->ptr - before); diff --git a/src/upb_decoder_x86.dasc b/src/upb_decoder_x86.dasc index fac0dcf..f56b9f8 100644 --- a/src/upb_decoder_x86.dasc +++ b/src/upb_decoder_x86.dasc @@ -67,15 +67,15 @@ gdb_jit_descriptor __jit_debug_descriptor = {1, GDB_JIT_NOACTION, NULL, NULL}; void __attribute__((noinline)) __jit_debug_register_code() { __asm__ __volatile__(""); } -void upb_reg_jit_gdb(upb_decoder *d, void *addr, size_t size) { +void upb_reg_jit_gdb(upb_decoder *d) { // Create debug info. size_t elf_len = src_jit_debug_elf_file_o_len; d->debug_info = malloc(elf_len); memcpy(d->debug_info, src_jit_debug_elf_file_o, elf_len); uint64_t *p = (void*)d->debug_info; for (; (void*)(p+1) <= (void*)d->debug_info + elf_len; ++p) { - if (*p == 0x12345678) { *p = (uintptr_t)addr; } - if (*p == 0x321) { *p = size; } + if (*p == 0x12345678) { *p = (uintptr_t)d->jit_code; } + if (*p == 0x321) { *p = d->jit_size; } } // Register the JIT-ted code with GDB. @@ -93,9 +93,8 @@ void upb_reg_jit_gdb(upb_decoder *d, void *addr, size_t size) { #else -void upb_reg_jit_gdb(void *addr, size_t size) { - (void)addr; - (void)size; +void upb_reg_jit_gdb(upb_decoder *d) { + (void)d } #endif @@ -664,7 +663,7 @@ void upb_decoder_makejit(upb_decoder *d) { d->jit_code = mmap(NULL, d->jit_size, PROT_READ | PROT_WRITE, MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); - upb_reg_jit_gdb(d->jit_code, d->jit_size); + upb_reg_jit_gdb(d); dasm_encode(d, d->jit_code); -- cgit v1.2.3