public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@digeo.com>
To: Nicholas Miell <nmiell@attbi.com>
Cc: Linus Torvalds <torvalds@transmeta.com>, Greg KH <greg@kroah.com>,
	linux-usb-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: [patch] dump_stack(): arch-neutral stack trace
Date: Mon, 09 Sep 2002 18:01:47 -0700	[thread overview]
Message-ID: <3D7D447B.D7BD1C33@digeo.com> (raw)
In-Reply-To: 1031618129.1403.12.camel@entropy

Nicholas Miell wrote:
> 
> ...
> show_trace isn't exported for modules, and (even worse) isn't even
> implemented on all architectures, IIRC.

That's right.



>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 |    5 +++++
 arch/cris/kernel/traps.c  |    6 +++++-
 arch/i386/kernel/traps.c  |    8 ++++++++
 fs/buffer.c               |    4 +---
 include/linux/kernel.h    |    2 ++
 kernel/ksyms.c            |    3 +++
 lib/Makefile              |    2 +-
 lib/dump_stack.c          |   13 +++++++++++++
 8 files changed, 38 insertions(+), 5 deletions(-)

--- 2.5.34/arch/alpha/kernel/traps.c~dump-stack	Mon Sep  9 12:24:43 2002
+++ 2.5.34-akpm/arch/alpha/kernel/traps.c	Mon Sep  9 12:24:43 2002
@@ -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)
 {
--- 2.5.34/arch/cris/kernel/traps.c~dump-stack	Mon Sep  9 12:24:43 2002
+++ 2.5.34-akpm/arch/cris/kernel/traps.c	Mon Sep  9 12:24:43 2002
@@ -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)
 {
--- 2.5.34/arch/i386/kernel/traps.c~dump-stack	Mon Sep  9 12:24:43 2002
+++ 2.5.34-akpm/arch/i386/kernel/traps.c	Mon Sep  9 12:24:43 2002
@@ -207,6 +207,14 @@ void show_stack(unsigned long * esp)
 	show_trace(esp);
 }
 
+/*
+ * The architecture-independent backtrace generator
+ */
+void dump_stack(void)
+{
+	show_stack(0);
+}
+
 void show_registers(struct pt_regs *regs)
 {
 	int i;
--- 2.5.34/fs/buffer.c~dump-stack	Mon Sep  9 12:24:43 2002
+++ 2.5.34-akpm/fs/buffer.c	Mon Sep  9 12:24:43 2002
@@ -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);
 
--- 2.5.34/include/linux/kernel.h~dump-stack	Mon Sep  9 12:24:43 2002
+++ 2.5.34-akpm/include/linux/kernel.h	Mon Sep  9 12:24:43 2002
@@ -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)
--- 2.5.34/kernel/ksyms.c~dump-stack	Mon Sep  9 12:24:43 2002
+++ 2.5.34-akpm/kernel/ksyms.c	Mon Sep  9 12:24:43 2002
@@ -609,3 +609,6 @@ EXPORT_SYMBOL(pidhash);
 #if defined(CONFIG_SMP) && defined(__GENERIC_PER_CPU)
 EXPORT_SYMBOL(__per_cpu_offset);
 #endif
+
+/* debug */
+EXPORT_SYMBOL(dump_stack);
--- /dev/null	Thu Aug 30 13:30:55 2001
+++ 2.5.34-akpm/lib/dump_stack.c	Mon Sep  9 12:24:43 2002
@@ -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");
+}
--- 2.5.34/lib/Makefile~dump-stack	Mon Sep  9 12:24:43 2002
+++ 2.5.34-akpm/lib/Makefile	Mon Sep  9 12:24:43 2002
@@ -12,7 +12,7 @@ export-objs := cmdline.o dec_and_lock.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

.

  reply	other threads:[~2002-09-10  0:57 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-09 22:17 [BK PATCH] USB changes for 2.5.34 Greg KH
2002-09-10  0:17 ` Linus Torvalds
2002-09-10  0:19   ` Greg KH
2002-09-10  0:30     ` Linus Torvalds
2002-09-10  0:40       ` [linux-usb-devel] " Alan Cox
2002-09-10  1:41         ` Linus Torvalds
2002-09-10  1:48           ` Linus Torvalds
2002-09-10 10:23     ` Andries Brouwer
2002-09-10  0:35   ` Nicholas Miell
2002-09-10  1:01     ` Andrew Morton [this message]
2002-09-15  4:34       ` [patch] dump_stack(): arch-neutral stack trace Daniel Phillips
2002-09-15  4:51         ` Andrew Morton
2002-09-10  1:27     ` [BK PATCH] USB changes for 2.5.34 Linus Torvalds
2002-09-10  2:07   ` Matthew Dharm
2002-09-10  2:49     ` Linus Torvalds
2002-09-10  2:59       ` Linus Torvalds
2002-09-10 16:32       ` [linux-usb-devel] " David Brownell
2002-09-10 16:51         ` Linus Torvalds
2002-09-10 17:16           ` Jeff Garzik
2002-09-10 18:16             ` David S. Miller
2002-09-10 18:40               ` Linus Torvalds
2002-09-10 18:48                 ` Jeff Garzik
2002-09-10 19:31                 ` David S. Miller
2002-09-10 19:32                 ` Oliver Xymoron
2002-09-10 19:38                   ` Linus Torvalds
2002-09-10 19:43                     ` Jeff Garzik
2002-09-10 21:52                   ` Bill Davidsen
2002-09-10 22:02                     ` Jeff Garzik
2002-09-10 18:44           ` Alan Cox
2002-09-10 19:03             ` Linus Torvalds
2002-09-10 19:27               ` Rik van Riel
2002-09-10 20:18                 ` Alan Cox
2002-09-10 22:00                   ` David Woodhouse
2002-09-10 22:23                     ` Alan Cox
2002-09-10 22:26                       ` David Woodhouse
2002-09-10 23:01                         ` Alan Cox
2002-09-10 19:29               ` David S. Miller
2002-09-15  5:10               ` Daniel Phillips
2002-09-15  5:33                 ` Daniel Berlin
2002-09-15 16:41                   ` Daniel Phillips
2002-09-16  0:32                     ` Horst von Brand
2002-09-15  6:07                 ` Pete Zaitcev
2002-09-15  7:00                   ` Andrew Morton
2002-09-15 20:05                     ` David Woodhouse
2002-09-15 14:53                   ` Daniel Phillips
2002-09-15 18:23                     ` Pete Zaitcev
2002-09-15 18:34                       ` Jeff Garzik
2002-09-16  0:55                         ` Larry McVoy
2002-09-15 21:35                   ` Rob Landley
2002-09-16  3:00                     ` Larry McVoy
2002-09-16  3:08                       ` Daniel Phillips
2002-09-16 11:16                       ` Henning P. Schmiedehausen
2002-09-16 18:35                       ` Thunder from the hill
2002-09-16 18:45                         ` Daniel Phillips
2002-09-16 19:36                           ` Thunder from the hill
2002-09-16 19:40                             ` Daniel Phillips
2002-09-16  8:50                     ` Ian Molton
2002-09-16  9:37                       ` Rob Landley
2002-09-15 18:06                 ` Linus Torvalds
2002-09-15 18:36                   ` Roman Zippel
2002-09-15 19:04                   ` Daniel Jacobowitz
2002-09-15 19:43                     ` Andrew Morton
2002-09-15 19:43                       ` Daniel Phillips
2002-09-15 23:24                     ` Larry McVoy
2002-09-15 23:41                       ` Daniel Jacobowitz
2002-09-15 23:52                         ` Larry McVoy
2002-09-16  0:01                           ` Robert Love
2002-09-16  1:29                           ` Alan Cox
2002-09-16  2:13                             ` Larry McVoy
2002-09-16 11:05                               ` Henning P. Schmiedehausen
2002-09-16 14:05                               ` Rogier Wolff
2002-09-16 16:24                               ` Marco Colombo
2002-09-16  0:44                       ` Daniel Phillips
2002-09-16  1:23                       ` Alan Cox
2002-09-15 19:07                   ` Daniel Phillips
2002-09-16  9:06                     ` Jens Axboe
2002-09-16 14:14                       ` David Woodhouse
2002-09-16 14:53                         ` Jens Axboe
2002-09-16 15:15                       ` Daniel Phillips
2002-09-16 15:59                         ` kernel debuggers was [Re: [linux-usb-devel] Re: [BK PATCH] USB changes for 2.5.34] Soewono Effendi
2002-09-15 19:08                   ` [linux-usb-devel] Re: [BK PATCH] USB changes for 2.5.34 Linus Torvalds
2002-09-15 19:10                     ` Daniel Phillips
2002-09-15 19:26                       ` Linus Torvalds
2002-09-15 19:32                         ` Daniel Jacobowitz
2002-09-15 19:48                           ` Daniel Phillips
2002-09-16  4:59                             ` Jeff Dike
2002-09-16  4:05                               ` Daniel Phillips
2002-09-16  4:55                           ` Jeff Dike
2002-09-15 19:35                         ` Daniel Phillips
2002-09-16  4:51                       ` Jeff Dike
2002-09-16 15:29                     ` Oliver Xymoron
2002-09-18  0:33                   ` Rusty Russell
2002-09-18  0:46                     ` Linus Torvalds
2002-09-18  0:50                       ` Daniel Phillips
2002-09-18  1:16                         ` Rik van Riel
2002-09-15 13:54               ` Rogier Wolff
2002-09-15  5:01           ` Daniel Phillips
2002-09-10 16:46       ` Thunder from the hill
2002-09-10 16:56         ` Vojtech Pavlik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D7D447B.D7BD1C33@digeo.com \
    --to=akpm@digeo.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=nmiell@attbi.com \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox