1 /* $Id: traps.c,v 1.9 2004/05/11 12:28:26 starvik Exp $
3 * linux/arch/cris/traps.c
5 * Here we handle the break vectors not used by the system call
6 * mechanism, as well as some general stack/register dumping
9 * Copyright (C) 2000-2002 Axis Communications AB
11 * Authors: Bjorn Wesen
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <asm/pgtable.h>
19 #include <asm/uaccess.h>
21 static int kstack_depth_to_print
= 24;
23 void show_trace(unsigned long * stack
)
25 unsigned long addr
, module_start
, module_end
;
26 extern char _stext
, _etext
;
29 printk("\nCall Trace: ");
32 module_start
= VMALLOC_START
;
33 module_end
= VMALLOC_END
;
35 while (((long) stack
& (THREAD_SIZE
-1)) != 0) {
36 if (__get_user (addr
, stack
)) {
37 /* This message matches "failing address" marked
38 s390 in ksymoops, so lines containing it will
39 not be filtered out by ksymoops. */
40 printk ("Failing address 0x%lx\n", (unsigned long)stack
);
46 * If the address is either in the text segment of the
47 * kernel, or in the region which contains vmalloc'ed
48 * memory, it *may* be the address of a calling
49 * routine; if so, print it so that someone tracing
50 * down the cause of the crash will be able to figure
51 * out the call path that was taken.
53 if (((addr
>= (unsigned long) &_stext
) &&
54 (addr
<= (unsigned long) &_etext
)) ||
55 ((addr
>= module_start
) && (addr
<= module_end
))) {
56 if (i
&& ((i
% 8) == 0))
58 printk("[<%08lx>] ", addr
);
65 * These constants are for searching for possible module text
66 * segments. MODULE_RANGE is a guess of how much space is likely
70 #define MODULE_RANGE (8*1024*1024)
73 * The output (format, strings and order) is adjusted to be usable with
74 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
75 * change it unless you're serious about adjusting ksymoops and syncing
76 * with the ksymoops maintainer.
80 show_stack(struct task_struct
*task
, unsigned long *sp
)
82 unsigned long *stack
, addr
;
86 * debugging aid: "show_stack(NULL);" prints a
92 sp
= (unsigned long*)task
->thread
.ksp
;
94 sp
= (unsigned long*)rdsp();
99 printk("\nStack from %08lx:\n ", (unsigned long)stack
);
100 for(i
= 0; i
< kstack_depth_to_print
; i
++) {
101 if (((long) stack
& (THREAD_SIZE
-1)) == 0)
103 if (i
&& ((i
% 8) == 0))
105 if (__get_user (addr
, stack
)) {
106 /* This message matches "failing address" marked
107 s390 in ksymoops, so lines containing it will
108 not be filtered out by ksymoops. */
109 printk ("Failing address 0x%lx\n", (unsigned long)stack
);
113 printk("%08lx ", addr
);
119 /* displays a short stack trace */
124 unsigned long *sp
= (unsigned long *)rdusp();
126 printk("Stack dump [0x%08lx]:\n", (unsigned long)sp
);
127 for(i
= 0; i
< 16; i
++)
128 printk("sp + %d: 0x%08lx\n", i
*4, sp
[i
]);
133 void dump_stack(void)
135 show_stack(NULL
, NULL
);
138 EXPORT_SYMBOL(dump_stack
);
143 /* Nothing needs to be done */