From owner-svn-src-stable-8@FreeBSD.ORG Fri Apr 29 17:04:52 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 856A4106564A; Fri, 29 Apr 2011 17:04:52 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 74EE78FC14; Fri, 29 Apr 2011 17:04:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p3TH4qRU007495; Fri, 29 Apr 2011 17:04:52 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p3TH4qY3007493; Fri, 29 Apr 2011 17:04:52 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201104291704.p3TH4qY3007493@svn.freebsd.org> From: Attilio Rao Date: Fri, 29 Apr 2011 17:04:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221211 - stable/8/sys/ddb X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2011 17:04:52 -0000 Author: attilio Date: Fri Apr 29 17:04:52 2011 New Revision: 221211 URL: http://svn.freebsd.org/changeset/base/221211 Log: MFC r220362: Extend the DDB command watchdog with the ability to specify a timeout value. Modified: stable/8/sys/ddb/db_command.c Modified: stable/8/sys/ddb/db_command.c ============================================================================== --- stable/8/sys/ddb/db_command.c Fri Apr 29 16:43:30 2011 (r221210) +++ stable/8/sys/ddb/db_command.c Fri Apr 29 17:04:52 2011 (r221211) @@ -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, dumm 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