Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) |
| 3 | * Licensed under the GPL |
| 4 | */ |
| 5 | |
| 6 | #include "linux/sched.h" |
| 7 | #include "linux/kernel.h" |
| 8 | #include "linux/module.h" |
| 9 | #include "linux/kallsyms.h" |
| 10 | #include "asm/page.h" |
| 11 | #include "asm/processor.h" |
| 12 | #include "sysrq.h" |
| 13 | #include "user_util.h" |
| 14 | |
Paolo 'Blaisorblade' Giarrusso | b346103 | 2005-05-28 15:52:00 -0700 | [diff] [blame] | 15 | /* Catch non-i386 SUBARCH's. */ |
| 16 | #if !defined(CONFIG_UML_X86) || defined(CONFIG_64BIT) |
| 17 | void show_trace(struct task_struct *task, unsigned long * stack) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | unsigned long addr; |
| 20 | |
| 21 | if (!stack) { |
Paolo 'Blaisorblade' Giarrusso | b346103 | 2005-05-28 15:52:00 -0700 | [diff] [blame] | 22 | stack = (unsigned long*) &stack; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | WARN_ON(1); |
| 24 | } |
| 25 | |
| 26 | printk("Call Trace: \n"); |
| 27 | while (((long) stack & (THREAD_SIZE-1)) != 0) { |
| 28 | addr = *stack; |
| 29 | if (__kernel_text_address(addr)) { |
| 30 | printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); |
| 31 | print_symbol(" %s", addr); |
| 32 | printk("\n"); |
| 33 | } |
| 34 | stack++; |
| 35 | } |
| 36 | printk("\n"); |
| 37 | } |
Paolo 'Blaisorblade' Giarrusso | b346103 | 2005-05-28 15:52:00 -0700 | [diff] [blame] | 38 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * stack dumps generator - this is used by arch-independent code. |
| 42 | * And this is identical to i386 currently. |
| 43 | */ |
| 44 | void dump_stack(void) |
| 45 | { |
| 46 | unsigned long stack; |
| 47 | |
Paolo 'Blaisorblade' Giarrusso | b346103 | 2005-05-28 15:52:00 -0700 | [diff] [blame] | 48 | show_trace(current, &stack); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | } |
| 50 | EXPORT_SYMBOL(dump_stack); |
| 51 | |
| 52 | /*Stolen from arch/i386/kernel/traps.c */ |
Jeff Dike | 0d0d0ed | 2007-02-10 01:44:15 -0800 | [diff] [blame] | 53 | static const int kstack_depth_to_print = 24; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /* This recently started being used in arch-independent code too, as in |
| 56 | * kernel/sched.c.*/ |
| 57 | void show_stack(struct task_struct *task, unsigned long *esp) |
| 58 | { |
| 59 | unsigned long *stack; |
| 60 | int i; |
| 61 | |
| 62 | if (esp == NULL) { |
Paolo 'Blaisorblade' Giarrusso | b346103 | 2005-05-28 15:52:00 -0700 | [diff] [blame] | 63 | if (task != current && task != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | esp = (unsigned long *) KSTK_ESP(task); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } else { |
| 66 | esp = (unsigned long *) &esp; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | stack = esp; |
| 71 | for(i = 0; i < kstack_depth_to_print; i++) { |
| 72 | if (kstack_end(stack)) |
| 73 | break; |
| 74 | if (i && ((i % 8) == 0)) |
| 75 | printk("\n "); |
| 76 | printk("%08lx ", *stack++); |
| 77 | } |
| 78 | |
Paolo 'Blaisorblade' Giarrusso | b346103 | 2005-05-28 15:52:00 -0700 | [diff] [blame] | 79 | printk("Call Trace: \n"); |
Allan Graves | fad1c45 | 2005-10-04 14:53:52 -0400 | [diff] [blame] | 80 | show_trace(task, esp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |