aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/traps_32.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2008-01-30 07:33:07 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:07 -0500
commit5bc27dc2f55fd3043597b5a8de6536183f28a449 (patch)
treedca83b12fb2f01f85a9e31bf1fb3802bd2cfef2a /arch/x86/kernel/traps_32.c
parente9d4efddbec3d852d435b370b9c40ff7ac24afe6 (diff)
x86: pull bp calculation earlier into the backtrace path
Right now, we take the stack pointer early during the backtrace path, but only calculate bp several functions deep later, making it hard to reconcile the stack and bp backtraces (as well as showing several internal backtrace functions on the stack with bp based backtracing). This patch moves the bp taking to the same place we take the stack pointer; sadly this ripples through several layers of the back tracing stack, but it's not all that bad in the end I hope. 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>
Diffstat (limited to 'arch/x86/kernel/traps_32.c')
-rw-r--r--arch/x86/kernel/traps_32.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 959d40edecd5..6f3bb287c702 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -120,15 +120,6 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
120{ 120{
121 struct stack_frame *frame = (struct stack_frame *)bp; 121 struct stack_frame *frame = (struct stack_frame *)bp;
122 122
123 /*
124 * if EBP is "deeper" into the stack than the actual stack pointer,
125 * we need to rewind the stack pointer a little to start at the
126 * first stack frame, but only if EBP is in this stack frame.
127 */
128 if (stack > (unsigned long *) bp
129 && valid_stack_ptr(tinfo, frame, sizeof(*frame)))
130 stack = (unsigned long *) bp;
131
132 while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) { 123 while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) {
133 unsigned long addr; 124 unsigned long addr;
134 125
@@ -139,7 +130,7 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
139 frame = frame->next_frame; 130 frame = frame->next_frame;
140 bp = (unsigned long) frame; 131 bp = (unsigned long) frame;
141 } else { 132 } else {
142 ops->address(data, addr, 0); 133 ops->address(data, addr, bp == 0);
143 } 134 }
144 } 135 }
145 stack++; 136 stack++;
@@ -150,11 +141,9 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
150#define MSG(msg) ops->warning(data, msg) 141#define MSG(msg) ops->warning(data, msg)
151 142
152void dump_trace(struct task_struct *task, struct pt_regs *regs, 143void dump_trace(struct task_struct *task, struct pt_regs *regs,
153 unsigned long *stack, 144 unsigned long *stack, unsigned long bp,
154 const struct stacktrace_ops *ops, void *data) 145 const struct stacktrace_ops *ops, void *data)
155{ 146{
156 unsigned long bp = 0;
157
158 if (!task) 147 if (!task)
159 task = current; 148 task = current;
160 149
@@ -234,20 +223,20 @@ static const struct stacktrace_ops print_trace_ops = {
234 223
235static void 224static void
236show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, 225show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
237 unsigned long * stack, char *log_lvl) 226 unsigned long *stack, unsigned long bp, char *log_lvl)
238{ 227{
239 dump_trace(task, regs, stack, &print_trace_ops, log_lvl); 228 dump_trace(task, regs, stack, bp, &print_trace_ops, log_lvl);
240 printk("%s =======================\n", log_lvl); 229 printk("%s =======================\n", log_lvl);
241} 230}
242 231
243void show_trace(struct task_struct *task, struct pt_regs *regs, 232void show_trace(struct task_struct *task, struct pt_regs *regs,
244 unsigned long * stack) 233 unsigned long *stack, unsigned long bp)
245{ 234{
246 show_trace_log_lvl(task, regs, stack, ""); 235 show_trace_log_lvl(task, regs, stack, bp, "");
247} 236}
248 237
249static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, 238static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
250 unsigned long *sp, char *log_lvl) 239 unsigned long *sp, unsigned long bp, char *log_lvl)
251{ 240{
252 unsigned long *stack; 241 unsigned long *stack;
253 int i; 242 int i;
@@ -268,13 +257,13 @@ static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
268 printk("%08lx ", *stack++); 257 printk("%08lx ", *stack++);
269 } 258 }
270 printk("\n%sCall Trace:\n", log_lvl); 259 printk("\n%sCall Trace:\n", log_lvl);
271 show_trace_log_lvl(task, regs, sp, log_lvl); 260 show_trace_log_lvl(task, regs, sp, bp, log_lvl);
272} 261}
273 262
274void show_stack(struct task_struct *task, unsigned long *sp) 263void show_stack(struct task_struct *task, unsigned long *sp)
275{ 264{
276 printk(" "); 265 printk(" ");
277 show_stack_log_lvl(task, NULL, sp, ""); 266 show_stack_log_lvl(task, NULL, sp, 0, "");
278} 267}
279 268
280/* 269/*
@@ -283,13 +272,19 @@ void show_stack(struct task_struct *task, unsigned long *sp)
283void dump_stack(void) 272void dump_stack(void)
284{ 273{
285 unsigned long stack; 274 unsigned long stack;
275 unsigned long bp = 0;
276
277#ifdef CONFIG_FRAME_POINTER
278 if (!bp)
279 asm("movl %%ebp, %0" : "=r" (bp):);
280#endif
286 281
287 printk("Pid: %d, comm: %.20s %s %s %.*s\n", 282 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
288 current->pid, current->comm, print_tainted(), 283 current->pid, current->comm, print_tainted(),
289 init_utsname()->release, 284 init_utsname()->release,
290 (int)strcspn(init_utsname()->version, " "), 285 (int)strcspn(init_utsname()->version, " "),
291 init_utsname()->version); 286 init_utsname()->version);
292 show_trace(current, NULL, &stack); 287 show_trace(current, NULL, &stack, bp);
293} 288}
294 289
295EXPORT_SYMBOL(dump_stack); 290EXPORT_SYMBOL(dump_stack);
@@ -314,7 +309,7 @@ void show_registers(struct pt_regs *regs)
314 unsigned char c; 309 unsigned char c;
315 310
316 printk("\n" KERN_EMERG "Stack: "); 311 printk("\n" KERN_EMERG "Stack: ");
317 show_stack_log_lvl(NULL, regs, &regs->sp, KERN_EMERG); 312 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
318 313
319 printk(KERN_EMERG "Code: "); 314 printk(KERN_EMERG "Code: ");
320 315