public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] (update) more helpful WARN_ON and BUG_ON messages
Date: Fri, 20 Oct 2006 11:54:10 -0500	[thread overview]
Message-ID: <4538FF32.8050604@sandeen.net> (raw)
In-Reply-To: <4538F81A.2070007@redhat.com>

Eric Sandeen wrote:

> After a few bugs I encountered in FC6 in buffer.c, with output like:
>
> Kernel BUG at fs/buffer.c: 2791
>
> where buffer.c contains:
>
> ...
>         BUG_ON(!buffer_locked(bh));
>         BUG_ON(!buffer_mapped(bh));
>         BUG_ON(!bh->b_end_io);
> ...
>
> around line 2790, it's awfully tedious to go get the exact failing kernel tree
> just to see -which- BUG_ON was encountered.
>
> Printing out the failing condition as a string would make this more helpful IMHO.
>
> This is mostly just compile-tested... comments?
Whoops, missed WARN_ON_ONCE... thanks Peter.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Index: linux-2.6.18/include/asm-generic/bug.h
===================================================================
--- linux-2.6.18.orig/include/asm-generic/bug.h
+++ linux-2.6.18/include/asm-generic/bug.h
@@ -12,13 +12,19 @@
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
-#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
+#define BUG_ON(condition) do { \
+	if (unlikely((condition)!=0)) { \
+		printk("BUGging on (%s)\n", #condition); \
+		BUG(); \
+	} \
+} while(0)
 #endif
 
 #ifndef HAVE_ARCH_WARN_ON
 #define WARN_ON(condition) do { \
 	if (unlikely((condition)!=0)) { \
-		printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \
+		printk("BUG: warning: (%s) at %s:%d/%s()\n", \
+			#condition, __FILE__, __LINE__, __FUNCTION__); \
 		dump_stack(); \
 	} \
 } while (0)
@@ -45,7 +51,7 @@
 							\
 	if (unlikely((condition) && __warn_once)) {	\
 		__warn_once = 0;			\
-		WARN_ON(1);				\
+		WARN_ON(condition);			\
 		__ret = 1;				\
 	}						\
 	__ret;						\



  reply	other threads:[~2006-10-20 16:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-20 16:23 [PATCH] more helpful WARN_ON and BUG_ON messages Eric Sandeen
2006-10-20 16:54 ` Eric Sandeen [this message]
2006-10-20 17:02   ` [PATCH] (update) " Peter Zijlstra
2006-10-20 19:30   ` Eric Sandeen
2006-10-20 21:16 ` [PATCH] " Jeremy Fitzhardinge
2006-10-23  3:18   ` Eric Sandeen
2006-10-20 21:41 ` Adrian Bunk
2006-10-20 21:56   ` Eric Sandeen
2006-10-20 22:07     ` Adrian Bunk
2006-10-21  2:41       ` Dave Jones

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=4538FF32.8050604@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=linux-kernel@vger.kernel.org \
    /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