sysrq.c 1.4 KB

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