Skip to content

Commit af5329c

Browse files
committed
Merge branch 'core/stacktrace' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core/stacktrace' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: generic-ipi: powerpc/generic-ipi tree build failure stacktrace: fix build failure on sparc64 stacktrace: export save_stack_trace[_tsk] stacktrace: fix modular build, export print_stack_trace and save_stack_trace backtrace: replace timer with tasklet + completions stacktrace: add saved stack traces to backtrace self-test stacktrace: print_stack_trace() cleanup debugging: make stacktrace independent from DEBUG_KERNEL stacktrace: don't crash on invalid stack trace structs
2 parents 1dc60c5 + 7798ed0 commit af5329c

11 files changed

Lines changed: 77 additions & 18 deletions

File tree

‎arch/arm/kernel/stacktrace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,5 @@ void save_stack_trace(struct stack_trace *trace)
9292
{
9393
save_stack_trace_tsk(current, trace);
9494
}
95+
EXPORT_SYMBOL_GPL(save_stack_trace);
9596
#endif

‎arch/avr32/kernel/stacktrace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ void save_stack_trace(struct stack_trace *trace)
5151
fp = frame->fp;
5252
}
5353
}
54+
EXPORT_SYMBOL_GPL(save_stack_trace);

‎arch/mips/kernel/stacktrace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ void save_stack_trace(struct stack_trace *trace)
7373
prepare_frametrace(regs);
7474
save_context_stack(trace, regs);
7575
}
76+
EXPORT_SYMBOL_GPL(save_stack_trace);

‎arch/powerpc/kernel/stacktrace.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/sched.h>
1414
#include <linux/stacktrace.h>
15+
#include <linux/module.h>
1516
#include <asm/ptrace.h>
1617

1718
/*
@@ -44,3 +45,4 @@ void save_stack_trace(struct stack_trace *trace)
4445
sp = newsp;
4546
}
4647
}
48+
EXPORT_SYMBOL_GPL(save_stack_trace);

‎arch/s390/kernel/stacktrace.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void save_stack_trace(struct stack_trace *trace)
8181
S390_lowcore.thread_info,
8282
S390_lowcore.thread_info + THREAD_SIZE, 1);
8383
}
84+
EXPORT_SYMBOL_GPL(save_stack_trace);
8485

8586
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
8687
{
@@ -93,3 +94,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
9394
if (trace->nr_entries < trace->max_entries)
9495
trace->entries[trace->nr_entries++] = ULONG_MAX;
9596
}
97+
EXPORT_SYMBOL_GPL(save_stack_trace_tsk);

‎arch/sh/kernel/stacktrace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ void save_stack_trace(struct stack_trace *trace)
3434
}
3535
}
3636
}
37+
EXPORT_SYMBOL_GPL(save_stack_trace);

‎arch/sparc64/kernel/stacktrace.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <linux/sched.h>
22
#include <linux/stacktrace.h>
33
#include <linux/thread_info.h>
4+
#include <linux/module.h>
45
#include <asm/ptrace.h>
56
#include <asm/stacktrace.h>
67

@@ -47,3 +48,4 @@ void save_stack_trace(struct stack_trace *trace)
4748
trace->entries[trace->nr_entries++] = pc;
4849
} while (trace->nr_entries < trace->max_entries);
4950
}
51+
EXPORT_SYMBOL_GPL(save_stack_trace);

‎arch/x86/kernel/stacktrace.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ void save_stack_trace(struct stack_trace *trace)
7474
if (trace->nr_entries < trace->max_entries)
7575
trace->entries[trace->nr_entries++] = ULONG_MAX;
7676
}
77+
EXPORT_SYMBOL_GPL(save_stack_trace);
7778

7879
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
7980
{
8081
dump_trace(tsk, NULL, NULL, 0, &save_stack_ops_nosched, trace);
8182
if (trace->nr_entries < trace->max_entries)
8283
trace->entries[trace->nr_entries++] = ULONG_MAX;
8384
}
85+
EXPORT_SYMBOL_GPL(save_stack_trace_tsk);

‎kernel/backtracetest.c‎

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,73 @@
1010
* of the License.
1111
*/
1212

13+
#include <linux/completion.h>
14+
#include <linux/delay.h>
15+
#include <linux/interrupt.h>
1316
#include <linux/module.h>
1417
#include <linux/sched.h>
15-
#include <linux/delay.h>
18+
#include <linux/stacktrace.h>
19+
20+
static void backtrace_test_normal(void)
21+
{
22+
printk("Testing a backtrace from process context.\n");
23+
printk("The following trace is a kernel self test and not a bug!\n");
1624

17-
static struct timer_list backtrace_timer;
25+
dump_stack();
26+
}
1827

19-
static void backtrace_test_timer(unsigned long data)
28+
static DECLARE_COMPLETION(backtrace_work);
29+
30+
static void backtrace_test_irq_callback(unsigned long data)
31+
{
32+
dump_stack();
33+
complete(&backtrace_work);
34+
}
35+
36+
static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
37+
38+
static void backtrace_test_irq(void)
2039
{
2140
printk("Testing a backtrace from irq context.\n");
2241
printk("The following trace is a kernel self test and not a bug!\n");
23-
dump_stack();
42+
43+
init_completion(&backtrace_work);
44+
tasklet_schedule(&backtrace_tasklet);
45+
wait_for_completion(&backtrace_work);
46+
}
47+
48+
#ifdef CONFIG_STACKTRACE
49+
static void backtrace_test_saved(void)
50+
{
51+
struct stack_trace trace;
52+
unsigned long entries[8];
53+
54+
printk("Testing a saved backtrace.\n");
55+
printk("The following trace is a kernel self test and not a bug!\n");
56+
57+
trace.nr_entries = 0;
58+
trace.max_entries = ARRAY_SIZE(entries);
59+
trace.entries = entries;
60+
trace.skip = 0;
61+
62+
save_stack_trace(&trace);
63+
print_stack_trace(&trace, 0);
64+
}
65+
#else
66+
static void backtrace_test_saved(void)
67+
{
68+
printk("Saved backtrace test skipped.\n");
2469
}
70+
#endif
71+
2572
static int backtrace_regression_test(void)
2673
{
2774
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();
3175

32-
init_timer(&backtrace_timer);
33-
backtrace_timer.function = backtrace_test_timer;
34-
mod_timer(&backtrace_timer, jiffies + 10);
76+
backtrace_test_normal();
77+
backtrace_test_irq();
78+
backtrace_test_saved();
3579

36-
msleep(10);
3780
printk("====[ end of backtrace testing ]====\n");
3881
return 0;
3982
}

‎kernel/stacktrace.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66
* Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
77
*/
88
#include <linux/sched.h>
9+
#include <linux/module.h>
910
#include <linux/kallsyms.h>
1011
#include <linux/stacktrace.h>
1112

1213
void print_stack_trace(struct stack_trace *trace, int spaces)
1314
{
14-
int i, j;
15+
int i;
1516

16-
for (i = 0; i < trace->nr_entries; i++) {
17-
unsigned long ip = trace->entries[i];
17+
if (WARN_ON(!trace->entries))
18+
return;
1819

19-
for (j = 0; j < spaces + 1; j++)
20-
printk(" ");
21-
print_ip_sym(ip);
20+
for (i = 0; i < trace->nr_entries; i++) {
21+
printk("%*c", 1 + spaces, ' ');
22+
print_ip_sym(trace->entries[i]);
2223
}
2324
}
25+
EXPORT_SYMBOL_GPL(print_stack_trace);
2426

0 commit comments

Comments
 (0)