2 * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
6 #include "linux/config.h"
7 #include "linux/kernel.h"
9 #include "linux/sched.h"
10 #include "linux/kallsyms.h"
11 #include "asm/ptrace.h"
14 /* This is declared by <linux/sched.h> */
15 void show_regs(struct pt_regs *regs)
18 printk("EIP: %04lx:[<%08lx>] CPU: %d %s",
19 0xffff & PT_REGS_CS(regs), PT_REGS_IP(regs),
20 smp_processor_id(), print_tainted());
21 if (PT_REGS_CS(regs) & 3)
22 printk(" ESP: %04lx:%08lx", 0xffff & PT_REGS_SS(regs),
24 printk(" EFLAGS: %08lx\n %s\n", PT_REGS_EFLAGS(regs),
26 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
27 PT_REGS_EAX(regs), PT_REGS_EBX(regs),
30 printk("ESI: %08lx EDI: %08lx EBP: %08lx",
31 PT_REGS_ESI(regs), PT_REGS_EDI(regs),
33 printk(" DS: %04lx ES: %04lx\n",
34 0xffff & PT_REGS_DS(regs),
35 0xffff & PT_REGS_ES(regs));
37 show_trace(NULL, (unsigned long *) ®s);
40 /* Copied from i386. */
41 static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
43 return p > (void *)tinfo &&
44 p < (void *)tinfo + THREAD_SIZE - 3;
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)
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);
59 ebp = *(unsigned long *)ebp;
62 while (valid_stack_ptr(tinfo, stack)) {
64 if (__kernel_text_address(addr)) {
65 printk("%08lx: [<%08lx>]", (unsigned long) stack, addr);
66 print_symbol(" %s", addr);
75 void show_trace(struct task_struct* task, unsigned long * stack)
78 struct thread_info *context;
80 /* Turn this into BUG_ON if possible. */
82 stack = (unsigned long*) &stack;
83 printk("show_trace: got NULL stack, implicit assumption task == current");
90 if (task != current) {
91 ebp = (unsigned long) KSTK_EBP(task);
93 asm ("movl %%ebp, %0" : "=r" (ebp) : );
96 context = (struct thread_info *)
97 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
98 print_context_stack(context, stack, ebp);