From nobody@FreeBSD.org  Sat Jan 26 07:38:59 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A088416A417
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Jan 2008 07:38:59 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 87E2013C45B
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Jan 2008 07:38:59 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m0Q7bK6S023771
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Jan 2008 07:37:20 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m0Q7bKAc023770;
	Sat, 26 Jan 2008 07:37:20 GMT
	(envelope-from nobody)
Message-Id: <200801260737.m0Q7bKAc023770@www.freebsd.org>
Date: Sat, 26 Jan 2008 07:37:20 GMT
From: Scot Hetzel <swhetzel@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] New rc.d script ddb to load ddb scripts from /etc/ddb.conf
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         119995
>Category:       conf
>Synopsis:       [patch] New rc.d script ddb to load ddb scripts from /etc/ddb.conf
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brooks
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 26 07:40:00 UTC 2008
>Closed-Date:    Wed Mar 05 19:29:14 UTC 2008
>Last-Modified:  Thu Apr  3 21:40:02 UTC 2008
>Originator:     Scot Hetzel
>Release:        8.0-CURRENT
>Organization:
>Environment:
FreeBSD hp010.hetzel.org 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sat Jan 19 00:03:54 CST 2008     root@hp010.hetzel.org:/usr/src/sys/amd64/compile/DV8135NR  amd64

>Description:
Currently, ddb scripts can only be loaded after the login prompt is shown and the administrator has logged into a system.  There is no mechanism to load a ddb script at boot time.

The attach patch solves this problem by creating /etc/rc.d/ddb.  rc.d/ddb then reads the ddb scripts from /etc/ddb.conf and uses /sbin/ddb to create each script.

The format of the ddb.conf file is:

<scriptname>=<scriptvalue>

<scriptname> must be less than 32 characters (31 max)
<scriptvalue> must be less than 120 characters (119 max)

<scriptvalue>=<ddb command>[; <ddb command>]||[; run <script name>]...

To get around the 119 character limit, define a script that is run from the main script as shown below:

lockinfo=show locks; show alllocks; show lockedvnods

kdb.enter.panic=textdump set; capture on; bt; run lockinfo; capture off; call doadump; reset

NOTE: These limits are releate to ddb scripting and not the rc.d/ddb script.
>How-To-Repeat:
Boot computer then use /sbin/ddb script to load each script individually.
>Fix:
The attached patch creates a /etc/rc.d/ddb script that reads /etc/ddb.conf to load the ddb scripts after the dump device has been defined.

Patch attached with submission follows:

Index: etc/Makefile
===================================================================
RCS file: /home/ncvs/src/etc/Makefile,v
retrieving revision 1.365
diff -u -r1.365 Makefile
--- etc/Makefile	11 Nov 2007 01:16:51 -0000	1.365
+++ etc/Makefile	26 Jan 2008 06:43:34 -0000
@@ -7,8 +7,8 @@
 SUBDIR=	sendmail
 .endif
 
 BIN1=	amd.map apmd.conf auth.conf \
-	crontab csh.cshrc csh.login csh.logout devd.conf devfs.conf \
+	crontab csh.cshrc csh.login csh.logout ddb.conf devd.conf devfs.conf \
 	dhclient.conf disktab fbtab freebsd-update.conf \
 	ftpusers gettytab group \
 	hosts hosts.allow hosts.equiv hosts.lpd \
@@ -207,7 +207,7 @@
 .if ${MK_SENDMAIL} != "no"
 	mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/mtree/BSD.sendmail.dist -p ${DESTDIR}/
 .endif
-	cd ${DESTDIR}/; rm -f ${DESTDIR}/sys; ln -s usr/src/sys sys
+	cd ${DESTDIR}/; rm -f ${DESTDIR}/sys; ln -s ${SYSDIR} sys
 	cd ${DESTDIR}/usr/share/man/en.ISO8859-1; ln -sf ../man* .
 	cd ${DESTDIR}/usr/share/man; \
 	set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \
Index: etc/ddb.conf
===================================================================
RCS file: etc/ddb.conf
diff -N etc/ddb.conf
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/ddb.conf	26 Jan 2008 06:42:16 -0000
@@ -0,0 +1,14 @@
+# $FreeBSD$
+#
+#  This file is read when going to multi-user and its contents piped thru
+#  ``ddb'' to define debugging scripts.
+#
+# see ``man 4 ddb'' and ``man 8 ddb'' for details.
+#
+
+
+lockinfo=show locks; show alllocks; show lockedvnods
+
+# kdb.enter.panic	  panic(9) was called.
+#kdb.enter.panic=textdump set; capture on; run lockinfo; show pcpu; bt; ps; alltrace; capture off; call doadump; reset
+
Index: etc/rc.d/Makefile
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/Makefile,v
retrieving revision 1.88
diff -u -r1.88 Makefile
--- etc/rc.d/Makefile	8 Dec 2007 07:20:22 -0000	1.88
+++ etc/rc.d/Makefile	26 Jan 2008 06:47:23 -0000
@@ -7,7 +7,7 @@
 	apm apmd archdep atm1 atm2 atm3 auditd auto_linklocal \
 	bgfsck bluetooth bootparams bridge bsnmpd bthidd \
 	ccd cleanvar cleartmp cron \
-	devd devfs dhclient \
+	ddb devd devfs dhclient \
 	dmesg dumpon \
 	early.sh encswap \
 	fsck ftp-proxy ftpd \
Index: etc/rc.d/ddb
===================================================================
RCS file: etc/rc.d/ddb
diff -N etc/rc.d/ddb
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/rc.d/ddb	26 Jan 2008 06:37:35 -0000
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: ddb
+# REQUIRE: dumpon
+# BEFORE: disks savecore initrandom
+# KEYWORD: nojail
+
+. /etc/rc.subr
+
+name="ddb"
+stop_cmd=":"
+start_cmd="ddb_start"
+reload_cmd="ddb_start"
+extra_commands="reload"
+
+ddb_start()
+{
+	#
+	# Read in /etc/sysctl.conf and set things accordingly
+	#
+	if [ -f /etc/ddb.conf ]; then
+		while read var
+		do
+			case ${var} in
+			\#*|'')
+				;;
+			*)
+				mib=${var%=*}
+				val=${var#*=}
+
+				/sbin/ddb script ${mib}="${val}"
+				;;
+			esac
+		done < /etc/ddb.conf
+	fi
+}
+
+load_rc_config $name
+run_rc_command "$1"


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Jan 26 08:13:58 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=119995 

From: Robert Watson <rwatson@FreeBSD.org>
To: Brooks Davis <brooks@freebsd.org>
Cc: Doug Barton <dougb@freebsd.org>, freebsd-bugs@freebsd.org, 
    freebsd-rc@freebsd.org, bug-followup@FreeBSD.org
Subject: Re: conf/119995: [patch] New rc.d script ddb to load ddb scripts
 from /etc/ddb.conf
Date: Sat, 26 Jan 2008 22:41:13 +0000 (GMT)

 On Sat, 26 Jan 2008, Brooks Davis wrote:
 
 > IMO we want this in the base and ideally this script or the crash dump 
 > script would grow the option to mail text dumps somewhere automatically (off 
 > by default of course).  This should be as tightly integrated as we can 
 > reasonably make it.
 
 I think I'd like to see something along these lines in the base, as 
 offering tools to help autonatically configure DDB scripting isn't all that 
 different from offering tools to configure firewalls, run user scripts, etc.
 
 However, I wonder if we should consider doing it slightly differently than 
 proposed.  One of the things I like about the way we do ipfw rulesets is that 
 we allow a filename to be specified that contains a series of commands to pass 
 to the ipfw command-line tool, rather than a file that contains a list of 
 rules.  This means that as the ipfw tool becomes more capable, the 
 configuration file supports those changes in a natural way.  I.e., rather than 
 having ddb.conf contain:
 
    scriptname="foo bar baz"
 
 It should perhaps instead contain:
 
    script scriptname="foo bar baz"
 
 We will need to teach ddb(8) to do this in a similar manner to ipfw(8).
 
 Robert N M Watson
 Computer Laboratory
 University of Cambridge

From: Doug Barton <dougb@FreeBSD.org>
To: Robert Watson <rwatson@FreeBSD.org>
Cc: Brooks Davis <brooks@freebsd.org>, freebsd-bugs@freebsd.org, 
 freebsd-rc@freebsd.org, bug-followup@FreeBSD.org
Subject: Re: conf/119995: [patch] New rc.d script ddb to load ddb scripts
 from /etc/ddb.conf
Date: Sat, 26 Jan 2008 15:48:30 -0800

 Robert Watson wrote:
 > 
 > On Sat, 26 Jan 2008, Brooks Davis wrote:
 > 
 >> IMO we want this in the base and ideally this script or the crash dump
 >> script would grow the option to mail text dumps somewhere
 >> automatically (off by default of course).  This should be as tightly
 >> integrated as we can reasonably make it.
 > 
 > I think I'd like to see something along these lines in the base, as
 > offering tools to help autonatically configure DDB scripting isn't all
 > that different from offering tools to configure firewalls, run user
 > scripts, etc.
 
 I see a fairly significant difference, namely that the other things
 you mentioned are things that we expect all of our users to be able to
 and/or want to do. No one wants to debug crash dumps. :)
 
 But seriously folks, I said I have no objection if this goes in, I
 just think we're heading in a dangerous direction when we start
 throwing everything in that _could_ go in. I want to be sure that we
 have a compelling reason that it _should_ go in first. If you think we
 have one, go for it.
 
 FWIW I think Robert's on the right track in terms of making the
 functionality more flexible. No need to include me on the followup
 discussions though, I'll watch this one on the list.
 
 Doug
 
 -- 
 
     This .signature sanitized for your protection
 

From: Brooks Davis <brooks@freebsd.org>
To: freebsd-rc@freebsd.org
Cc: Robert Watson <rwatson@freebsd.org>, freebsd-bugs@freebsd.org,
        bug-followup@freebsd.org
Subject: Re: conf/119995: [patch] New rc.d script ddb to load ddb scripts
	from /etc/ddb.conf
Date: Sat, 26 Jan 2008 18:54:08 -0600

 --c3bfwLpm8qysLVxt
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Sat, Jan 26, 2008 at 03:48:30PM -0800, Doug Barton wrote:
 > Robert Watson wrote:
 > >=20
 > > On Sat, 26 Jan 2008, Brooks Davis wrote:
 > >=20
 > >> IMO we want this in the base and ideally this script or the crash dump
 > >> script would grow the option to mail text dumps somewhere
 > >> automatically (off by default of course).  This should be as tightly
 > >> integrated as we can reasonably make it.
 > >=20
 > > I think I'd like to see something along these lines in the base, as
 > > offering tools to help autonatically configure DDB scripting isn't all
 > > that different from offering tools to configure firewalls, run user
 > > scripts, etc.
 >=20
 > I see a fairly significant difference, namely that the other things
 > you mentioned are things that we expect all of our users to be able to
 > and/or want to do. No one wants to debug crash dumps. :)
 
 I think you've misunderstood what we're suggesting.  What all our users
 want is to never run into any bugs and failing that to have a fix
 magically appear the moment they do hit one. :)  I think this another
 step toward more reliably providing developers the information they need
 to discover and fix bugs that users hit.  I'd venture to say that 80-90%
 of panic reports we receive are useless because we don't have what we
 need to do anything with them and this is a step toward resolving that.
 I'd really like to see 8.0 ship with textdumps on by default.
 
 -- Brooks
 
 --c3bfwLpm8qysLVxt
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (FreeBSD)
 
 iD8DBQFHm9YvXY6L6fI4GtQRAhE1AKCLw4WVAHcXEkIGsZ2Gbim/glj9lwCgzq1C
 HC2LuHW332Ulum9MHDzUiKU=
 =+mjp
 -----END PGP SIGNATURE-----
 
 --c3bfwLpm8qysLVxt--

From: Doug Barton <dougb@FreeBSD.org>
To: Brooks Davis <brooks@freebsd.org>
Cc: freebsd-rc@freebsd.org, freebsd-bugs@freebsd.org, 
 Robert Watson <rwatson@freebsd.org>,
 bug-followup@freebsd.org
Subject: Re: conf/119995: [patch] New rc.d script ddb to load ddb scripts
 from /etc/ddb.conf
Date: Sat, 26 Jan 2008 21:41:42 -0800

 Brooks Davis wrote:
 
 > I think you've misunderstood what we're suggesting. 
 
 I understand perfectly what you're suggesting, and why you're
 suggesting it. I just don't agree with you. However, as I said I am
 not going to object to including it in the base, I just wanted to
 state an opinion. It's ok with me if no one shares it. :)
 
 Doug
 
 -- 
 
     This .signature sanitized for your protection
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/119995: commit references a PR
Date: Wed,  5 Mar 2008 18:33:07 +0000 (UTC)

 brooks      2008-03-05 18:32:58 UTC
 
   FreeBSD src repository
 
   Modified files:
     share/man/man5       rc.conf.5 
     etc                  Makefile 
     etc/defaults         rc.conf 
     etc/rc.d             Makefile 
   Added files:
     etc                  ddb.conf 
     etc/rc.d             ddb 
   Log:
   Use the new command file feature of ddb(8) to support setting ddb(4)
   scripts at boot.  This is currently disabled by default. /etc/ddb.conf
   contains some potentially reasonable default scripts.
   
   PR:             conf/119995
   Submitted by:   Scot Hetzel <swhetzel at gmail dot com> (Earlier version)
   X-MFC after:    textdumps
   
   Revision  Changes    Path
   1.366     +1 -1      src/etc/Makefile
   1.1       +15 -0     src/etc/ddb.conf (new)
   1.327     +2 -0      src/etc/defaults/rc.conf
   1.89      +1 -1      src/etc/rc.d/Makefile
   1.1       +32 -0     src/etc/rc.d/ddb (new)
   1.335     +13 -0     src/share/man/man5/rc.conf.5
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: brooks 
State-Changed-When: Wed Mar 5 18:59:58 UTC 2008 
State-Changed-Why:  
Committed to head. 


Responsible-Changed-From-To: freebsd-rc->brooks 
Responsible-Changed-By: brooks 
Responsible-Changed-When: Wed Mar 5 18:59:58 UTC 2008 
Responsible-Changed-Why:  
Committed to head. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=119995 
State-Changed-From-To: patched->closed 
State-Changed-By: brooks 
State-Changed-When: Wed Mar 5 19:28:01 UTC 2008 
State-Changed-Why:  
On second thought, this can't be MFCd until textdumps are so  
there's no point in leaving this open. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=119995 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/119995: commit references a PR
Date: Thu,  3 Apr 2008 21:36:21 +0000 (UTC)

 brooks      2008-04-03 21:36:12 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     etc                  Makefile 
     etc/defaults         rc.conf 
     etc/rc.d             Makefile 
     share/man/man5       rc.conf.5 
   Added files:           (Branch: RELENG_7)
     etc                  ddb.conf 
     etc/rc.d             ddb 
   Log:
   MFC:
   
   Use the new command file feature of ddb(8) to support setting ddb(4)
   scripts at boot.  This is currently disabled by default. /etc/ddb.conf
   contains some potentially reasonable default scripts.
   
   PR:             conf/119995
   Submitted by:   Scot Hetzel <swhetzel at gmail dot com> (Earlier version)
   
   Revision   Changes    Path
   1.360.2.4  +1 -1      src/etc/Makefile
   1.1.2.1    +15 -0     src/etc/ddb.conf (new)
   1.318.2.6  +2 -0      src/etc/defaults/rc.conf
   1.84.2.3   +1 -1      src/etc/rc.d/Makefile
   1.1.2.1    +32 -0     src/etc/rc.d/ddb (new)
   1.327.2.3  +13 -0     src/share/man/man5/rc.conf.5
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
