bin/119995: [patch] New rc.d script ddb to load ddb scripts from /etc/ddb.conf

Scot Hetzel swhetzel at gmail.com
Sat Jan 26 07:40:01 UTC 2008


>Number:         119995
>Category:       bin
>Synopsis:       [patch] New rc.d script ddb to load ddb scripts from /etc/ddb.conf
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 26 07:40:00 UTC 2008
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list