summaryrefslogtreecommitdiff
path: root/upb
diff options
context:
space:
mode:
Diffstat (limited to 'upb')
-rw-r--r--upb/bindings/lua/upb.c1
-rw-r--r--upb/bindings/ruby/extconf.rb4
-rw-r--r--upb/pb/compile_decoder_x64.c83
-rw-r--r--upb/pb/jit_debug_elf_file.s6
4 files changed, 4 insertions, 90 deletions
diff --git a/upb/bindings/lua/upb.c b/upb/bindings/lua/upb.c
index dbeb937..f938b26 100644
--- a/upb/bindings/lua/upb.c
+++ b/upb/bindings/lua/upb.c
@@ -1622,6 +1622,7 @@ static void lupb_sethasbit(lupb_msg *msg, uint32_t hasbit) {
static size_t strhandler(void *closure, const void *hd, const char *str,
size_t len, const upb_bufhandle *handle) {
+ UPB_UNUSED(handle);
lupb_msg *msg = closure;
const lupb_handlerdata *data = hd;
lua_State *L = msg->lmd->L;
diff --git a/upb/bindings/ruby/extconf.rb b/upb/bindings/ruby/extconf.rb
index 67fddba..3637511 100644
--- a/upb/bindings/ruby/extconf.rb
+++ b/upb/bindings/ruby/extconf.rb
@@ -2,6 +2,8 @@
require 'mkmf'
find_header("upb/upb.h", "../../..") or raise "Can't find upb headers"
-find_library("upb_pic", "upb_msgdef_new", "../..") or raise "Can't find upb lib"
+find_library("upb_pic", "upb_msgdef_new", "../../../lib") or raise "Can't find upb lib"
+find_library("upb.pb_pic", "upb_decoder_init", "../../../lib") or raise "Can't find upb.pb lib"
+find_library("upb.descriptor_pic", "upb_descreader_init", "../../../lib") or raise "Can't find upb.descriptor lib"
$CFLAGS += " -Wall"
create_makefile("upb")
diff --git a/upb/pb/compile_decoder_x64.c b/upb/pb/compile_decoder_x64.c
index 1d8b861..d8af013 100644
--- a/upb/pb/compile_decoder_x64.c
+++ b/upb/pb/compile_decoder_x64.c
@@ -259,8 +259,6 @@ static int pcofs(jitcompiler *jc) {
return jc->pc - jc->group->bytecode;
}
-static void upb_reg_jit_gdb(jitcompiler *jc);
-
// Returns a machine code offset corresponding to the given key.
// Requires that this key was defined with define_jmptarget.
static int machine_code_ofs(jitcompiler *jc, const void *key) {
@@ -470,7 +468,6 @@ void upb_pbdecoder_jit(mgroup *group) {
MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
dasm_encode(jc, jit_code);
mprotect(jit_code, jc->group->jit_size, PROT_EXEC | PROT_READ);
- upb_reg_jit_gdb(jc);
jc->group->jit_code = (upb_string_handlerfunc *)jit_code;
#ifdef UPB_JIT_LOAD_SO
@@ -496,84 +493,4 @@ void upb_pbdecoder_freejit(mgroup *group) {
munmap(group->jit_code, group->jit_size);
}
free(group->debug_info);
- // TODO: unregister GDB JIT interface.
-}
-
-// To debug JIT-ted code with GDB we need to tell GDB about the JIT-ted code
-// at runtime. GDB 7.x+ has defined an interface for doing this, and these
-// structure/function defintions are copied out of gdb/jit.h
-//
-// We need to give GDB an ELF file at runtime describing the symbols we have
-// generated. To avoid implementing the ELF format, we generate an ELF file
-// at compile-time and compile it in as a character string. We can replace
-// a few key constants (address of JIT-ted function and its size) by looking
-// for a few magic numbers and doing a dumb string replacement.
-//
-// Unfortunately this approach is showing its limits; we can only define one
-// symbol, and this approach only works with GDB. The .so approach above is
-// more reliable.
-
-#ifndef __APPLE__
-const unsigned char upb_jit_debug_elf_file[] = {
-#include "upb/pb/jit_debug_elf_file.h"
-};
-
-typedef enum {
- GDB_JIT_NOACTION = 0,
- GDB_JIT_REGISTER,
- GDB_JIT_UNREGISTER
-} jit_actions_t;
-
-typedef struct gdb_jit_entry {
- struct gdb_jit_entry *next_entry;
- struct gdb_jit_entry *prev_entry;
- const char *symfile_addr;
- uint64_t symfile_size;
-} gdb_jit_entry;
-
-typedef struct {
- uint32_t version;
- uint32_t action_flag;
- gdb_jit_entry *relevant_entry;
- gdb_jit_entry *first_entry;
-} gdb_jit_descriptor;
-
-gdb_jit_descriptor __jit_debug_descriptor = {1, GDB_JIT_NOACTION, NULL, NULL};
-
-void __attribute__((noinline)) __jit_debug_register_code() {
- __asm__ __volatile__("");
}
-
-static void upb_reg_jit_gdb(jitcompiler *jc) {
- // Create debug info.
- size_t elf_len = sizeof(upb_jit_debug_elf_file);
- jc->group->debug_info = malloc(elf_len);
- memcpy(jc->group->debug_info, upb_jit_debug_elf_file, elf_len);
- uint64_t *p = (void *)jc->group->debug_info;
- for (; (void *)(p + 1) <= (void *)jc->group->debug_info + elf_len; ++p) {
- if (*p == 0x12345678) {
- *p = (uintptr_t)jc->group->jit_code;
- }
- if (*p == 0x321) {
- *p = jc->group->jit_size;
- }
- }
-
- // Register the JIT-ted code with GDB.
- gdb_jit_entry *e = malloc(sizeof(gdb_jit_entry));
- e->next_entry = __jit_debug_descriptor.first_entry;
- e->prev_entry = NULL;
- if (e->next_entry) e->next_entry->prev_entry = e;
- e->symfile_addr = jc->group->debug_info;
- e->symfile_size = elf_len;
- __jit_debug_descriptor.first_entry = e;
- __jit_debug_descriptor.relevant_entry = e;
- __jit_debug_descriptor.action_flag = GDB_JIT_REGISTER;
- __jit_debug_register_code();
-}
-
-#else
-
-static void upb_reg_jit_gdb(jitcompiler *jc) { (void)jc; }
-
-#endif
diff --git a/upb/pb/jit_debug_elf_file.s b/upb/pb/jit_debug_elf_file.s
deleted file mode 100644
index 2c3d6fb..0000000
--- a/upb/pb/jit_debug_elf_file.s
+++ /dev/null
@@ -1,6 +0,0 @@
- .file "JIT mcode"
- .text
-upb_jit_compiled_decoder:
- .globl upb_jit_compiled_decoder
- .size upb_jit_compiled_decoder, 0x321
- .space 0x321
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback