diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2005-05-28 18:52:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-05-28 19:46:13 -0400 |
commit | b3461034d7d46455060c8476910be22b6b0fc313 (patch) | |
tree | d5ebcf803116eb3c5800189ebb065df28c994d07 /arch/um | |
parent | 37fce857bec00d26d0e8251c909da2bd8736c949 (diff) |
[PATCH] uml: stack dump fix
Copy (and adapt) to UML the stack code dumper used in i386 when
CONFIG_FRAME_POINTER is enabled.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/include/sysrq.h | 3 | ||||
-rw-r--r-- | arch/um/kernel/sysrq.c | 21 | ||||
-rw-r--r-- | arch/um/sys-i386/sysrq.c | 80 | ||||
-rw-r--r-- | arch/um/sys-ppc/sysrq.c | 14 | ||||
-rw-r--r-- | arch/um/sys-x86_64/sysrq.c | 11 |
5 files changed, 97 insertions, 32 deletions
diff --git a/arch/um/include/sysrq.h b/arch/um/include/sysrq.h index 2ce9423460b3..c8d332b56b98 100644 --- a/arch/um/include/sysrq.h +++ b/arch/um/include/sysrq.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef __UM_SYSRQ_H | 1 | #ifndef __UM_SYSRQ_H |
2 | #define __UM_SYSRQ_H | 2 | #define __UM_SYSRQ_H |
3 | 3 | ||
4 | extern void show_trace(unsigned long *stack); | 4 | struct task_struct; |
5 | extern void show_trace(struct task_struct* task, unsigned long *stack); | ||
5 | 6 | ||
6 | #endif | 7 | #endif |
diff --git a/arch/um/kernel/sysrq.c b/arch/um/kernel/sysrq.c index e630438f9e73..f80850091e79 100644 --- a/arch/um/kernel/sysrq.c +++ b/arch/um/kernel/sysrq.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/config.h" | ||
6 | #include "linux/sched.h" | 7 | #include "linux/sched.h" |
7 | #include "linux/kernel.h" | 8 | #include "linux/kernel.h" |
8 | #include "linux/module.h" | 9 | #include "linux/module.h" |
@@ -12,14 +13,14 @@ | |||
12 | #include "sysrq.h" | 13 | #include "sysrq.h" |
13 | #include "user_util.h" | 14 | #include "user_util.h" |
14 | 15 | ||
15 | void show_trace(unsigned long * stack) | 16 | /* Catch non-i386 SUBARCH's. */ |
17 | #if !defined(CONFIG_UML_X86) || defined(CONFIG_64BIT) | ||
18 | void show_trace(struct task_struct *task, unsigned long * stack) | ||
16 | { | 19 | { |
17 | /* XXX: Copy the CONFIG_FRAME_POINTER stack-walking backtrace from | ||
18 | * arch/i386/kernel/traps.c, and then move this to sys-i386/sysrq.c.*/ | ||
19 | unsigned long addr; | 20 | unsigned long addr; |
20 | 21 | ||
21 | if (!stack) { | 22 | if (!stack) { |
22 | stack = (unsigned long*) &stack; | 23 | stack = (unsigned long*) &stack; |
23 | WARN_ON(1); | 24 | WARN_ON(1); |
24 | } | 25 | } |
25 | 26 | ||
@@ -35,6 +36,7 @@ void show_trace(unsigned long * stack) | |||
35 | } | 36 | } |
36 | printk("\n"); | 37 | printk("\n"); |
37 | } | 38 | } |
39 | #endif | ||
38 | 40 | ||
39 | /* | 41 | /* |
40 | * stack dumps generator - this is used by arch-independent code. | 42 | * stack dumps generator - this is used by arch-independent code. |
@@ -44,7 +46,7 @@ void dump_stack(void) | |||
44 | { | 46 | { |
45 | unsigned long stack; | 47 | unsigned long stack; |
46 | 48 | ||
47 | show_trace(&stack); | 49 | show_trace(current, &stack); |
48 | } | 50 | } |
49 | EXPORT_SYMBOL(dump_stack); | 51 | EXPORT_SYMBOL(dump_stack); |
50 | 52 | ||
@@ -59,7 +61,11 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
59 | int i; | 61 | int i; |
60 | 62 | ||
61 | if (esp == NULL) { | 63 | if (esp == NULL) { |
62 | if (task != current) { | 64 | if (task != current && task != NULL) { |
65 | /* XXX: Isn't this bogus? I.e. isn't this the | ||
66 | * *userspace* stack of this task? If not so, use this | ||
67 | * even when task == current (as in i386). | ||
68 | */ | ||
63 | esp = (unsigned long *) KSTK_ESP(task); | 69 | esp = (unsigned long *) KSTK_ESP(task); |
64 | /* Which one? No actual difference - just coding style.*/ | 70 | /* Which one? No actual difference - just coding style.*/ |
65 | //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs); | 71 | //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs); |
@@ -77,5 +83,6 @@ void show_stack(struct task_struct *task, unsigned long *esp) | |||
77 | printk("%08lx ", *stack++); | 83 | printk("%08lx ", *stack++); |
78 | } | 84 | } |
79 | 85 | ||
80 | show_trace(esp); | 86 | printk("Call Trace: \n"); |
87 | show_trace(current, esp); | ||
81 | } | 88 | } |
diff --git a/arch/um/sys-i386/sysrq.c b/arch/um/sys-i386/sysrq.c index 281fc7b8ca00..e3706d15c4f5 100644 --- a/arch/um/sys-i386/sysrq.c +++ b/arch/um/sys-i386/sysrq.c | |||
@@ -3,12 +3,15 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/config.h" | ||
6 | #include "linux/kernel.h" | 7 | #include "linux/kernel.h" |
7 | #include "linux/smp.h" | 8 | #include "linux/smp.h" |
8 | #include "linux/sched.h" | 9 | #include "linux/sched.h" |
10 | #include "linux/kallsyms.h" | ||
9 | #include "asm/ptrace.h" | 11 | #include "asm/ptrace.h" |
10 | #include "sysrq.h" | 12 | #include "sysrq.h" |
11 | 13 | ||
14 | /* This is declared by <linux/sched.h> */ | ||
12 | void show_regs(struct pt_regs *regs) | 15 | void show_regs(struct pt_regs *regs) |
13 | { | 16 | { |
14 | printk("\n"); | 17 | printk("\n"); |
@@ -31,5 +34,80 @@ void show_regs(struct pt_regs *regs) | |||
31 | 0xffff & PT_REGS_DS(regs), | 34 | 0xffff & PT_REGS_DS(regs), |
32 | 0xffff & PT_REGS_ES(regs)); | 35 | 0xffff & PT_REGS_ES(regs)); |
33 | 36 | ||
34 | show_trace((unsigned long *) ®s); | 37 | show_trace(NULL, (unsigned long *) ®s); |
35 | } | 38 | } |
39 | |||
40 | /* Copied from i386. */ | ||
41 | static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) | ||
42 | { | ||
43 | return p > (void *)tinfo && | ||
44 | p < (void *)tinfo + THREAD_SIZE - 3; | ||
45 | } | ||
46 | |||
47 | /* Adapted from i386 (we also print the address we read from). */ | ||
48 | static inline unsigned long print_context_stack(struct thread_info *tinfo, | ||
49 | unsigned long *stack, unsigned long ebp) | ||
50 | { | ||
51 | unsigned long addr; | ||
52 | |||
53 | #ifdef CONFIG_FRAME_POINTER | ||
54 | while (valid_stack_ptr(tinfo, (void *)ebp)) { | ||
55 | addr = *(unsigned long *)(ebp + 4); | ||
56 | printk("%08lx: [<%08lx>]", ebp + 4, addr); | ||
57 | print_symbol(" %s", addr); | ||
58 | printk("\n"); | ||
59 | ebp = *(unsigned long *)ebp; | ||
60 | } | ||
61 | #else | ||
62 | while (valid_stack_ptr(tinfo, stack)) { | ||
63 | addr = *stack; | ||
64 | if (__kernel_text_address(addr)) { | ||
65 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); | ||
66 | print_symbol(" %s", addr); | ||
67 | printk("\n"); | ||
68 | } | ||
69 | stack++; | ||
70 | } | ||
71 | #endif | ||
72 | return ebp; | ||
73 | } | ||
74 | |||
75 | void show_trace(struct task_struct* task, unsigned long * stack) | ||
76 | { | ||
77 | unsigned long ebp; | ||
78 | struct thread_info *context; | ||
79 | |||
80 | /* Turn this into BUG_ON if possible. */ | ||
81 | if (!stack) { | ||
82 | stack = (unsigned long*) &stack; | ||
83 | printk("show_trace: got NULL stack, implicit assumption task == current"); | ||
84 | WARN_ON(1); | ||
85 | } | ||
86 | |||
87 | if (!task) | ||
88 | task = current; | ||
89 | |||
90 | if (task != current) { | ||
91 | //ebp = (unsigned long) KSTK_EBP(task); | ||
92 | /* Which one? No actual difference - just coding style.*/ | ||
93 | ebp = (unsigned long) PT_REGS_EBP(&task->thread.regs); | ||
94 | } else { | ||
95 | asm ("movl %%ebp, %0" : "=r" (ebp) : ); | ||
96 | } | ||
97 | |||
98 | context = (struct thread_info *) | ||
99 | ((unsigned long)stack & (~(THREAD_SIZE - 1))); | ||
100 | print_context_stack(context, stack, ebp); | ||
101 | |||
102 | /*while (((long) stack & (THREAD_SIZE-1)) != 0) { | ||
103 | addr = *stack; | ||
104 | if (__kernel_text_address(addr)) { | ||
105 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); | ||
106 | print_symbol(" %s", addr); | ||
107 | printk("\n"); | ||
108 | } | ||
109 | stack++; | ||
110 | }*/ | ||
111 | printk("\n"); | ||
112 | } | ||
113 | |||
diff --git a/arch/um/sys-ppc/sysrq.c b/arch/um/sys-ppc/sysrq.c index 82d6e9335bb6..2f816f1a0ff4 100644 --- a/arch/um/sys-ppc/sysrq.c +++ b/arch/um/sys-ppc/sysrq.c | |||
@@ -27,17 +27,5 @@ void show_regs(struct pt_regs_subarch *regs) | |||
27 | 0xffff & regs->xds, 0xffff & regs->xes); | 27 | 0xffff & regs->xds, 0xffff & regs->xes); |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | show_trace(®s->gpr[1]); | 30 | show_trace(current, ®s->gpr[1]); |
31 | } | 31 | } |
32 | |||
33 | |||
34 | /* | ||
35 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
36 | * Emacs will notice this stuff at the end of the file and automatically | ||
37 | * adjust the settings for this buffer only. This must remain at the end | ||
38 | * of the file. | ||
39 | * --------------------------------------------------------------------------- | ||
40 | * Local variables: | ||
41 | * c-file-style: "linux" | ||
42 | * End: | ||
43 | */ | ||
diff --git a/arch/um/sys-x86_64/sysrq.c b/arch/um/sys-x86_64/sysrq.c index ddf74691a610..d0a25af19a5b 100644 --- a/arch/um/sys-x86_64/sysrq.c +++ b/arch/um/sys-x86_64/sysrq.c | |||
@@ -36,14 +36,5 @@ void __show_regs(struct pt_regs * regs) | |||
36 | void show_regs(struct pt_regs *regs) | 36 | void show_regs(struct pt_regs *regs) |
37 | { | 37 | { |
38 | __show_regs(regs); | 38 | __show_regs(regs); |
39 | show_trace((unsigned long *) ®s); | 39 | show_trace(current, (unsigned long *) ®s); |
40 | } | 40 | } |
41 | |||
42 | /* Emacs will notice this stuff at the end of the file and automatically | ||
43 | * adjust the settings for this buffer only. This must remain at the end | ||
44 | * of the file. | ||
45 | * --------------------------------------------------------------------------- | ||
46 | * Local variables: | ||
47 | * c-file-style: "linux" | ||
48 | * End: | ||
49 | */ | ||