From aaf2af3e3b0c159a64609c82811662d7253c3a96 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 25 Mar 2008 11:32:58 -0400 Subject: rebased unwind_branch on top of current master --- runtime/stack-x86_64.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'runtime/stack-x86_64.c') diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c index 186b2ad4..3ba99201 100644 --- a/runtime/stack-x86_64.c +++ b/runtime/stack-x86_64.c @@ -1,6 +1,6 @@ /* -*- linux-c -*- * x86_64 stack tracing functions - * Copyright (C) 2005, 2006, 2007 Red Hat Inc. + * Copyright (C) 2005-2008 Red Hat Inc. * * This file is part of systemtap, and is free software. You can * redistribute it and/or modify it under the terms of the GNU General @@ -8,13 +8,38 @@ * later version. */ -static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels) +// todo: don't use unwinder for kernel if CONFIG_FRAME + +/* DWARF unwinder failed. Just dump intereting addresses on kernel stack. */ +static void _stp_stack_print_fallback(unsigned long stack, int verbose) { - unsigned long *stack = (unsigned long *)REG_SP(regs); unsigned long addr; - while ((long)stack & (THREAD_SIZE-1)) { - addr = *stack++; - _stp_func_print(addr, verbose, 1); + while (stack & (THREAD_SIZE - 1)) { + if (unlikely(__stp_get_user(addr, (unsigned long *)stack))) { + /* cannot access stack. give up. */ + return; + } + _stp_func_print(addr, verbose, 0); + stack++; + } +} + +static void __stp_stack_print(struct pt_regs *regs, int verbose, int levels) +{ + struct unwind_frame_info info; + arch_unw_init_frame_info(&info, regs); + + /* we haven't actually executed the instruction at the IP yet. */ + UNW_PC(&info) -= 1; + + while (!arch_unw_user_mode(&info)) { + int ret = unwind(&info); + dbug_unwind(1, "ret=%d PC=%lx\n", ret, UNW_PC(&info)); + if (ret < 0) { + _stp_stack_print_fallback(UNW_SP(&info), verbose); + break; + } + _stp_func_print(UNW_PC(&info), verbose, 1); } } -- cgit From b56639bb84656464efbf88912f68c36e7f099d49 Mon Sep 17 00:00:00 2001 From: Martin Hunt Date: Tue, 25 Mar 2008 12:26:46 -0400 Subject: Cleanup. --- runtime/stack-x86_64.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'runtime/stack-x86_64.c') diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c index 3ba99201..e2eb4aa2 100644 --- a/runtime/stack-x86_64.c +++ b/runtime/stack-x86_64.c @@ -30,16 +30,15 @@ static void __stp_stack_print(struct pt_regs *regs, int verbose, int levels) struct unwind_frame_info info; arch_unw_init_frame_info(&info, regs); - /* we haven't actually executed the instruction at the IP yet. */ - UNW_PC(&info) -= 1; - while (!arch_unw_user_mode(&info)) { int ret = unwind(&info); - dbug_unwind(1, "ret=%d PC=%lx\n", ret, UNW_PC(&info)); + dbug_unwind(1, "ret=%d PC=%lx SP=%lx\n", ret, UNW_PC(&info), UNW_SP(&info)); if (ret < 0) { _stp_stack_print_fallback(UNW_SP(&info), verbose); break; } + if (ret) + break; _stp_func_print(UNW_PC(&info), verbose, 1); } } -- cgit From 614ead2b7dd8ac70cd89d018b09a397be7ade371 Mon Sep 17 00:00:00 2001 From: Martin Hunt Date: Fri, 28 Mar 2008 16:20:02 -0400 Subject: kretprobe trampoline fixes Recognize when a kretprobe trampoline was hit and continue with inexact stack dump. Also some testsuite changes. --- runtime/stack-x86_64.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'runtime/stack-x86_64.c') diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c index e2eb4aa2..846653be 100644 --- a/runtime/stack-x86_64.c +++ b/runtime/stack-x86_64.c @@ -8,13 +8,12 @@ * later version. */ -// todo: don't use unwinder for kernel if CONFIG_FRAME +// todo: don't use unwinder for kernel if CONFIG_FRAME /* DWARF unwinder failed. Just dump intereting addresses on kernel stack. */ static void _stp_stack_print_fallback(unsigned long stack, int verbose) { unsigned long addr; - while (stack & (THREAD_SIZE - 1)) { if (unlikely(__stp_get_user(addr, (unsigned long *)stack))) { /* cannot access stack. give up. */ @@ -33,12 +32,14 @@ static void __stp_stack_print(struct pt_regs *regs, int verbose, int levels) while (!arch_unw_user_mode(&info)) { int ret = unwind(&info); dbug_unwind(1, "ret=%d PC=%lx SP=%lx\n", ret, UNW_PC(&info), UNW_SP(&info)); - if (ret < 0) { - _stp_stack_print_fallback(UNW_SP(&info), verbose); - break; + if (ret == 0) { + _stp_func_print(UNW_PC(&info), verbose, 1); + continue; } - if (ret) - break; - _stp_func_print(UNW_PC(&info), verbose, 1); + /* 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)) + _stp_stack_print_fallback(UNW_SP(&info), verbose); + break; } } -- cgit From 580f1a959f79fdd5534a5f2f8daeb415399f38ac Mon Sep 17 00:00:00 2001 From: Martin Hunt Date: Fri, 28 Mar 2008 17:01:40 -0400 Subject: dded _stp_read_address() and changed code to use it. --- runtime/stack-x86_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/stack-x86_64.c') diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c index 846653be..96f82004 100644 --- a/runtime/stack-x86_64.c +++ b/runtime/stack-x86_64.c @@ -15,7 +15,7 @@ static void _stp_stack_print_fallback(unsigned long stack, int verbose) { unsigned long addr; while (stack & (THREAD_SIZE - 1)) { - if (unlikely(__stp_get_user(addr, (unsigned long *)stack))) { + if (unlikely(_stp_read_address(addr, (unsigned long *)stack, KERNEL_DS))) { /* cannot access stack. give up. */ return; } -- cgit From b53c1feef55dc74501a90257e4beff6c1a9cf03b Mon Sep 17 00:00:00 2001 From: Martin Hunt Date: Wed, 9 Apr 2008 17:02:40 -0400 Subject: Fixes for 2.6.25 pt_regs changes. --- runtime/stack-x86_64.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime/stack-x86_64.c') diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c index 96f82004..ae8e446d 100644 --- a/runtime/stack-x86_64.c +++ b/runtime/stack-x86_64.c @@ -8,8 +8,6 @@ * later version. */ -// todo: don't use unwinder for kernel if CONFIG_FRAME - /* DWARF unwinder failed. Just dump intereting addresses on kernel stack. */ static void _stp_stack_print_fallback(unsigned long stack, int verbose) { @@ -26,6 +24,7 @@ static void _stp_stack_print_fallback(unsigned long stack, int verbose) static void __stp_stack_print(struct pt_regs *regs, int verbose, int levels) { + // FIXME: large stack allocation struct unwind_frame_info info; arch_unw_init_frame_info(&info, regs); -- cgit