diff options
author | Arjan van de Ven <arjan@infradead.org> | 2008-01-30 07:33:08 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:33:08 -0500 |
commit | 6dab27784b2a97823b522e1cb88e40be40a93d45 (patch) | |
tree | 75ee27b4841aad5800531e591aed141164071727 | |
parent | 80b51f310b6f55006a265d087b8f48744e65663d (diff) |
x86: add a simple backtrace test module
During the work on the x86 32 and 64 bit backtrace code I found it useful
to have a simple test module to test a process and irq context backtrace.
Since the existing backtrace code was buggy, I figure it might be useful
to have such a test module in the kernel so that maybe we can even
detect such bugs earlier..
[ mingo@elte.hu: build fix ]
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | kernel/Makefile | 1 | ||||
-rw-r--r-- | kernel/backtracetest.c | 48 | ||||
-rw-r--r-- | lib/Kconfig.debug | 12 |
3 files changed, 61 insertions, 0 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 62015c3d8d91..8885627ea021 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -36,6 +36,7 @@ obj-$(CONFIG_KALLSYMS) += kallsyms.o | |||
36 | obj-$(CONFIG_PM) += power/ | 36 | obj-$(CONFIG_PM) += power/ |
37 | obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o | 37 | obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o |
38 | obj-$(CONFIG_KEXEC) += kexec.o | 38 | obj-$(CONFIG_KEXEC) += kexec.o |
39 | obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o | ||
39 | obj-$(CONFIG_COMPAT) += compat.o | 40 | obj-$(CONFIG_COMPAT) += compat.o |
40 | obj-$(CONFIG_CGROUPS) += cgroup.o | 41 | obj-$(CONFIG_CGROUPS) += cgroup.o |
41 | obj-$(CONFIG_CGROUP_DEBUG) += cgroup_debug.o | 42 | obj-$(CONFIG_CGROUP_DEBUG) += cgroup_debug.o |
diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c new file mode 100644 index 000000000000..d1a7605c5b8f --- /dev/null +++ b/kernel/backtracetest.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Simple stack backtrace regression test module | ||
3 | * | ||
4 | * (C) Copyright 2008 Intel Corporation | ||
5 | * Author: Arjan van de Ven <arjan@linux.intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; version 2 | ||
10 | * of the License. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/delay.h> | ||
16 | |||
17 | static struct timer_list backtrace_timer; | ||
18 | |||
19 | static void backtrace_test_timer(unsigned long data) | ||
20 | { | ||
21 | printk("Testing a backtrace from irq context.\n"); | ||
22 | printk("The following trace is a kernel self test and not a bug!\n"); | ||
23 | dump_stack(); | ||
24 | } | ||
25 | static int backtrace_regression_test(void) | ||
26 | { | ||
27 | printk("====[ backtrace testing ]===========\n"); | ||
28 | printk("Testing a backtrace from process context.\n"); | ||
29 | printk("The following trace is a kernel self test and not a bug!\n"); | ||
30 | dump_stack(); | ||
31 | |||
32 | init_timer(&backtrace_timer); | ||
33 | backtrace_timer.function = backtrace_test_timer; | ||
34 | mod_timer(&backtrace_timer, jiffies + 10); | ||
35 | |||
36 | msleep(10); | ||
37 | printk("====[ end of backtrace testing ]====\n"); | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | static void exitf(void) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | module_init(backtrace_regression_test); | ||
46 | module_exit(exitf); | ||
47 | MODULE_LICENSE("GPL"); | ||
48 | MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>"); | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index f535b9b5eb00..aa56e631580d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -506,6 +506,18 @@ config KPROBES_SANITY_TEST | |||
506 | 506 | ||
507 | Say N if you are unsure. | 507 | Say N if you are unsure. |
508 | 508 | ||
509 | config BACKTRACE_SELF_TEST | ||
510 | tristate "Self test for the backtrace code" | ||
511 | depends on DEBUG_KERNEL | ||
512 | default n | ||
513 | help | ||
514 | This option provides a kernel module that can be used to test | ||
515 | the kernel stack backtrace code. This option is not useful | ||
516 | for distributions or general kernels, but only for kernel | ||
517 | developers working on architecture code. | ||
518 | |||
519 | Say N if you are unsure. | ||
520 | |||
509 | config LKDTM | 521 | config LKDTM |
510 | tristate "Linux Kernel Dump Test Tool Module" | 522 | tristate "Linux Kernel Dump Test Tool Module" |
511 | depends on DEBUG_KERNEL | 523 | depends on DEBUG_KERNEL |