sysrq.c 1.7 KB

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