diff options
author | Pekka Enberg <penberg@kernel.org> | 2012-01-11 18:08:35 +0200 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2012-01-11 19:47:12 +0200 |
commit | 64029fed3b2288c16dafca17bd47b4b265e15533 (patch) | |
tree | 639b0499c3478c940f9c81b0e91c73b02a9d5187 | |
parent | 538f5538762ce0cd38ac8e5c43216e7363cc9d1b (diff) | |
download | jato-64029fed3b2288c16dafca17bd47b4b265e15533.tar.gz |
x86: Show function names in disassembly output
Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r-- | arch/x86/disassemble.c | 41 | ||||
-rw-r--r-- | arch/x86/include/arch/decode.h | 24 | ||||
-rw-r--r-- | arch/x86/include/arch/encode.h | 3 | ||||
-rw-r--r-- | arch/x86/include/arch/isa.h | 7 | ||||
-rw-r--r-- | arch/x86/inline-cache.c | 3 |
5 files changed, 69 insertions, 9 deletions
diff --git a/arch/x86/disassemble.c b/arch/x86/disassemble.c index d01a0499..d5d618c1 100644 --- a/arch/x86/disassemble.c +++ b/arch/x86/disassemble.c @@ -31,11 +31,19 @@ */ -#include "jit/bc-offset-mapping.h" #include "jit/disassemble.h" + +#include "jit/bc-offset-mapping.h" +#include "jit/cu-mapping.h" #include "jit/compiler.h" +#include "jit/text.h" #include "lib/string.h" +#include "arch/decode.h" + +#include "vm/backtrace.h" +#include "vm/method.h" +#include "vm/class.h" #include "vm/trace.h" #include <assert.h> @@ -106,17 +114,40 @@ static unsigned char *disassemble_insn(struct compilation_unit *cu, unsigned cha seqlen = print_insn_i386((bfd_vma) (unsigned long) code, &info); - for (i = 0; i < seqlen; i++, code++) { - trace_printf("%02x ", *code); + for (i = 0; i < seqlen; i++) { + trace_printf("%02x ", code[i]); } for (; i < 8; i++) { trace_printf(" "); } - trace_printf(" %s\n", disass_buf); + trace_printf(" %s", disass_buf); + + if (x86_is_call(code)) { + unsigned long addr = x86_call_target(code); + + trace_printf("%8s ", "#"); + + if (is_jit_text((void *) addr)) { + struct compilation_unit *target_cu; + + target_cu = jit_lookup_cu(addr); + if (target_cu) { + struct vm_method *vmm = target_cu->method; + + trace_printf("%s.%s%s", vmm->class->name, vmm->name, vmm->type); + } else { + trace_printf("<unknown>\n"); + } + } else { + show_function((void *) addr); + } + } + + trace_printf("\n"); - return code; + return code + seqlen; } void disassemble(struct vm_method *vmm) diff --git a/arch/x86/include/arch/decode.h b/arch/x86/include/arch/decode.h new file mode 100644 index 00000000..bed78bf5 --- /dev/null +++ b/arch/x86/include/arch/decode.h @@ -0,0 +1,24 @@ +#ifndef X86_DECODE_H +#define X86_DECODE_H + +#include "arch/isa.h" + +#include <stdbool.h> +#include <stdint.h> + +static inline bool x86_is_call(unsigned char *insn) +{ + return *insn == 0xe8; +} + +static inline unsigned long x86_call_target(unsigned char *insn) +{ + unsigned long start = (unsigned long) insn; + int32_t relative; + + relative = (uint32_t) insn[1] | (uint32_t) insn[2] << 8 | (uint32_t) insn[3] << 16 | (uint32_t) insn[4] << 24; + + return start + relative + X86_CALL_INSN_SIZE; +} + +#endif /* X86_DECODE_H */ diff --git a/arch/x86/include/arch/encode.h b/arch/x86/include/arch/encode.h index 2204b7c4..0a49efe7 100644 --- a/arch/x86/include/arch/encode.h +++ b/arch/x86/include/arch/encode.h @@ -2,6 +2,7 @@ #define X86_ENCODE_H #include "arch/registers.h" /* for enum machine_reg */ +#include "arch/isa.h" #include <stdint.h> @@ -9,8 +10,6 @@ struct basic_block; struct buffer; struct insn; -#define X86_CALL_INSN_SIZE 5 - #define REX 0x40 #define REX_W (REX | 8) /* 64-bit operands */ #define REX_R (REX | 4) /* ModRM reg extension */ diff --git a/arch/x86/include/arch/isa.h b/arch/x86/include/arch/isa.h new file mode 100644 index 00000000..a656503c --- /dev/null +++ b/arch/x86/include/arch/isa.h @@ -0,0 +1,7 @@ +#ifndef JATO_X86_ISA_H +#define JATO_X86_ISA_H + +#define X86_CALL_INSN_SIZE 5 +#define X86_CALL_OPC 0xe8 + +#endif /* JATO_X86_ISA_H */ diff --git a/arch/x86/inline-cache.c b/arch/x86/inline-cache.c index 48ca5d70..69869145 100644 --- a/arch/x86/inline-cache.c +++ b/arch/x86/inline-cache.c @@ -1,5 +1,6 @@ #include "arch/inline-cache.h" #include "arch/instruction.h" +#include "arch/isa.h" #include "vm/method.h" #include "vm/class.h" @@ -16,11 +17,9 @@ #include <stdbool.h> #include <pthread.h> -#define X86_CALL_INSN_SIZE 5 #define X86_CALL_DISP_OFFSET 1 #define X86_MOV_IMM_REG_INSN_SIZE 5 #define X86_MOV_IMM_REG_IMM_OFFSET 1 -#define X86_CALL_OPC 0xe8 #define X86_MOV_EAX_OPC 0xb8 struct x86_ic { |