Fix GDB JIT registration on Linux.

pull/13171/head
Joshua Haberman 14 years ago
parent 813bc74be6
commit 6b16e74cdc
  1. 2
      src/upb_decoder.c
  2. 13
      src/upb_decoder_x86.dasc

@ -249,7 +249,7 @@ void upb_decoder_decode(upb_decoder *d, upb_status *status) {
#ifdef UPB_USE_JIT_X64 #ifdef UPB_USE_JIT_X64
void (*upb_jit_decode)(upb_decoder *d) = (void*)d->jit_code; 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) { 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); //fprintf(stderr, "Entering JIT, JIT bytes left: %zd\n", d->jit_end - d->ptr);
upb_jit_decode(d); upb_jit_decode(d);
//fprintf(stderr, "Exiting JIT, parsed %zd bytes\n", d->ptr - before); //fprintf(stderr, "Exiting JIT, parsed %zd bytes\n", d->ptr - before);

@ -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 __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. // Create debug info.
size_t elf_len = src_jit_debug_elf_file_o_len; size_t elf_len = src_jit_debug_elf_file_o_len;
d->debug_info = malloc(elf_len); d->debug_info = malloc(elf_len);
memcpy(d->debug_info, src_jit_debug_elf_file_o, elf_len); memcpy(d->debug_info, src_jit_debug_elf_file_o, elf_len);
uint64_t *p = (void*)d->debug_info; uint64_t *p = (void*)d->debug_info;
for (; (void*)(p+1) <= (void*)d->debug_info + elf_len; ++p) { for (; (void*)(p+1) <= (void*)d->debug_info + elf_len; ++p) {
if (*p == 0x12345678) { *p = (uintptr_t)addr; } if (*p == 0x12345678) { *p = (uintptr_t)d->jit_code; }
if (*p == 0x321) { *p = size; } if (*p == 0x321) { *p = d->jit_size; }
} }
// Register the JIT-ted code with GDB. // 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 #else
void upb_reg_jit_gdb(void *addr, size_t size) { void upb_reg_jit_gdb(upb_decoder *d) {
(void)addr; (void)d
(void)size;
} }
#endif #endif
@ -664,7 +663,7 @@ void upb_decoder_makejit(upb_decoder *d) {
d->jit_code = mmap(NULL, d->jit_size, PROT_READ | PROT_WRITE, d->jit_code = mmap(NULL, d->jit_size, PROT_READ | PROT_WRITE,
MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); 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); dasm_encode(d, d->jit_code);

Loading…
Cancel
Save