From: Douglas Anderson <dianders@chromium.org>
To: Jason Wessel <jason.wessel@windriver.com>,
Daniel Thompson <daniel.thompson@linaro.org>
Cc: briannorris@chromium.org,
Douglas Anderson <dianders@chromium.org>,
kgdb-bugreport@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: [PATCH] debug: Allow forcing entering debug mode on panic/exception
Date: Sun, 9 Dec 2018 18:36:49 -0800 [thread overview]
Message-ID: <20181210023649.229271-1-dianders@chromium.org> (raw)
Ever since commit 5516fd7b92a7 ("debug: prevent entering debug mode on
panic/exception.") (yes, years ago) my kgdb workflow has been broken.
On Chrome OS we have 'kernel.panic = -1' in
'/etc/sysctl.d/00-sysctl.conf'. That means that when userspace starts
up it will tell the kernel "please reboot on panic". ...and so when I
get a panic then the system reboots instead of letting me debug it.
While I could go in an change the 'sysctl.conf' and I could go in and
hack the kernel myself, these things are inconvenient. I either need
to keep a private kernel patch or or remember to edit a file every
time I install an updated version of Chrome OS. What is convenient
(for me) is to have a CONFIG option that makes kgdb override the panic
request. This is because the Chrome OS build system makes it very
easy for me to add some extra CONFIG "fragments" to my debug kernels.
Hopefully having this extra config option is OK and useful to others
who would also prefer to make sure that kgdb is always entered on a
panic no matter what userspace might request.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
kernel/debug/debug_core.c | 5 +++--
lib/Kconfig.kgdb | 10 ++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 65c0f1363788..d4a38543fcdd 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -703,7 +703,8 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
* reboot on panic. We don't want to get stuck waiting for input
* on such systems, especially if its "just" an oops.
*/
- if (signo != SIGTRAP && panic_timeout)
+ if (!IS_ENABLED(CONFIG_KGDB_ALWAYS_ENTER_ON_PANIC) &&
+ signo != SIGTRAP && panic_timeout)
return 1;
memset(ks, 0, sizeof(struct kgdb_state));
@@ -843,7 +844,7 @@ static int kgdb_panic_event(struct notifier_block *self,
* panic_timeout indicates the system should automatically
* reboot on panic.
*/
- if (panic_timeout)
+ if (!IS_ENABLED(CONFIG_KGDB_ALWAYS_ENTER_ON_PANIC) && panic_timeout)
return NOTIFY_DONE;
if (dbg_kdb_mode)
diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb
index ab4ff0eea776..f12c6e1394c6 100644
--- a/lib/Kconfig.kgdb
+++ b/lib/Kconfig.kgdb
@@ -67,6 +67,16 @@ config KGDB_LOW_LEVEL_TRAP
exception handler which will allow kgdb to step through a
notify handler.
+config KGDB_ALWAYS_ENTER_ON_PANIC
+ bool "KGDB: Enter kgdb on panic even if reboot specified"
+ default n
+ help
+ If kgdb is enabled and the system is configured to reboot on
+ panic then there's a question of whether we should drop into
+ kgdb on panic or whether we should reboot on panic. If you
+ say yes here then we'll enter kgdb. If you say no here then
+ we'll reboot.
+
config KGDB_KDB
bool "KGDB_KDB: include kdb frontend for kgdb"
default n
--
2.20.0.rc2.403.gdbc3b29805-goog
next reply other threads:[~2018-12-10 2:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 2:36 Douglas Anderson [this message]
2018-12-18 17:05 ` Daniel Thompson
2018-12-18 23:53 ` Doug Anderson
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=20181210023649.229271-1-dianders@chromium.org \
--to=dianders@chromium.org \
--cc=briannorris@chromium.org \
--cc=daniel.thompson@linaro.org \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.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
all inboxes | Powered by JetHome®