summaryrefslogtreecommitdiffstats
path: root/sys/ddb
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2011-04-05 14:15:58 +0000
committerattilio <attilio@FreeBSD.org>2011-04-05 14:15:58 +0000
commitd61e0853481197f3bed84fdcb57a9a74deb3e549 (patch)
treeca16d52af1207bb77508accdb2cd13cd4b3c4c44 /sys/ddb
parentd8728201a117b1b54eec2b3519f7b2665de6ac67 (diff)
downloadFreeBSD-src-d61e0853481197f3bed84fdcb57a9a74deb3e549.zip
FreeBSD-src-d61e0853481197f3bed84fdcb57a9a74deb3e549.tar.gz
Extend the DDB command "watchdog" with the ability to specify a timeout
value. The timeout is expressed in the form T(N) = (2^N * nanoseconds) and can be easilly extracted from the watchdog interface as a WD_TO_* macro. That new functionality is supposed to fix re-entering the kernel from DDB re-enabling the watchdog again (previously disabled) and also offer the possibility to break for deadlocked DDB commands. Please note that retro-compatibility is retained. Sponsored by: Sandvine Incorporated Approved by: des MFC after: 10 days
Diffstat (limited to 'sys/ddb')
-rw-r--r--sys/ddb/db_command.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index ba9c094..d8c8cb0 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -129,7 +129,7 @@ static struct command db_cmds[] = {
{ "reboot", db_reset, 0, 0 },
{ "reset", db_reset, 0, 0 },
{ "kill", db_kill, CS_OWN, 0 },
- { "watchdog", db_watchdog, 0, 0 },
+ { "watchdog", db_watchdog, CS_OWN, 0 },
{ "thread", db_set_thread, CS_OWN, 0 },
{ "run", db_run_cmd, CS_OWN, 0 },
{ "script", db_script_cmd, CS_OWN, 0 },
@@ -708,15 +708,32 @@ db_watchdog(dummy1, dummy2, dummy3, dummy4)
db_expr_t dummy3;
char * dummy4;
{
- int i;
+ db_expr_t old_radix, tout;
+ int err, i;
- /*
- * XXX: It might make sense to be able to set the watchdog to a
- * XXX: timeout here so that failure or hang as a result of subsequent
- * XXX: ddb commands could be recovered by a reset.
- */
+ old_radix = db_radix;
+ db_radix = 10;
+ err = db_expression(&tout);
+ db_skip_to_eol();
+ db_radix = old_radix;
- EVENTHANDLER_INVOKE(watchdog_list, 0, &i);
+ /* If no argument is provided the watchdog will just be disabled. */
+ if (err == 0) {
+ db_printf("No argument provided, disabling watchdog\n");
+ tout = 0;
+ } else if ((tout & WD_INTERVAL) == WD_TO_NEVER) {
+ db_error("Out of range watchdog interval\n");
+ return;
+ } else {
+
+ /*
+ * XXX: Right now we only support WD_ACTIVE, in the future we
+ * may be possibly needing a more convoluted function for
+ * dealing with different cases.
+ */
+ tout |= WD_ACTIVE;
+ }
+ EVENTHANDLER_INVOKE(watchdog_list, tout, &i);
}
static void
OpenPOWER on IntegriCloud