This patch series adds config options which can be set during compile to direct the compiler to output a breakpoint instruction anywhere a BUG() or WARN() macro has been placed in the kernel to trigger the system to enter a debugger if a bug is detected by the system. Use of this compile time option also allows conditional breakpoints to be set in the kernel with these currently used macros.
This addition is extremely useful for debugging hard and soft lockups real time and quickly from a console debugger, and other areas of the kernel. Signed-off-by: Jeffrey Merkey <jeffmer...@gmail.com> --- include/linux/printk.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/printk.h b/include/linux/printk.h index 51dd6b8..dcfb270 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -252,8 +252,16 @@ extern asmlinkage void dump_stack(void) __cold; * and other debug macros are compiled out unless either DEBUG is defined * or CONFIG_DYNAMIC_DEBUG is set. */ +#ifdef CONFIG_DEBUG_WARN +#define pr_emerg(fmt, ...) \ +({ \ + printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__); \ + BUG(); \ +}) +#else #define pr_emerg(fmt, ...) \ printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) +#endif #define pr_alert(fmt, ...) \ printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) #define pr_crit(fmt, ...) \ -- 1.8.3.1