public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeffrey Merkey <jeffmerkey@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Jason@zx2c4.com, aconole@redhat.com, akpm@linux-foundation.org,
	andriy.shevchenko@linux.intel.com, jeffmerkey@gmail.com,
	linus.walleij@linaro.org, nicolas.iooss_linux@m4x.org,
	pmladek@suse.com, rostedt@goodmis.org, tj@kernel.org
Subject: [PATCH v4 4/4] pr_emerg add WARN_XX() debugger options
Date: Mon,  1 Feb 2016 16:35:52 -0700	[thread overview]
Message-ID: <1454369752-20706-4-git-send-email-jeffmerkey@gmail.com> (raw)
In-Reply-To: <1454369752-20706-1-git-send-email-jeffmerkey@gmail.com>

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 <jeffmerkey@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

  parent reply	other threads:[~2016-02-01 23:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 23:35 [PATCH v4 1/4] Add BUG_XX() debugging options Jeffrey Merkey
2016-02-01 23:35 ` [PATCH v4 2/4] Add WARN_XX() " Jeffrey Merkey
2016-02-01 23:35 ` [PATCH v4 3/4] Add BUG_XX() and " Jeffrey Merkey
2016-02-01 23:35 ` Jeffrey Merkey [this message]
2016-02-02  1:58   ` [PATCH v4 4/4] pr_emerg add WARN_XX() debugger options Steven Rostedt
2016-02-02  2:01     ` Jeffrey Merkey
2016-02-02 19:40       ` Maciej W. Rozycki
2016-02-02 22:18         ` Jeffrey Merkey

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=1454369752-20706-4-git-send-email-jeffmerkey@gmail.com \
    --to=jeffmerkey@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=aconole@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.iooss_linux@m4x.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=tj@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