xref: /freebsd/share/man/man4/textdump.4 (revision faf25f48d601ae39f5752602f3020e2e92605625)
1.\"
2.\" Copyright (c) 2007 Robert N. M. Watson
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice(s), this list of conditions and the following disclaimer as
10.\"    the first lines of this file unmodified other than the possible
11.\"    addition of one or more copyright notices.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice(s), this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
20.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26.\" DAMAGE.
27.\"
28.\" $FreeBSD$
29.\"
30.Dd October 18, 2019
31.Dt TEXTDUMP 4
32.Os
33.Sh NAME
34.Nm textdump
35.Nd textdump kernel dumping facility
36.Sh SYNOPSIS
37.Cd options DDB
38.Cd options KDB
39.Pp
40.Cd options TEXTDUMP_PREFERRED
41.Cd options TEXTDUMP_VERBOSE
42.Sh DESCRIPTION
43The
44.Nm
45facility allows the capture of kernel debugging information to disk in a
46human-readable rather than the machine-readable form normally used with
47kernel memory dumps and minidumps.
48This representation, while less complete in that it does not capture full
49kernel state, can provide debugging information in a more compact, portable,
50and persistent form than a traditional dump.
51By combining
52.Nm
53with other
54.Xr ddb 4
55facilities, such as scripting and output capture, detailed bug information
56can be captured in a fully automated manner.
57.Sh FORMAT
58.Nm
59data is stored in a dump partition in the same style as a regular memory
60dump, and will be automatically extracted by
61.Xr savecore 8
62if present on boot.
63.Pp
64.Nm
65files are stored in the
66.Xr tar 5
67format, and consist of one or more text files, each storing a particular type
68of debugging output.
69The following parts may be present:
70.Bl -tag -width version.txt
71.It Pa ddb.txt
72Captured
73.Xr ddb 4
74output, if the capture facility has been used.
75May be disabled by clearing the
76.Va debug.ddb.textdump.do_ddb
77sysctl.
78.It Pa config.txt
79Kernel configuration, if
80.Cd options INCLUDE_CONFIG_FILE
81has been compiled into the kernel.
82May be disabled by clearing the
83.Va debug.ddb.textdump.do_config
84sysctl.
85.It Pa msgbuf.txt
86Kernel message buffer, including recent console output if the capture
87facility has been used.
88May be disabled by clearing the
89.Va debug.ddb.textdump.do_msgbuf
90sysctl.
91.It Pa panic.txt
92Kernel panic string, if the kernel panicked before the dump was generated.
93May be disabled by clearing the
94.Va debug.ddb.textdump.do_panic
95sysctl.
96.It Pa version.txt
97Kernel version string.
98My be disabled by clearing the
99.Va debug.ddb.textdump.do_version
100sysctl.
101.El
102.Pp
103Kernel textdumps may be extracted using
104.Xr tar 1 .
105.Sh CONFIGURATION
106The
107.Nm
108facility is enabled as part of the kernel debugger using
109.Cd options KDB
110and
111.Cd options DDB .
112By default, kernel dumps generated on panic or via explicit requests for a
113dump will be regular memory dumps; however, by using the
114.Ic textdump set
115command in
116.Xr ddb 4 ,
117or by setting the
118.Va debug.ddb.textdump.pending
119sysctl to 1 using
120.Xr sysctl 8 ,
121it is possible to request that the next dump be a textdump.
122One may also directly trigger a textdump in
123.Xr ddb 4
124by running the command
125.Ic textdump dump .
126.Pp
127If at the
128.Xr ddb 4
129command line, the commands
130.Ic textdump set ,
131.Ic textdump status ,
132and
133.Ic textdump unset
134may be used to set, query, and clear the textdump pending flag.
135.Pp
136As with regular kernel dumps, a dump partition must be automatically or
137manually configured using
138.Xr dumpon 8 .
139.Pp
140Additional kernel
141.Xr config 8
142options:
143.Bl -tag -width TEXTDUMP_PREFERRED
144.It Cd TEXTDUMP_PREFERRED
145sets textdumps to be the default manner of doing dumps.
146This means there will be no need to
147.Xr sysctl 8
148or use the
149.Ic textdump set
150.Xr ddb 8
151commands.
152.It Cd TEXTDUMP_VERBOSE
153will have the textdump facility be more verbose about each file it is emitting
154as well as other diagnostics useful to debug the textdump facility itself.
155.El
156.Sh EXAMPLES
157In the following example, the script
158.Va kdb.enter.panic
159will run when the kernel debugger is entered as a result of a panic, enable
160output capture, dump several useful pieces of debugging information, and then
161invoke panic in order to force a kernel dump to be written out followed by a
162reboot:
163.Bd -literal -offset indent
164script kdb.enter.panic=textdump set; capture on; show allpcpu; bt;
165  ps; alltrace; show alllocks; textdump dump; reset
166.Ed
167.Pp
168In the following example, the script
169.Va kdb.enter.witness
170will run when the kernel debugger is entered as a result of a witness
171violation, printing lock-related information for the user:
172.Bd -literal -offset indent
173script kdb.enter.witness=show locks
174.Ed
175.Pp
176These scripts may also be configured using the
177.Xr ddb 8
178utility.
179.Sh SEE ALSO
180.Xr tar 1 ,
181.Xr ddb 4 ,
182.Xr tar 5 ,
183.Xr ddb 8 ,
184.Xr dumpon 8 ,
185.Xr savecore 8 ,
186.Xr sysctl 8
187.Sh HISTORY
188The
189.Nm
190facility first appeared in
191.Fx 7.1 .
192.Sh AUTHORS
193The
194.Nm
195facility was created by
196.An Robert N. M. Watson .
197