show_function() and show_exe_function() were not using the trace buffer which led to inconsistent backtrace output.
Reported-by: Pekka Enberg <penb...@cs.helsinki.fi> Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- arch/x86/backtrace.c | 28 ++++++++++++++-------------- test/vm/stack-trace-stub.c | 6 ++++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/x86/backtrace.c b/arch/x86/backtrace.c index 64e5ccd..684fcaa 100644 --- a/arch/x86/backtrace.c +++ b/arch/x86/backtrace.c @@ -114,7 +114,7 @@ bool show_exe_function(void *addr) symbol_start = bfd_asymbol_value(symbol); symbol_offset = (unsigned long) addr - symbol_start; - printf("%s+%llx (%s:%i)\n", + trace_printf("%s+%llx (%s:%i)\n", function_name, (long long) symbol_offset, filename, line); ret = true; @@ -135,7 +135,7 @@ void show_function(void *addr) if (show_exe_function(addr)) return; - printf("<unknown>\n"); + trace_printf("<unknown>\n"); } static unsigned long get_greg(gregset_t gregs, int reg) @@ -165,10 +165,10 @@ static void show_registers(gregset_t gregs) ebp = get_greg(gregs, REG_EBP); esp = get_greg(gregs, REG_ESP); - printf("Registers:\n"); - printf(" eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", + trace_printf("Registers:\n"); + trace_printf(" eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", eax, ebx, ecx, edx); - printf(" esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", + trace_printf(" esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", esi, edi, ebp, esp); } @@ -210,13 +210,13 @@ static void show_registers(gregset_t gregs) r14 = get_greg(gregs, REG_R14); r15 = get_greg(gregs, REG_R15); - printf("Registers:\n"); - printf(" rsp: %016lx\n", rsp); - printf(" rax: %016lx ebx: %016lx ecx: %016lx\n", rax, rbx, rcx); - printf(" rdx: %016lx rsi: %016lx rdi: %016lx\n", rdx, rsi, rdi); - printf(" rbp: %016lx r8: %016lx r9: %016lx\n", rbp, r8, r9); - printf(" r10: %016lx r11: %016lx r12: %016lx\n", r10, r11, r12); - printf(" r13: %016lx r14: %016lx r15: %016lx\n", r13, r14, r15); + trace_printf("Registers:\n"); + trace_printf(" rsp: %016lx\n", rsp); + trace_printf(" rax: %016lx ebx: %016lx ecx: %016lx\n", rax, rbx, rcx); + trace_printf(" rdx: %016lx rsi: %016lx rdi: %016lx\n", rdx, rsi, rdi); + trace_printf(" rbp: %016lx r8: %016lx r9: %016lx\n", rbp, r8, r9); + trace_printf(" r10: %016lx r11: %016lx r12: %016lx\n", r10, r11, r12); + trace_printf(" r13: %016lx r14: %016lx r15: %016lx\n", r13, r14, r15); } #endif @@ -231,11 +231,11 @@ void print_backtrace_and_die(int sig, siginfo_t *info, void *secret) switch (sig) { case SIGSEGV: - printf("SIGSEGV at %s %08lx while accessing memory address %08lx.\n", + trace_printf("SIGSEGV at %s %08lx while accessing memory address %08lx.\n", IP_REG_NAME, eip, addr); break; default: - printf("Signal %d at %s %08lx\n", sig, IP_REG_NAME, eip); + trace_printf("Signal %d at %s %08lx\n", sig, IP_REG_NAME, eip); break; }; show_registers(uc->uc_mcontext.gregs); diff --git a/test/vm/stack-trace-stub.c b/test/vm/stack-trace-stub.c index 48cb7c9..d6414b4 100644 --- a/test/vm/stack-trace-stub.c +++ b/test/vm/stack-trace-stub.c @@ -54,11 +54,13 @@ static inline void __show_stack_trace(unsigned long start, unsigned long caller) if (caller) array[1] = (void *) caller; - printf("Native stack trace:\n"); + trace_printf("Native stack trace:\n"); for (i = start; i < size; i++) { - printf(" [<%08lx>] ", (unsigned long) array[i]); + trace_printf(" [<%08lx>] ", (unsigned long) array[i]); show_function(array[i]); } + + trace_flush(); } void print_trace(void) -- 1.6.0.6 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel