Skip to contentSkip to conversation

Use the GDB JIT interface

PATCH New Richard Henderson 1 participant 2 messages Mar 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Use the GDB JIT interface

Changes v2->v3:
* Generate a .debug_info section.
* Statically initialize most of the elf file.

This fixes the ?? case Peter Maydell found with the softmmu binaries:

#0 helper_set_cp15 (env=0x555556439770, insn=3993440154, val=0)

    at /home/rth/work/qemu/qemu/target-arm/helper.c:1455
#1  0x000000004000118c in code_gen_buffer ()
#2  0x0000555555707632 in cpu_arm_exec (env=0x555556439770)
    at /home/rth/work/qemu/qemu/cpu-exec.c:564
#3  0x0000555555708c3c in tcg_cpu_exec (env=0x555556439770)
    at /home/rth/work/qemu/qemu/cpus.c:1022
#4  tcg_exec_all () at /home/rth/work/qemu/qemu/cpus.c:1054
#5  qemu_tcg_cpu_thread_fn (arg=<optimized out>)
    at /home/rth/work/qemu/qemu/cpus.c:772
#6  0x00007ffff5b9ed90 in start_thread (arg=0x7fffec4a1700)
    at pthread_create.c:309
#7  0x00007ffff49f8f5d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

r~

Richard Henderson (1):
tcg: Use the GDB JIT debugging interface.

 elf.h                 |    1 +
 exec.c                |    1 +
 tcg/i386/tcg-target.c |  114 +++++++++++++++++++--
 tcg/tcg.c             |  277 +++++++++++++++++++++++++++++++++++++++++++++++++
 tcg/tcg.h             |    2 +
 5 files changed, 386 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 1/1 tcg: Use the GDB JIT debugging interface.

This allows us to generate unwind info for the dynamicly generated code in the code_gen_buffer. Only i386 is converted at this point.

---
 elf.h                 |    1 +
 exec.c                |    1 +
 tcg/i386/tcg-target.c |  114 +++++++++++++++++++--
 tcg/tcg.c             |  277 +++++++++++++++++++++++++++++++++++++++++++++++++
 tcg/tcg.h             |    2 +
 5 files changed, 386 insertions(+), 9 deletions(-)
elf.h +1 -0
index 2e05d34..310e05a 100644
@@ -216,6 +216,7 @@ typedef int64_t  Elf64_Sxword;
 
 #define ELF_ST_BIND(x)		((x) >> 4)
 #define ELF_ST_TYPE(x)		(((unsigned int) x) & 0xf)
+#define ELF_ST_INFO(bind, type) (((bind) << 4) | ((type) & 0xf))
 #define ELF32_ST_BIND(x)	ELF_ST_BIND(x)
 #define ELF32_ST_TYPE(x)	ELF_ST_TYPE(x)
 #define ELF64_ST_BIND(x)	ELF_ST_BIND(x)
exec.c +1 -0
index be392e2..dd24939 100644
@@ -636,6 +636,7 @@ void tcg_exec_init(unsigned long tb_size)
     cpu_gen_init();
     code_gen_alloc(tb_size);
     code_gen_ptr = code_gen_buffer;
+    tcg_register_jit(code_gen_buffer, code_gen_buffer_size);
     page_init();
 #if !defined(CONFIG_USER_ONLY) || !defined(CONFIG_USE_GUEST_BASE)
     /* There's no guest base to take into account, so go ahead and
tcg/i386/tcg-target.c +105 -9

130 lines not on this page · raw message

tcg/tcg.c +277 -0

298 lines not on this page · raw message

tcg/tcg.h +2 -0
index 5f6c647..a83bddd 100644
@@ -586,3 +586,5 @@ extern uint8_t code_gen_prologue[];
 # define tcg_qemu_tb_exec(env, tb_ptr) \
     ((tcg_target_ulong (*)(void *, void *))code_gen_prologue)(env, tb_ptr)
 #endif
+
+void tcg_register_jit(void *buf, size_t buf_size);
Signature · 1 line
1.7.7.6