Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- include/jit/compiler.h | 2 +- jit/exception.c | 2 +- jit/trace-jit.c | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/include/jit/compiler.h b/include/jit/compiler.h index 4613615..10e3118 100644 --- a/include/jit/compiler.h +++ b/include/jit/compiler.h @@ -112,7 +112,7 @@ void trace_regalloc(struct compilation_unit *); void trace_machine_code(struct compilation_unit *); void trace_invoke(struct compilation_unit *); void trace_exception(struct compilation_unit *, struct jit_stack_frame *, unsigned char *); -void trace_exception_handler(unsigned char *); +void trace_exception_handler(struct compilation_unit *, unsigned char *); void trace_exception_unwind(struct jit_stack_frame *); void trace_exception_unwind_to_native(struct jit_stack_frame *); void trace_bytecode(struct vm_method *); diff --git a/jit/exception.c b/jit/exception.c index 641a7f8..251bd17 100644 --- a/jit/exception.c +++ b/jit/exception.c @@ -258,7 +258,7 @@ throw_exception_from(struct compilation_unit *cu, struct jit_stack_frame *frame, signal_exception(exception); if (opt_trace_exceptions) - trace_exception_handler(eh_ptr); + trace_exception_handler(cu, eh_ptr); return eh_ptr; } diff --git a/jit/trace-jit.c b/jit/trace-jit.c index 765d854..2ea9c13 100644 --- a/jit/trace-jit.c +++ b/jit/trace-jit.c @@ -351,9 +351,28 @@ static void trace_invoke_args(struct vm_method *vmm, } } +static void print_source_and_line(struct compilation_unit *cu, + unsigned char *ptr) +{ + unsigned long pc; + const char *source_file; + + source_file = cu->method->class->source_file_name; + if (source_file) + printf("%s", source_file); + else + printf("UNKNOWN"); + + pc = native_ptr_to_bytecode_offset(cu, ptr); + if (pc == BC_OFFSET_UNKNOWN) + return; + + printf(":%d", bytecode_offset_to_line_no(cu->method, pc)); +} + static void trace_return_address(struct jit_stack_frame *frame) { - printf("\tret\t: %p", (void*)frame->return_address); + printf("\tret\t: %p:", (void*)frame->return_address); if (is_native(frame->return_address)) { printf(" (native)\n"); @@ -371,11 +390,13 @@ static void trace_return_address(struct jit_stack_frame *frame) vmm = cu->method;; vmc = vmm->class; - printf(" (%s.%s%s)\n", vmc->name, vmm->name, vmm->type ); + printf(" %s.%s%s\n", vmc->name, vmm->name, vmm->type ); + printf("\t\t ("); + print_source_and_line(cu, (void *) frame->return_address); + printf(")\n"); } } - void trace_invoke(struct compilation_unit *cu) { struct vm_method *vmm = cu->method; @@ -411,13 +432,20 @@ void trace_exception(struct compilation_unit *cu, struct jit_stack_frame *frame, printf("trace exception: exception object %p (%s) thrown\n", exception, exception->class->name); - printf("\tfrom\t: %p (%s.%s%s)\n", native_ptr, vmc->name, vmm->name, + printf("\tfrom\t: %p: %s.%s%s\n", native_ptr, vmc->name, vmm->name, vmm->type); + printf("\t\t ("); + print_source_and_line(cu, native_ptr); + printf(")\n"); } -void trace_exception_handler(unsigned char *ptr) +void trace_exception_handler(struct compilation_unit *cu, + unsigned char *ptr) { printf("\taction\t: jump to handler at %p\n", ptr); + printf("\t\t ("); + print_source_and_line(cu, ptr); + printf(")\n"); } void trace_exception_unwind(struct jit_stack_frame *frame) @@ -431,8 +459,11 @@ void trace_exception_unwind(struct jit_stack_frame *frame) vmm = cu->method; vmc = vmm->class; - printf("\taction\t: unwind to %p (%s.%s%s)\n", + printf("\taction\t: unwind to %p: %s.%s%s\n", (void*)frame->return_address, vmc->name, vmm->name, vmm->type); + printf("\t\t ("); + print_source_and_line(cu, (void *) frame->return_address); + printf(")\n"); } void trace_exception_unwind_to_native(struct jit_stack_frame *frame) -- 1.6.0.6 ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel