sysrq.c 1.7 KB

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