diff options
-rw-r--r-- | kernel/backtracetest.c | 30 | ||||
-rw-r--r-- | lib/Kconfig.debug | 3 |
2 files changed, 32 insertions, 1 deletions
diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c index d1a7605c5b8f..50f7abd0813d 100644 --- a/kernel/backtracetest.c +++ b/kernel/backtracetest.c | |||
@@ -10,9 +10,10 @@ | |||
10 | * of the License. | 10 | * of the License. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/delay.h> | ||
13 | #include <linux/module.h> | 14 | #include <linux/module.h> |
14 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
15 | #include <linux/delay.h> | 16 | #include <linux/stacktrace.h> |
16 | 17 | ||
17 | static struct timer_list backtrace_timer; | 18 | static struct timer_list backtrace_timer; |
18 | 19 | ||
@@ -22,6 +23,31 @@ static void backtrace_test_timer(unsigned long data) | |||
22 | printk("The following trace is a kernel self test and not a bug!\n"); | 23 | printk("The following trace is a kernel self test and not a bug!\n"); |
23 | dump_stack(); | 24 | dump_stack(); |
24 | } | 25 | } |
26 | |||
27 | #ifdef CONFIG_STACKTRACE | ||
28 | static void backtrace_test_saved(void) | ||
29 | { | ||
30 | struct stack_trace trace; | ||
31 | unsigned long entries[8]; | ||
32 | |||
33 | printk("Testing a saved backtrace.\n"); | ||
34 | printk("The following trace is a kernel self test and not a bug!\n"); | ||
35 | |||
36 | trace.nr_entries = 0; | ||
37 | trace.max_entries = ARRAY_SIZE(entries); | ||
38 | trace.entries = entries; | ||
39 | trace.skip = 0; | ||
40 | |||
41 | save_stack_trace(&trace); | ||
42 | print_stack_trace(&trace, 0); | ||
43 | } | ||
44 | #else | ||
45 | static void backtrace_test_saved(void) | ||
46 | { | ||
47 | printk("Saved backtrace test skipped.\n"); | ||
48 | } | ||
49 | #endif | ||
50 | |||
25 | static int backtrace_regression_test(void) | 51 | static int backtrace_regression_test(void) |
26 | { | 52 | { |
27 | printk("====[ backtrace testing ]===========\n"); | 53 | printk("====[ backtrace testing ]===========\n"); |
@@ -29,6 +55,8 @@ static int backtrace_regression_test(void) | |||
29 | printk("The following trace is a kernel self test and not a bug!\n"); | 55 | printk("The following trace is a kernel self test and not a bug!\n"); |
30 | dump_stack(); | 56 | dump_stack(); |
31 | 57 | ||
58 | backtrace_test_saved(); | ||
59 | |||
32 | init_timer(&backtrace_timer); | 60 | init_timer(&backtrace_timer); |
33 | backtrace_timer.function = backtrace_test_timer; | 61 | backtrace_timer.function = backtrace_test_timer; |
34 | mod_timer(&backtrace_timer, jiffies + 10); | 62 | mod_timer(&backtrace_timer, jiffies + 10); |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 9c17fb9d1d5e..6263e2d851f1 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -562,6 +562,9 @@ config BACKTRACE_SELF_TEST | |||
562 | for distributions or general kernels, but only for kernel | 562 | for distributions or general kernels, but only for kernel |
563 | developers working on architecture code. | 563 | developers working on architecture code. |
564 | 564 | ||
565 | Note that if you want to also test saved backtraces, you will | ||
566 | have to enable STACKTRACE as well. | ||
567 | |||
565 | Say N if you are unsure. | 568 | Say N if you are unsure. |
566 | 569 | ||
567 | config LKDTM | 570 | config LKDTM |