2 * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
6 #include "linux/kernel.h"
8 #include "linux/sched.h"
9 #include "linux/kallsyms.h"
10 #include "asm/ptrace.h"
13 /* This is declared by <linux/sched.h> */
14 void show_regs(struct pt_regs *regs)
17 printk("EIP: %04lx:[<%08lx>] CPU: %d %s",
18 0xffff & PT_REGS_CS(regs), PT_REGS_IP(regs),
19 smp_processor_id(), print_tainted());
20 if (PT_REGS_CS(regs) & 3)
21 printk(" ESP: %04lx:%08lx", 0xffff & PT_REGS_SS(regs),
23 printk(" EFLAGS: %08lx\n %s\n", PT_REGS_EFLAGS(regs),
25 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
26 PT_REGS_EAX(regs), PT_REGS_EBX(regs),
29 printk("ESI: %08lx EDI: %08lx EBP: %08lx",
30 PT_REGS_ESI(regs), PT_REGS_EDI(regs),
32 printk(" DS: %04lx ES: %04lx\n",
33 0xffff & PT_REGS_DS(regs),
34 0xffff & PT_REGS_ES(regs));
36 show_trace(NULL, (unsigned long *) ®s);
39 /* Copied from i386. */
40 static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
42 return p > (void *)tinfo &&
43 p < (void *)tinfo + THREAD_SIZE - 3;
46 /* Adapted from i386 (we also print the address we read from). */
47 static inline unsigned long print_context_stack(struct thread_info *tinfo,
48 unsigned long *stack, unsigned long ebp)
52 #ifdef CONFIG_FRAME_POINTER
53 while (valid_stack_ptr(tinfo, (void *)ebp)) {
54 addr = *(unsigned long *)(ebp + 4);
55 printk("%08lx: [<%08lx>]", ebp + 4, addr);
56 print_symbol(" %s", addr);
58 ebp = *(unsigned long *)ebp;
61 while (valid_stack_ptr(tinfo, stack)) {
63 if (__kernel_text_address(addr)) {
64 printk("%08lx: [<%08lx>]", (unsigned long) stack, addr);
65 print_symbol(" %s", addr);
74 void show_trace(struct task_struct* task, unsigned long * stack)
77 struct thread_info *context;
79 /* Turn this into BUG_ON if possible. */
81 stack = (unsigned long*) &stack;
82 printk("show_trace: got NULL stack, implicit assumption task == current");
89 if (task != current) {
90 ebp = (unsigned long) KSTK_EBP(task);
92 asm ("movl %%ebp, %0" : "=r" (ebp) : );
95 context = (struct thread_info *)
96 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
97 print_context_stack(context, stack, ebp);