diff options
author | Tim Moore <timoore@redhat.com> | 2009-03-04 11:56:45 +0100 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-03-04 13:18:55 +0100 |
commit | 8c5905d0b6c8206c5ed971a637077aa8ef5c1b02 (patch) | |
tree | 12e9d4f80aec601b66ec83e06e8b3675ba4a18bd | |
parent | cd1db1dd034141535648a66d9896db6c5e74dd9e (diff) | |
download | systemtap-steved-8c5905d0b6c8206c5ed971a637077aa8ef5c1b02.tar.gz systemtap-steved-8c5905d0b6c8206c5ed971a637077aa8ef5c1b02.tar.xz systemtap-steved-8c5905d0b6c8206c5ed971a637077aa8ef5c1b02.zip |
stap autoconf test for kernel stack trace support
* buildrun.cxx (compile_pass): Add autoconf line for stack trace
test, which defines STAPCONF_KERNEL_STACKTRACE.
* runtime/autoconf-save-stack-trace.c: New file.
* runtime/stack.c : Use STAPCONF_KERNEL_STACKTRACE instead of
tests for kernel configuration and versions.
* runtime/stack-i386.c : ditto
* runtime/stack-x86_64.c : ditto
-rw-r--r-- | buildrun.cxx | 2 | ||||
-rw-r--r-- | runtime/autoconf-save-stack-trace.c | 22 | ||||
-rw-r--r-- | runtime/stack-i386.c | 2 | ||||
-rw-r--r-- | runtime/stack-x86_64.c | 2 | ||||
-rw-r--r-- | runtime/stack.c | 7 |
5 files changed, 29 insertions, 6 deletions
diff --git a/buildrun.cxx b/buildrun.cxx index fe060236..973343cd 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -153,6 +153,8 @@ compile_pass (systemtap_session& s) * this autoconf. */ output_autoconf(s, o, "autoconf-probe-kernel.c", "STAPCONF_PROBE_KERNEL", NULL); #endif + output_autoconf(s, o, "autoconf-save-stack-trace.c", + "STAPCONF_KERNEL_STACKTRACE", NULL); o << module_cflags << " += -include $(STAPCONF_HEADER)" << endl; diff --git a/runtime/autoconf-save-stack-trace.c b/runtime/autoconf-save-stack-trace.c new file mode 100644 index 00000000..39ded684 --- /dev/null +++ b/runtime/autoconf-save-stack-trace.c @@ -0,0 +1,22 @@ +#include <linux/string.h> +#include <linux/sched.h> +#include <linux/stacktrace.h> +#include <asm/stacktrace.h> + +void foo(struct task_struct *foo) +{ + struct stack_trace trace; + unsigned long backtrace[20]; + memset(&trace, 0, sizeof(trace)); + trace.entries = &backtrace[0]; + trace.max_entries = 20; + trace.skip = 0; + save_stack_trace_tsk(tsk, &trace); +} + +static const struct stacktrace_ops print_stack_ops; + +void dumper(struct task_struct *foo) +{ + dump_trace(foo, 0, 0, 0, &print_stack_ops, 0); +} diff --git a/runtime/stack-i386.c b/runtime/stack-i386.c index 206801d8..5a18c9d8 100644 --- a/runtime/stack-i386.c +++ b/runtime/stack-i386.c @@ -14,7 +14,7 @@ static int _stp_valid_stack_ptr(unsigned long context, unsigned long p) } /* DWARF unwinder failed. Just dump intereting addresses on kernel stack. */ -#if ! (defined(CONFIG_STACKTRACE) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) +#if !defined(STAPCONF_KERNEL_STACKTRACE) static void _stp_stack_print_fallback(unsigned long stack, int verbose, int levels) { unsigned long addr; diff --git a/runtime/stack-x86_64.c b/runtime/stack-x86_64.c index 183de0a0..03d88ef0 100644 --- a/runtime/stack-x86_64.c +++ b/runtime/stack-x86_64.c @@ -10,7 +10,7 @@ /* DWARF unwinder failed. Just dump intereting addresses on kernel stack. */ -#if ! (defined(CONFIG_STACKTRACE) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) +#if !defined(STAPCONF_KERNEL_STACKTRACE) static void _stp_stack_print_fallback(unsigned long stack, int verbose, int levels) { unsigned long addr; diff --git a/runtime/stack.c b/runtime/stack.c index aa0e6d65..f6b1cd08 100644 --- a/runtime/stack.c +++ b/runtime/stack.c @@ -27,8 +27,7 @@ #define MAXBACKTRACE 20 -#if defined(CONFIG_STACKTRACE) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26) -// XXX: PR9866: hacky temporarily restriction to recent kernels +#if defined(STAPCONF_KERNEL_STACKTRACE) #include <linux/stacktrace.h> #include <asm/stacktrace.h> #endif @@ -51,7 +50,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int); #error "Unsupported architecture" #endif -#if defined(CONFIG_STACKTRACE) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26) +#if defined(STAPCONF_KERNEL_STACKTRACE) struct print_stack_data { @@ -161,7 +160,7 @@ static void _stp_ustack_print(char *str) void _stp_stack_print_tsk(struct task_struct *tsk, int verbose, int levels) { -#if defined(CONFIG_STACKTRACE) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26) +#if defined(STAPCONF_KERNEL_STACKTRACE) int i; unsigned long backtrace[MAXBACKTRACE]; struct stack_trace trace; |