From 15d8b8ee8214d1fbba80329c5a571974a4403476 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 21 Apr 2009 12:06:53 +0200 Subject: Don't use stack fallback for user space unwinding when using dwarf unwinder. It never seems to be anywhere near correct. * runtime/stack-i386.c (__stp_stack_print): Stop unwinding when dwarf unwinder fails and we are unwinding user space task. * runtime/stack-x86_64.c (__stp_stack_print): Likewise. --- runtime/stack-i386.c | 12 ++++++++---- runtime/stack-x86_64.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/runtime/stack-i386.c b/runtime/stack-i386.c index 6fd1613f..69623765 100644 --- a/runtime/stack-i386.c +++ b/runtime/stack-i386.c @@ -69,11 +69,15 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels, levels--; continue; } - /* If an error happened or we hit a kretprobe trampoline, use fallback backtrace */ - /* FIXME: is there a way to unwind across kretprobe trampolines? */ - if (ret < 0 || (ret > 0 && UNW_PC(&info) == _stp_kretprobe_trampoline)) + /* If an error happened or we hit a kretprobe trampoline, + * use fallback backtrace, unless user task backtrace. + * FIXME: is there a way to unwind across kretprobe + * trampolines? */ + if ((ret < 0 + || (ret > 0 && UNW_PC(&info) == _stp_kretprobe_trampoline)) + && ! (tsk || arch_unw_user_mode(&info))) _stp_stack_print_fallback(UNW_SP(&info), verbose, levels); - break; + return; } #else /* ! STP_USE_DWARF_UNWINDER */ _stp_stack_print_fallback((unsigned long)®_SP(regs), verbose, levels); diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c index 03eb33e8..9afdf38a 100644 --- a/runtime/stack-x86_64.c +++ b/runtime/stack-x86_64.c @@ -43,11 +43,15 @@ static void __stp_stack_print(struct pt_regs *regs, int verbose, int levels, levels--; continue; } - /* If an error happened or we hit a kretprobe trampoline, use fallback backtrace */ - /* FIXME: is there a way to unwind across kretprobe trampolines? */ - if (ret < 0 || (ret > 0 && UNW_PC(&info) == _stp_kretprobe_trampoline)) + /* If an error happened or we hit a kretprobe trampoline, + * use fallback backtrace, unless user task backtrace. + * FIXME: is there a way to unwind across kretprobe + * trampolines? */ + if ((ret < 0 + || (ret > 0 && UNW_PC(&info) == _stp_kretprobe_trampoline)) + && ! (tsk || arch_unw_user_mode(&info))) _stp_stack_print_fallback(UNW_SP(&info), verbose, levels); - break; + return; } #else /* ! STP_USE_DWARF_UNWINDER */ _stp_stack_print_fallback(REG_SP(regs), verbose, levels); -- cgit