[PATCH] add dump_stack(): cross-arch backtrace
authorAndrew Morton <akpm@digeo.com>
Sun, 15 Sep 2002 15:51:02 +0000 (08:51 -0700)
committerChristoph Hellwig <hch@hera.kernel.org>
Sun, 15 Sep 2002 15:51:02 +0000 (08:51 -0700)
From Christoph Hellwig, also present in 2.4.

Create an arch-independent `dump_stack()' function.  So we don't need to do

#ifdef CONFIG_X86
show_stack(0); /* No prototype in scope! */
#endif

any more.

The whole dump_stack() implementation is delegated to the architecture.
If it doesn't provide one, there is a default do-nothing library
function.

arch/alpha/kernel/traps.c
arch/cris/kernel/traps.c
arch/i386/kernel/traps.c
fs/buffer.c
include/linux/kernel.h
kernel/ksyms.c
lib/Makefile
lib/dump_stack.c [new file with mode: 0644]

index c90a631..5bce21c 100644 (file)
@@ -171,6 +171,11 @@ void show_stack(unsigned long *sp)
        dik_show_trace(sp);
 }
 
+void dump_stack(void)
+{
+       show_stack(NULL);
+}
+
 void
 die_if_kernel(char * str, struct pt_regs *regs, long err, unsigned long *r9_15)
 {
index cae9ff4..9666d32 100644 (file)
@@ -230,8 +230,12 @@ watchdog_bite_hook(struct pt_regs *regs)
 #endif 
 }
 
-/* This is normally the 'Oops' routine */
+void dump_stack(void)
+{
+       show_stack(NULL);
+}
 
+/* This is normally the 'Oops' routine */
 void 
 die_if_kernel(const char * str, struct pt_regs * regs, long err)
 {
index 0325148..3329600 100644 (file)
@@ -189,6 +189,14 @@ void show_stack(unsigned long * esp)
        show_trace(esp);
 }
 
+/*
+ * The architecture-independent dump_stack generator
+ */
+void dump_stack(void)
+{
+       show_stack(0);
+}
+
 void show_registers(struct pt_regs *regs)
 {
        int i;
index e07348c..22272f9 100644 (file)
@@ -61,10 +61,8 @@ void __buffer_error(char *file, int line)
                return;
        enough++;
        printk("buffer layer error at %s:%d\n", file, line);
-#ifdef CONFIG_X86
        printk("Pass this trace through ksymoops for reporting\n");
-       show_stack(0);
-#endif
+       dump_stack();
 }
 EXPORT_SYMBOL(__buffer_error);
 
index 9596597..5efa540 100644 (file)
@@ -96,6 +96,8 @@ extern const char *print_tainted(void);
 #define TAINT_FORCED_MODULE            (1<<1)
 #define TAINT_UNSAFE_SMP               (1<<2)
 
+extern void dump_stack(void);
+
 #if DEBUG
 #define pr_debug(fmt,arg...) \
        printk(KERN_DEBUG fmt,##arg)
index d69272a..61b045b 100644 (file)
@@ -605,3 +605,6 @@ EXPORT_SYMBOL(pidhash);
 #if defined(CONFIG_SMP) && defined(__GENERIC_PER_CPU)
 EXPORT_SYMBOL(__per_cpu_offset);
 #endif
+
+/* debug */
+EXPORT_SYMBOL(dump_stack);
index f16f109..6589280 100644 (file)
@@ -12,7 +12,7 @@ export-objs := cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o \
               crc32.o rbtree.o radix-tree.o
 
 obj-y := errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o \
-        bust_spinlocks.o rbtree.o radix-tree.o
+        bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o
 
 obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
diff --git a/lib/dump_stack.c b/lib/dump_stack.c
new file mode 100644 (file)
index 0000000..47c2728
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Provide a default dump_stack() function for architectures
+ * which don't implement their own.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+void dump_stack(void)
+{
+       printk(KERN_NOTICE
+               "This architecture does not implement dump_stack()\n");
+}