Messages in this thread Patch in this message | | | Date | Mon, 27 Jun 2005 15:27:50 +0300 (EEST) | From | Pekka J Enberg <> | Subject | [PATCH] verbose BUG_ON reporting |
| |
On Mon, 27 Jun 2005, Andi Kleen wrote: > It won't work for me because it'll bloat the kernel .text > considerable. There is a reason why BUG is implemented > like it is. Compare it.
The assertion codes bloat the kernel all the same. So how about this instead?
This patch adds a CONFIG_DEBUG_BUG_ON_VERBOSE that makes BUG_ON report the evaluated expression in human readable form when the assertion fails.
The size of vmlinux with allyesconfig increases about 100k when the config option is enabled:
text data bss dec filename 19333351 6699691 1845604 27878646 vmlinux-2.6.12-git8 19434139 6699691 1845604 27979434 vmlinux-2.6.12-git8-verbose-bug_on
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> ---
include/asm-generic/bug.h | 11 ++++++++++- lib/Kconfig.debug | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
Index: 2.6/include/asm-generic/bug.h =================================================================== --- 2.6.orig/include/asm-generic/bug.h +++ 2.6/include/asm-generic/bug.h @@ -12,8 +12,17 @@ } while (0) #endif +#ifdef CONFIG_DEBUG_BUG_ON_VERBOSE +#define FAIL_BUG_ON(expr_str) do { \ + printk("BUG_ON(%s) failed.\n", expr_str); \ + BUG(); \ +} while (0) +#else +#define FAIL_BUG_ON(expr_str) BUG() +#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)) FAIL_BUG_ON(#condition); } while(0) #endif #ifndef HAVE_ARCH_WARN_ON Index: 2.6/lib/Kconfig.debug =================================================================== --- 2.6.orig/lib/Kconfig.debug +++ 2.6/lib/Kconfig.debug @@ -116,6 +116,13 @@ config DEBUG_BUGVERBOSE of the BUG call as well as the EIP and oops trace. This aids debugging but costs about 70-100K of memory. +config DEBUG_BUG_ON_VERBOSE + bool "Verbose BUG_ON() reporting" + depends on DEBUG_KERNEL && BUG + default false + help + Say Y here to make BUG_ON() panics output the evaluated expression. + config DEBUG_INFO bool "Compile the kernel with debug info" depends on DEBUG_KERNEL - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |