traps.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* $Id: traps.c,v 1.9 2004/05/11 12:28:26 starvik Exp $
  2. *
  3. * linux/arch/cris/traps.c
  4. *
  5. * Here we handle the break vectors not used by the system call
  6. * mechanism, as well as some general stack/register dumping
  7. * things.
  8. *
  9. * Copyright (C) 2000-2002 Axis Communications AB
  10. *
  11. * Authors: Bjorn Wesen
  12. * Hans-Peter Nilsson
  13. *
  14. */
  15. #include <linux/init.h>
  16. #include <linux/module.h>
  17. #include <asm/pgtable.h>
  18. #include <asm/uaccess.h>
  19. static int kstack_depth_to_print = 24;
  20. void show_trace(unsigned long * stack)
  21. {
  22. unsigned long addr, module_start, module_end;
  23. extern char _stext, _etext;
  24. int i;
  25. printk("\nCall Trace: ");
  26. i = 1;
  27. module_start = VMALLOC_START;
  28. module_end = VMALLOC_END;
  29. while (((long) stack & (THREAD_SIZE-1)) != 0) {
  30. if (__get_user (addr, stack)) {
  31. /* This message matches "failing address" marked
  32. s390 in ksymoops, so lines containing it will
  33. not be filtered out by ksymoops. */
  34. printk ("Failing address 0x%lx\n", (unsigned long)stack);
  35. break;
  36. }
  37. stack++;
  38. /*
  39. * If the address is either in the text segment of the
  40. * kernel, or in the region which contains vmalloc'ed
  41. * memory, it *may* be the address of a calling
  42. * routine; if so, print it so that someone tracing
  43. * down the cause of the crash will be able to figure
  44. * out the call path that was taken.
  45. */
  46. if (((addr >= (unsigned long) &_stext) &&
  47. (addr <= (unsigned long) &_etext)) ||
  48. ((addr >= module_start) && (addr <= module_end))) {
  49. if (i && ((i % 8) == 0))
  50. printk("\n ");
  51. printk("[<%08lx>] ", addr);
  52. i++;
  53. }
  54. }
  55. }
  56. /*
  57. * These constants are for searching for possible module text
  58. * segments. MODULE_RANGE is a guess of how much space is likely
  59. * to be vmalloced.
  60. */
  61. #define MODULE_RANGE (8*1024*1024)
  62. /*
  63. * The output (format, strings and order) is adjusted to be usable with
  64. * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
  65. * change it unless you're serious about adjusting ksymoops and syncing
  66. * with the ksymoops maintainer.
  67. */
  68. void
  69. show_stack(struct task_struct *task, unsigned long *sp)
  70. {
  71. unsigned long *stack, addr;
  72. int i;
  73. /*
  74. * debugging aid: "show_stack(NULL);" prints a
  75. * back trace.
  76. */
  77. if(sp == NULL) {
  78. if (task)
  79. sp = (unsigned long*)task->thread.ksp;
  80. else
  81. sp = (unsigned long*)rdsp();
  82. }
  83. stack = sp;
  84. printk("\nStack from %08lx:\n ", (unsigned long)stack);
  85. for(i = 0; i < kstack_depth_to_print; i++) {
  86. if (((long) stack & (THREAD_SIZE-1)) == 0)
  87. break;
  88. if (i && ((i % 8) == 0))
  89. printk("\n ");
  90. if (__get_user (addr, stack)) {
  91. /* This message matches "failing address" marked
  92. s390 in ksymoops, so lines containing it will
  93. not be filtered out by ksymoops. */
  94. printk ("Failing address 0x%lx\n", (unsigned long)stack);
  95. break;
  96. }
  97. stack++;
  98. printk("%08lx ", addr);
  99. }
  100. show_trace(sp);
  101. }
  102. #if 0
  103. /* displays a short stack trace */
  104. int
  105. show_stack()
  106. {
  107. unsigned long *sp = (unsigned long *)rdusp();
  108. int i;
  109. printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
  110. for(i = 0; i < 16; i++)
  111. printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
  112. return 0;
  113. }
  114. #endif
  115. void dump_stack(void)
  116. {
  117. show_stack(NULL, NULL);
  118. }
  119. EXPORT_SYMBOL(dump_stack);
  120. void __init
  121. trap_init(void)
  122. {
  123. /* Nothing needs to be done */
  124. }