aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/dynamic-debug-howto.txt
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2012-04-27 16:30:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-30 16:26:30 -0400
commit29e36c9ffb696ed8d73e1aee713d483ec74a9a43 (patch)
tree1cb91235091fa9d750fd56753f6b4ffd6701ca0d /Documentation/dynamic-debug-howto.txt
parent8e59b5cfb9a6f43753236b554d785e8efca62db7 (diff)
dynamic_debug: update Documentation/*, Kconfig.debug
In dynamic-debug-howto.txt: - add section: Debug Messages at Module Initialization Time - update flags indicators in example outputs to include '=' - make flags descriptions tabular - add item on '_' flag-char - add dyndbg, boot-args examples - rewrap some paragraphs with long lines In Kconfig.debug, note that compiling with -DDEBUG enables all pr_debug()s in that code. In kernel-parameters.txt, add dyndbg and module.dyndbg items, and deprecate ddebug_query. Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Acked-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation/dynamic-debug-howto.txt')
-rw-r--r--Documentation/dynamic-debug-howto.txt184
1 files changed, 121 insertions, 63 deletions
diff --git a/Documentation/dynamic-debug-howto.txt b/Documentation/dynamic-debug-howto.txt
index 74e6c7782678..6e1684981da2 100644
--- a/Documentation/dynamic-debug-howto.txt
+++ b/Documentation/dynamic-debug-howto.txt
@@ -2,17 +2,17 @@
2Introduction 2Introduction
3============ 3============
4 4
5This document describes how to use the dynamic debug (ddebug) feature. 5This document describes how to use the dynamic debug (dyndbg) feature.
6 6
7Dynamic debug is designed to allow you to dynamically enable/disable kernel 7Dynamic debug is designed to allow you to dynamically enable/disable
8code to obtain additional kernel information. Currently, if 8kernel code to obtain additional kernel information. Currently, if
9CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() calls can be 9CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() calls can
10dynamically enabled per-callsite. 10be dynamically enabled per-callsite.
11 11
12Dynamic debug has even more useful features: 12Dynamic debug has even more useful features:
13 13
14 * Simple query language allows turning on and off debugging statements by 14 * Simple query language allows turning on and off debugging
15 matching any combination of 0 or 1 of: 15 statements by matching any combination of 0 or 1 of:
16 16
17 - source filename 17 - source filename
18 - function name 18 - function name
@@ -20,17 +20,19 @@ Dynamic debug has even more useful features:
20 - module name 20 - module name
21 - format string 21 - format string
22 22
23 * Provides a debugfs control file: <debugfs>/dynamic_debug/control which can be 23 * Provides a debugfs control file: <debugfs>/dynamic_debug/control
24 read to display the complete list of known debug statements, to help guide you 24 which can be read to display the complete list of known debug
25 statements, to help guide you
25 26
26Controlling dynamic debug Behaviour 27Controlling dynamic debug Behaviour
27=================================== 28===================================
28 29
29The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a 30The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a
30control file in the 'debugfs' filesystem. Thus, you must first mount the debugfs 31control file in the 'debugfs' filesystem. Thus, you must first mount
31filesystem, in order to make use of this feature. Subsequently, we refer to the 32the debugfs filesystem, in order to make use of this feature.
32control file as: <debugfs>/dynamic_debug/control. For example, if you want to 33Subsequently, we refer to the control file as:
33enable printing from source file 'svcsock.c', line 1603 you simply do: 34<debugfs>/dynamic_debug/control. For example, if you want to enable
35printing from source file 'svcsock.c', line 1603 you simply do:
34 36
35nullarbor:~ # echo 'file svcsock.c line 1603 +p' > 37nullarbor:~ # echo 'file svcsock.c line 1603 +p' >
36 <debugfs>/dynamic_debug/control 38 <debugfs>/dynamic_debug/control
@@ -44,15 +46,15 @@ nullarbor:~ # echo 'file svcsock.c wtf 1 +p' >
44Viewing Dynamic Debug Behaviour 46Viewing Dynamic Debug Behaviour
45=========================== 47===========================
46 48
47You can view the currently configured behaviour of all the debug statements 49You can view the currently configured behaviour of all the debug
48via: 50statements via:
49 51
50nullarbor:~ # cat <debugfs>/dynamic_debug/control 52nullarbor:~ # cat <debugfs>/dynamic_debug/control
51# filename:lineno [module]function flags format 53# filename:lineno [module]function flags format
52/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup - "SVCRDMA Module Removed, deregister RPC RDMA transport\012" 54/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012"
53/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init - "\011max_inline : %d\012" 55/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline : %d\012"
54/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init - "\011sq_depth : %d\012" 56/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth : %d\012"
55/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init - "\011max_requests : %d\012" 57/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests : %d\012"
56... 58...
57 59
58 60
@@ -65,12 +67,12 @@ nullarbor:~ # grep -i rdma <debugfs>/dynamic_debug/control | wc -l
65nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l 67nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l
6642 6842
67 69
68Note in particular that the third column shows the enabled behaviour 70The third column shows the currently enabled flags for each debug
69flags for each debug statement callsite (see below for definitions of the 71statement callsite (see below for definitions of the flags). The
70flags). The default value, no extra behaviour enabled, is "-". So 72default value, with no flags enabled, is "=_". So you can view all
71you can view all the debug statement callsites with any non-default flags: 73the debug statement callsites with any non-default flags:
72 74
73nullarbor:~ # awk '$3 != "-"' <debugfs>/dynamic_debug/control 75nullarbor:~ # awk '$3 != "=_"' <debugfs>/dynamic_debug/control
74# filename:lineno [module]function flags format 76# filename:lineno [module]function flags format
75/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012" 77/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012"
76 78
@@ -103,15 +105,14 @@ specifications, followed by a flags change specification.
103 105
104command ::= match-spec* flags-spec 106command ::= match-spec* flags-spec
105 107
106The match-spec's are used to choose a subset of the known dprintk() 108The match-spec's are used to choose a subset of the known pr_debug()
107callsites to which to apply the flags-spec. Think of them as a query 109callsites to which to apply the flags-spec. Think of them as a query
108with implicit ANDs between each pair. Note that an empty list of 110with implicit ANDs between each pair. Note that an empty list of
109match-specs is possible, but is not very useful because it will not 111match-specs will select all debug statement callsites.
110match any debug statement callsites.
111 112
112A match specification comprises a keyword, which controls the attribute 113A match specification comprises a keyword, which controls the
113of the callsite to be compared, and a value to compare against. Possible 114attribute of the callsite to be compared, and a value to compare
114keywords are: 115against. Possible keywords are:
115 116
116match-spec ::= 'func' string | 117match-spec ::= 'func' string |
117 'file' string | 118 'file' string |
@@ -164,15 +165,15 @@ format
164 characters (") or single quote characters ('). 165 characters (") or single quote characters (').
165 Examples: 166 Examples:
166 167
167 format svcrdma: // many of the NFS/RDMA server dprintks 168 format svcrdma: // many of the NFS/RDMA server pr_debugs
168 format readahead // some dprintks in the readahead cache 169 format readahead // some pr_debugs in the readahead cache
169 format nfsd:\040SETATTR // one way to match a format with whitespace 170 format nfsd:\040SETATTR // one way to match a format with whitespace
170 format "nfsd: SETATTR" // a neater way to match a format with whitespace 171 format "nfsd: SETATTR" // a neater way to match a format with whitespace
171 format 'nfsd: SETATTR' // yet another way to match a format with whitespace 172 format 'nfsd: SETATTR' // yet another way to match a format with whitespace
172 173
173line 174line
174 The given line number or range of line numbers is compared 175 The given line number or range of line numbers is compared
175 against the line number of each dprintk() callsite. A single 176 against the line number of each pr_debug() callsite. A single
176 line number matches the callsite line number exactly. A 177 line number matches the callsite line number exactly. A
177 range of line numbers matches any callsite between the first 178 range of line numbers matches any callsite between the first
178 and last line number inclusive. An empty first number means 179 and last line number inclusive. An empty first number means
@@ -188,51 +189,93 @@ The flags specification comprises a change operation followed
188by one or more flag characters. The change operation is one 189by one or more flag characters. The change operation is one
189of the characters: 190of the characters:
190 191
191- 192 - remove the given flags
192 remove the given flags 193 + add the given flags
193 194 = set the flags to the given flags
194+
195 add the given flags
196
197=
198 set the flags to the given flags
199 195
200The flags are: 196The flags are:
201 197
202f 198 p enables the pr_debug() callsite.
203 Include the function name in the printed message 199 f Include the function name in the printed message
204l 200 l Include line number in the printed message
205 Include line number in the printed message 201 m Include module name in the printed message
206m 202 t Include thread ID in messages not generated from interrupt context
207 Include module name in the printed message 203 _ No flags are set. (Or'd with others on input)
208p 204
209 Causes a printk() message to be emitted to dmesg 205For display, the flags are preceded by '='
210t 206(mnemonic: what the flags are currently equal to).
211 Include thread ID in messages not generated from interrupt context
212 207
213Note the regexp ^[-+=][flmpt]+$ matches a flags specification. 208Note the regexp ^[-+=][flmpt_]+$ matches a flags specification.
214Note also that there is no convenient syntax to remove all 209To clear all flags at once, use "=_" or "-flmpt".
215the flags at once, you need to use "-flmpt".
216 210
217 211
218Debug messages during boot process 212Debug messages during Boot Process
219================================== 213==================================
220 214
221To be able to activate debug messages during the boot process, 215To activate debug messages for core code and built-in modules during
222even before userspace and debugfs exists, use the boot parameter: 216the boot process, even before userspace and debugfs exists, use
223ddebug_query="QUERY" 217dyndbg="QUERY", module.dyndbg="QUERY", or ddebug_query="QUERY"
218(ddebug_query is obsoleted by dyndbg, and deprecated). QUERY follows
219the syntax described above, but must not exceed 1023 characters. Your
220bootloader may impose lower limits.
221
222These dyndbg params are processed just after the ddebug tables are
223processed, as part of the arch_initcall. Thus you can enable debug
224messages in all code run after this arch_initcall via this boot
225parameter.
224 226
225QUERY follows the syntax described above, but must not exceed 1023
226characters. The enablement of debug messages is done as an arch_initcall.
227Thus you can enable debug messages in all code processed after this
228arch_initcall via this boot parameter.
229On an x86 system for example ACPI enablement is a subsys_initcall and 227On an x86 system for example ACPI enablement is a subsys_initcall and
230ddebug_query="file ec.c +p" 228 dyndbg="file ec.c +p"
231will show early Embedded Controller transactions during ACPI setup if 229will show early Embedded Controller transactions during ACPI setup if
232your machine (typically a laptop) has an Embedded Controller. 230your machine (typically a laptop) has an Embedded Controller.
233PCI (or other devices) initialization also is a hot candidate for using 231PCI (or other devices) initialization also is a hot candidate for using
234this boot parameter for debugging purposes. 232this boot parameter for debugging purposes.
235 233
234If foo module is not built-in, foo.dyndbg will still be processed at
235boot time, without effect, but will be reprocessed when module is
236loaded later. dyndbg_query= and bare dyndbg= are only processed at
237boot.
238
239
240Debug Messages at Module Initialization Time
241============================================
242
243When "modprobe foo" is called, modprobe scans /proc/cmdline for
244foo.params, strips "foo.", and passes them to the kernel along with
245params given in modprobe args or /etc/modprob.d/*.conf files,
246in the following order:
247
2481. # parameters given via /etc/modprobe.d/*.conf
249 options foo dyndbg=+pt
250 options foo dyndbg # defaults to +p
251
2522. # foo.dyndbg as given in boot args, "foo." is stripped and passed
253 foo.dyndbg=" func bar +p; func buz +mp"
254
2553. # args to modprobe
256 modprobe foo dyndbg==pmf # override previous settings
257
258These dyndbg queries are applied in order, with last having final say.
259This allows boot args to override or modify those from /etc/modprobe.d
260(sensible, since 1 is system wide, 2 is kernel or boot specific), and
261modprobe args to override both.
262
263In the foo.dyndbg="QUERY" form, the query must exclude "module foo".
264"foo" is extracted from the param-name, and applied to each query in
265"QUERY", and only 1 match-spec of each type is allowed.
266
267The dyndbg option is a "fake" module parameter, which means:
268
269- modules do not need to define it explicitly
270- every module gets it tacitly, whether they use pr_debug or not
271- it doesnt appear in /sys/module/$module/parameters/
272 To see it, grep the control file, or inspect /proc/cmdline.
273
274For CONFIG_DYNAMIC_DEBUG kernels, any settings given at boot-time (or
275enabled by -DDEBUG flag during compilation) can be disabled later via
276the sysfs interface if the debug messages are no longer needed:
277
278 echo "module module_name -p" > <debugfs>/dynamic_debug/control
236 279
237Examples 280Examples
238======== 281========
@@ -260,3 +303,18 @@ nullarbor:~ # echo -n 'func svc_process -p' >
260// enable messages for NFS calls READ, READLINK, READDIR and READDIR+. 303// enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
261nullarbor:~ # echo -n 'format "nfsd: READ" +p' > 304nullarbor:~ # echo -n 'format "nfsd: READ" +p' >
262 <debugfs>/dynamic_debug/control 305 <debugfs>/dynamic_debug/control
306
307// enable all messages
308nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control
309
310// add module, function to all enabled messages
311nullarbor:~ # echo -n '+mf' > <debugfs>/dynamic_debug/control
312
313// boot-args example, with newlines and comments for readability
314Kernel command line: ...
315 // see whats going on in dyndbg=value processing
316 dynamic_debug.verbose=1
317 // enable pr_debugs in 2 builtins, #cmt is stripped
318 dyndbg="module params +p #cmt ; module sys +p"
319 // enable pr_debugs in 2 functions in a module loaded later
320 pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p"