summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_shutdown.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-12-26 11:32:33 +0000
committerrwatson <rwatson@FreeBSD.org>2007-12-26 11:32:33 +0000
commit956e2983bab12b8a6ee25b06ca978419483ff488 (patch)
treea187b11df8e49734230bd533f4a9b7b1ba04d6ff /sys/kern/kern_shutdown.c
parent26435e9b8db00f61f14db439ebe23a6bf26e2817 (diff)
downloadFreeBSD-src-956e2983bab12b8a6ee25b06ca978419483ff488.zip
FreeBSD-src-956e2983bab12b8a6ee25b06ca978419483ff488.tar.gz
Add textdump(4) facility, which provides an alternative form of kernel
dump using mechanically generated/extracted debugging output rather than a simple memory dump. Current sources of debugging output are: - DDB output capture buffer, if there is captured output to save - Kernel message buffer - Kernel configuration, if included in kernel - Kernel version string - Panic message Textdumps are stored in swap/dump partitions as with regular dumps, but are laid out as ustar files in order to allow multiple parts to be stored as a stream of sequentially written blocks. Blocks are written out in reverse order, as the size of a textdump isn't known a priori. As with regular dumps, they will be extracted using savecore(8). One new DDB(4) command is added, "textdump", which accepts "set", "unset", and "status" arguments. By default, normal kernel dumps are generated unless "textdump set" is run in order to schedule a textdump. It can be canceled using "textdump unset" to restore generation of a normal kernel dump. Several sysctls exist to configure aspects of textdumps; debug.ddb.textdump.pending can be set to check whether a textdump is pending, or set/unset in order to control whether the next kernel dump will be a textdump from userspace. While textdumps don't have to be generated as a result of a DDB script run automatically as part of a kernel panic, this is a particular useful way to use them, as instead of generating a complete memory dump, a simple transcript of an automated DDB session can be captured using the DDB output capture and textdump facilities. This can be used to generate quite brief kernel bug reports rich in debugging information but not dependent on kernel symbol tables or precisely synchronized source code. Most textdumps I generate are less than 100k including the full message buffer. Using textdumps with an interactive debugging session is also useful, with capture being enabled/disabled in order to record some but not all of the DDB session. MFC after: 3 months
Diffstat (limited to 'sys/kern/kern_shutdown.c')
-rw-r--r--sys/kern/kern_shutdown.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index baeed23..7bbd98f 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -37,6 +37,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_ddb.h"
#include "opt_kdb.h"
#include "opt_mac.h"
#include "opt_panic.h"
@@ -64,6 +65,8 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/sysproto.h>
+#include <ddb/ddb.h>
+
#include <machine/cpu.h>
#include <machine/pcb.h>
#include <machine/smp.h>
@@ -240,7 +243,12 @@ doadump(void)
savectx(&dumppcb);
dumptid = curthread->td_tid;
dumping++;
- dumpsys(&dumper);
+#ifdef DDB
+ if (textdump_pending)
+ textdump_dumpsys(&dumper);
+ else
+#endif
+ dumpsys(&dumper);
}
static int
OpenPOWER on IntegriCloud