1 /* $Id: traps.c,v 1.7 2003/07/04 08:27:52 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 <asm/pgtable.h>
18 #include <asm/uaccess.h>
20 static int kstack_depth_to_print = 24;
22 void show_trace(unsigned long * stack)
24 unsigned long addr, module_start, module_end;
25 extern char _stext, _etext;
28 printk("\nCall Trace: ");
31 module_start = VMALLOC_START;
32 module_end = VMALLOC_END;
34 while (((long) stack & (THREAD_SIZE-1)) != 0) {
35 if (__get_user (addr, stack)) {
36 /* This message matches "failing address" marked
37 s390 in ksymoops, so lines containing it will
38 not be filtered out by ksymoops. */
39 printk ("Failing address 0x%lx\n", (unsigned long)stack);
45 * If the address is either in the text segment of the
46 * kernel, or in the region which contains vmalloc'ed
47 * memory, it *may* be the address of a calling
48 * routine; if so, print it so that someone tracing
49 * down the cause of the crash will be able to figure
50 * out the call path that was taken.
52 if (((addr >= (unsigned long) &_stext) &&
53 (addr <= (unsigned long) &_etext)) ||
54 ((addr >= module_start) && (addr <= module_end))) {
55 if (i && ((i % 8) == 0))
57 printk("[<%08lx>] ", addr);
64 * These constants are for searching for possible module text
65 * segments. MODULE_RANGE is a guess of how much space is likely
69 #define MODULE_RANGE (8*1024*1024)
72 * The output (format, strings and order) is adjusted to be usable with
73 * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
74 * change it unless you're serious about adjusting ksymoops and syncing
75 * with the ksymoops maintainer.
79 show_stack(struct task_struct *task, unsigned long *sp)
81 unsigned long *stack, addr;
85 * debugging aid: "show_stack(NULL);" prints a
91 sp = (unsigned long*)task->thread.ksp;
93 sp = (unsigned long*)rdsp();
98 printk("\nStack from %08lx:\n ", (unsigned long)stack);
99 for(i = 0; i < kstack_depth_to_print; i++) {
100 if (((long) stack & (THREAD_SIZE-1)) == 0)
102 if (i && ((i % 8) == 0))
104 if (__get_user (addr, stack)) {
105 /* This message matches "failing address" marked
106 s390 in ksymoops, so lines containing it will
107 not be filtered out by ksymoops. */
108 printk ("Failing address 0x%lx\n", (unsigned long)stack);
112 printk("%08lx ", addr);
118 /* displays a short stack trace */
123 unsigned long *sp = (unsigned long *)rdusp();
125 printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
126 for(i = 0; i < 16; i++)
127 printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
132 void dump_stack(void)
134 show_stack(NULL, NULL);
137 EXPORT_SYMBOL(dump_stack);
142 /* Nothing needs to be done */