xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/dynamic-debug-howto.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunDynamic debug
2*4882a593Smuzhiyun+++++++++++++
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunIntroduction
6*4882a593Smuzhiyun============
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunThis document describes how to use the dynamic debug (dyndbg) feature.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunDynamic debug is designed to allow you to dynamically enable/disable
11*4882a593Smuzhiyunkernel code to obtain additional kernel information.  Currently, if
12*4882a593Smuzhiyun``CONFIG_DYNAMIC_DEBUG`` is set, then all ``pr_debug()``/``dev_dbg()`` and
13*4882a593Smuzhiyun``print_hex_dump_debug()``/``print_hex_dump_bytes()`` calls can be dynamically
14*4882a593Smuzhiyunenabled per-callsite.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunIf you do not want to enable dynamic debug globally (i.e. in some embedded
17*4882a593Smuzhiyunsystem), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic
18*4882a593Smuzhiyundebug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any
19*4882a593Smuzhiyunmodules which you'd like to dynamically debug later.
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunIf ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is just
22*4882a593Smuzhiyunshortcut for ``print_hex_dump(KERN_DEBUG)``.
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunFor ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is
25*4882a593Smuzhiyunits ``prefix_str`` argument, if it is constant string; or ``hexdump``
26*4882a593Smuzhiyunin case ``prefix_str`` is built dynamically.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunDynamic debug has even more useful features:
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun * Simple query language allows turning on and off debugging
31*4882a593Smuzhiyun   statements by matching any combination of 0 or 1 of:
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun   - source filename
34*4882a593Smuzhiyun   - function name
35*4882a593Smuzhiyun   - line number (including ranges of line numbers)
36*4882a593Smuzhiyun   - module name
37*4882a593Smuzhiyun   - format string
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun * Provides a debugfs control file: ``<debugfs>/dynamic_debug/control``
40*4882a593Smuzhiyun   which can be read to display the complete list of known debug
41*4882a593Smuzhiyun   statements, to help guide you
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunControlling dynamic debug Behaviour
44*4882a593Smuzhiyun===================================
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunThe behaviour of ``pr_debug()``/``dev_dbg()`` are controlled via writing to a
47*4882a593Smuzhiyuncontrol file in the 'debugfs' filesystem. Thus, you must first mount
48*4882a593Smuzhiyunthe debugfs filesystem, in order to make use of this feature.
49*4882a593SmuzhiyunSubsequently, we refer to the control file as:
50*4882a593Smuzhiyun``<debugfs>/dynamic_debug/control``. For example, if you want to enable
51*4882a593Smuzhiyunprinting from source file ``svcsock.c``, line 1603 you simply do::
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun  nullarbor:~ # echo 'file svcsock.c line 1603 +p' >
54*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunIf you make a mistake with the syntax, the write will fail thus::
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun  nullarbor:~ # echo 'file svcsock.c wtf 1 +p' >
59*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
60*4882a593Smuzhiyun  -bash: echo: write error: Invalid argument
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunNote, for systems without 'debugfs' enabled, the control file can be
63*4882a593Smuzhiyunfound in ``/proc/dynamic_debug/control``.
64*4882a593Smuzhiyun
65*4882a593SmuzhiyunViewing Dynamic Debug Behaviour
66*4882a593Smuzhiyun===============================
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunYou can view the currently configured behaviour of all the debug
69*4882a593Smuzhiyunstatements via::
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun  nullarbor:~ # cat <debugfs>/dynamic_debug/control
72*4882a593Smuzhiyun  # filename:lineno [module]function flags format
73*4882a593Smuzhiyun  net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012"
74*4882a593Smuzhiyun  net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline       : %d\012"
75*4882a593Smuzhiyun  net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth         : %d\012"
76*4882a593Smuzhiyun  net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests     : %d\012"
77*4882a593Smuzhiyun  ...
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunYou can also apply standard Unix text manipulation filters to this
81*4882a593Smuzhiyundata, e.g.::
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun  nullarbor:~ # grep -i rdma <debugfs>/dynamic_debug/control  | wc -l
84*4882a593Smuzhiyun  62
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun  nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l
87*4882a593Smuzhiyun  42
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunThe third column shows the currently enabled flags for each debug
90*4882a593Smuzhiyunstatement callsite (see below for definitions of the flags).  The
91*4882a593Smuzhiyundefault value, with no flags enabled, is ``=_``.  So you can view all
92*4882a593Smuzhiyunthe debug statement callsites with any non-default flags::
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun  nullarbor:~ # awk '$3 != "=_"' <debugfs>/dynamic_debug/control
95*4882a593Smuzhiyun  # filename:lineno [module]function flags format
96*4882a593Smuzhiyun  net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012"
97*4882a593Smuzhiyun
98*4882a593SmuzhiyunCommand Language Reference
99*4882a593Smuzhiyun==========================
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunAt the lexical level, a command comprises a sequence of words separated
102*4882a593Smuzhiyunby spaces or tabs.  So these are all equivalent::
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun  nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
105*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
106*4882a593Smuzhiyun  nullarbor:~ # echo -n '  file   svcsock.c     line  1603 +p  ' >
107*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
108*4882a593Smuzhiyun  nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
109*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
110*4882a593Smuzhiyun
111*4882a593SmuzhiyunCommand submissions are bounded by a write() system call.
112*4882a593SmuzhiyunMultiple commands can be written together, separated by ``;`` or ``\n``::
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun  ~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \
115*4882a593Smuzhiyun     > <debugfs>/dynamic_debug/control
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunIf your query set is big, you can batch them too::
118*4882a593Smuzhiyun
119*4882a593Smuzhiyun  ~# cat query-batch-file > <debugfs>/dynamic_debug/control
120*4882a593Smuzhiyun
121*4882a593SmuzhiyunAnother way is to use wildcards. The match rule supports ``*`` (matches
122*4882a593Smuzhiyunzero or more characters) and ``?`` (matches exactly one character). For
123*4882a593Smuzhiyunexample, you can match all usb drivers::
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun  ~# echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control
126*4882a593Smuzhiyun
127*4882a593SmuzhiyunAt the syntactical level, a command comprises a sequence of match
128*4882a593Smuzhiyunspecifications, followed by a flags change specification::
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun  command ::= match-spec* flags-spec
131*4882a593Smuzhiyun
132*4882a593SmuzhiyunThe match-spec's are used to choose a subset of the known pr_debug()
133*4882a593Smuzhiyuncallsites to which to apply the flags-spec.  Think of them as a query
134*4882a593Smuzhiyunwith implicit ANDs between each pair.  Note that an empty list of
135*4882a593Smuzhiyunmatch-specs will select all debug statement callsites.
136*4882a593Smuzhiyun
137*4882a593SmuzhiyunA match specification comprises a keyword, which controls the
138*4882a593Smuzhiyunattribute of the callsite to be compared, and a value to compare
139*4882a593Smuzhiyunagainst.  Possible keywords are:::
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun  match-spec ::= 'func' string |
142*4882a593Smuzhiyun		 'file' string |
143*4882a593Smuzhiyun		 'module' string |
144*4882a593Smuzhiyun		 'format' string |
145*4882a593Smuzhiyun		 'line' line-range
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun  line-range ::= lineno |
148*4882a593Smuzhiyun		 '-'lineno |
149*4882a593Smuzhiyun		 lineno'-' |
150*4882a593Smuzhiyun		 lineno'-'lineno
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun  lineno ::= unsigned-int
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun.. note::
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun  ``line-range`` cannot contain space, e.g.
157*4882a593Smuzhiyun  "1-30" is valid range but "1 - 30" is not.
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun
160*4882a593SmuzhiyunThe meanings of each keyword are:
161*4882a593Smuzhiyun
162*4882a593Smuzhiyunfunc
163*4882a593Smuzhiyun    The given string is compared against the function name
164*4882a593Smuzhiyun    of each callsite.  Example::
165*4882a593Smuzhiyun
166*4882a593Smuzhiyun	func svc_tcp_accept
167*4882a593Smuzhiyun	func *recv*		# in rfcomm, bluetooth, ping, tcp
168*4882a593Smuzhiyun
169*4882a593Smuzhiyunfile
170*4882a593Smuzhiyun    The given string is compared against either the src-root relative
171*4882a593Smuzhiyun    pathname, or the basename of the source file of each callsite.
172*4882a593Smuzhiyun    Examples::
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun	file svcsock.c
175*4882a593Smuzhiyun	file kernel/freezer.c	# ie column 1 of control file
176*4882a593Smuzhiyun	file drivers/usb/*	# all callsites under it
177*4882a593Smuzhiyun	file inode.c:start_*	# parse :tail as a func (above)
178*4882a593Smuzhiyun	file inode.c:1-100	# parse :tail as a line-range (above)
179*4882a593Smuzhiyun
180*4882a593Smuzhiyunmodule
181*4882a593Smuzhiyun    The given string is compared against the module name
182*4882a593Smuzhiyun    of each callsite.  The module name is the string as
183*4882a593Smuzhiyun    seen in ``lsmod``, i.e. without the directory or the ``.ko``
184*4882a593Smuzhiyun    suffix and with ``-`` changed to ``_``.  Examples::
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun	module sunrpc
187*4882a593Smuzhiyun	module nfsd
188*4882a593Smuzhiyun	module drm*	# both drm, drm_kms_helper
189*4882a593Smuzhiyun
190*4882a593Smuzhiyunformat
191*4882a593Smuzhiyun    The given string is searched for in the dynamic debug format
192*4882a593Smuzhiyun    string.  Note that the string does not need to match the
193*4882a593Smuzhiyun    entire format, only some part.  Whitespace and other
194*4882a593Smuzhiyun    special characters can be escaped using C octal character
195*4882a593Smuzhiyun    escape ``\ooo`` notation, e.g. the space character is ``\040``.
196*4882a593Smuzhiyun    Alternatively, the string can be enclosed in double quote
197*4882a593Smuzhiyun    characters (``"``) or single quote characters (``'``).
198*4882a593Smuzhiyun    Examples::
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun	format svcrdma:         // many of the NFS/RDMA server pr_debugs
201*4882a593Smuzhiyun	format readahead        // some pr_debugs in the readahead cache
202*4882a593Smuzhiyun	format nfsd:\040SETATTR // one way to match a format with whitespace
203*4882a593Smuzhiyun	format "nfsd: SETATTR"  // a neater way to match a format with whitespace
204*4882a593Smuzhiyun	format 'nfsd: SETATTR'  // yet another way to match a format with whitespace
205*4882a593Smuzhiyun
206*4882a593Smuzhiyunline
207*4882a593Smuzhiyun    The given line number or range of line numbers is compared
208*4882a593Smuzhiyun    against the line number of each ``pr_debug()`` callsite.  A single
209*4882a593Smuzhiyun    line number matches the callsite line number exactly.  A
210*4882a593Smuzhiyun    range of line numbers matches any callsite between the first
211*4882a593Smuzhiyun    and last line number inclusive.  An empty first number means
212*4882a593Smuzhiyun    the first line in the file, an empty last line number means the
213*4882a593Smuzhiyun    last line number in the file.  Examples::
214*4882a593Smuzhiyun
215*4882a593Smuzhiyun	line 1603           // exactly line 1603
216*4882a593Smuzhiyun	line 1600-1605      // the six lines from line 1600 to line 1605
217*4882a593Smuzhiyun	line -1605          // the 1605 lines from line 1 to line 1605
218*4882a593Smuzhiyun	line 1600-          // all lines from line 1600 to the end of the file
219*4882a593Smuzhiyun
220*4882a593SmuzhiyunThe flags specification comprises a change operation followed
221*4882a593Smuzhiyunby one or more flag characters.  The change operation is one
222*4882a593Smuzhiyunof the characters::
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun  -    remove the given flags
225*4882a593Smuzhiyun  +    add the given flags
226*4882a593Smuzhiyun  =    set the flags to the given flags
227*4882a593Smuzhiyun
228*4882a593SmuzhiyunThe flags are::
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun  p    enables the pr_debug() callsite.
231*4882a593Smuzhiyun  f    Include the function name in the printed message
232*4882a593Smuzhiyun  l    Include line number in the printed message
233*4882a593Smuzhiyun  m    Include module name in the printed message
234*4882a593Smuzhiyun  t    Include thread ID in messages not generated from interrupt context
235*4882a593Smuzhiyun  _    No flags are set. (Or'd with others on input)
236*4882a593Smuzhiyun
237*4882a593SmuzhiyunFor ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` flag
238*4882a593Smuzhiyunhave meaning, other flags ignored.
239*4882a593Smuzhiyun
240*4882a593SmuzhiyunFor display, the flags are preceded by ``=``
241*4882a593Smuzhiyun(mnemonic: what the flags are currently equal to).
242*4882a593Smuzhiyun
243*4882a593SmuzhiyunNote the regexp ``^[-+=][flmpt_]+$`` matches a flags specification.
244*4882a593SmuzhiyunTo clear all flags at once, use ``=_`` or ``-flmpt``.
245*4882a593Smuzhiyun
246*4882a593Smuzhiyun
247*4882a593SmuzhiyunDebug messages during Boot Process
248*4882a593Smuzhiyun==================================
249*4882a593Smuzhiyun
250*4882a593SmuzhiyunTo activate debug messages for core code and built-in modules during
251*4882a593Smuzhiyunthe boot process, even before userspace and debugfs exists, use
252*4882a593Smuzhiyun``dyndbg="QUERY"``, ``module.dyndbg="QUERY"``, or ``ddebug_query="QUERY"``
253*4882a593Smuzhiyun(``ddebug_query`` is obsoleted by ``dyndbg``, and deprecated).  QUERY follows
254*4882a593Smuzhiyunthe syntax described above, but must not exceed 1023 characters.  Your
255*4882a593Smuzhiyunbootloader may impose lower limits.
256*4882a593Smuzhiyun
257*4882a593SmuzhiyunThese ``dyndbg`` params are processed just after the ddebug tables are
258*4882a593Smuzhiyunprocessed, as part of the early_initcall.  Thus you can enable debug
259*4882a593Smuzhiyunmessages in all code run after this early_initcall via this boot
260*4882a593Smuzhiyunparameter.
261*4882a593Smuzhiyun
262*4882a593SmuzhiyunOn an x86 system for example ACPI enablement is a subsys_initcall and::
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun   dyndbg="file ec.c +p"
265*4882a593Smuzhiyun
266*4882a593Smuzhiyunwill show early Embedded Controller transactions during ACPI setup if
267*4882a593Smuzhiyunyour machine (typically a laptop) has an Embedded Controller.
268*4882a593SmuzhiyunPCI (or other devices) initialization also is a hot candidate for using
269*4882a593Smuzhiyunthis boot parameter for debugging purposes.
270*4882a593Smuzhiyun
271*4882a593SmuzhiyunIf ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at
272*4882a593Smuzhiyunboot time, without effect, but will be reprocessed when module is
273*4882a593Smuzhiyunloaded later. ``ddebug_query=`` and bare ``dyndbg=`` are only processed at
274*4882a593Smuzhiyunboot.
275*4882a593Smuzhiyun
276*4882a593Smuzhiyun
277*4882a593SmuzhiyunDebug Messages at Module Initialization Time
278*4882a593Smuzhiyun============================================
279*4882a593Smuzhiyun
280*4882a593SmuzhiyunWhen ``modprobe foo`` is called, modprobe scans ``/proc/cmdline`` for
281*4882a593Smuzhiyun``foo.params``, strips ``foo.``, and passes them to the kernel along with
282*4882a593Smuzhiyunparams given in modprobe args or ``/etc/modprob.d/*.conf`` files,
283*4882a593Smuzhiyunin the following order:
284*4882a593Smuzhiyun
285*4882a593Smuzhiyun1. parameters given via ``/etc/modprobe.d/*.conf``::
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun	options foo dyndbg=+pt
288*4882a593Smuzhiyun	options foo dyndbg # defaults to +p
289*4882a593Smuzhiyun
290*4882a593Smuzhiyun2. ``foo.dyndbg`` as given in boot args, ``foo.`` is stripped and passed::
291*4882a593Smuzhiyun
292*4882a593Smuzhiyun	foo.dyndbg=" func bar +p; func buz +mp"
293*4882a593Smuzhiyun
294*4882a593Smuzhiyun3. args to modprobe::
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun	modprobe foo dyndbg==pmf # override previous settings
297*4882a593Smuzhiyun
298*4882a593SmuzhiyunThese ``dyndbg`` queries are applied in order, with last having final say.
299*4882a593SmuzhiyunThis allows boot args to override or modify those from ``/etc/modprobe.d``
300*4882a593Smuzhiyun(sensible, since 1 is system wide, 2 is kernel or boot specific), and
301*4882a593Smuzhiyunmodprobe args to override both.
302*4882a593Smuzhiyun
303*4882a593SmuzhiyunIn the ``foo.dyndbg="QUERY"`` form, the query must exclude ``module foo``.
304*4882a593Smuzhiyun``foo`` is extracted from the param-name, and applied to each query in
305*4882a593Smuzhiyun``QUERY``, and only 1 match-spec of each type is allowed.
306*4882a593Smuzhiyun
307*4882a593SmuzhiyunThe ``dyndbg`` option is a "fake" module parameter, which means:
308*4882a593Smuzhiyun
309*4882a593Smuzhiyun- modules do not need to define it explicitly
310*4882a593Smuzhiyun- every module gets it tacitly, whether they use pr_debug or not
311*4882a593Smuzhiyun- it doesn't appear in ``/sys/module/$module/parameters/``
312*4882a593Smuzhiyun  To see it, grep the control file, or inspect ``/proc/cmdline.``
313*4882a593Smuzhiyun
314*4882a593SmuzhiyunFor ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or
315*4882a593Smuzhiyunenabled by ``-DDEBUG`` flag during compilation) can be disabled later via
316*4882a593Smuzhiyunthe debugfs interface if the debug messages are no longer needed::
317*4882a593Smuzhiyun
318*4882a593Smuzhiyun   echo "module module_name -p" > <debugfs>/dynamic_debug/control
319*4882a593Smuzhiyun
320*4882a593SmuzhiyunExamples
321*4882a593Smuzhiyun========
322*4882a593Smuzhiyun
323*4882a593Smuzhiyun::
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun  // enable the message at line 1603 of file svcsock.c
326*4882a593Smuzhiyun  nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
327*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
328*4882a593Smuzhiyun
329*4882a593Smuzhiyun  // enable all the messages in file svcsock.c
330*4882a593Smuzhiyun  nullarbor:~ # echo -n 'file svcsock.c +p' >
331*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun  // enable all the messages in the NFS server module
334*4882a593Smuzhiyun  nullarbor:~ # echo -n 'module nfsd +p' >
335*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
336*4882a593Smuzhiyun
337*4882a593Smuzhiyun  // enable all 12 messages in the function svc_process()
338*4882a593Smuzhiyun  nullarbor:~ # echo -n 'func svc_process +p' >
339*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
340*4882a593Smuzhiyun
341*4882a593Smuzhiyun  // disable all 12 messages in the function svc_process()
342*4882a593Smuzhiyun  nullarbor:~ # echo -n 'func svc_process -p' >
343*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun  // enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
346*4882a593Smuzhiyun  nullarbor:~ # echo -n 'format "nfsd: READ" +p' >
347*4882a593Smuzhiyun				<debugfs>/dynamic_debug/control
348*4882a593Smuzhiyun
349*4882a593Smuzhiyun  // enable messages in files of which the paths include string "usb"
350*4882a593Smuzhiyun  nullarbor:~ # echo -n '*usb* +p' > <debugfs>/dynamic_debug/control
351*4882a593Smuzhiyun
352*4882a593Smuzhiyun  // enable all messages
353*4882a593Smuzhiyun  nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun  // add module, function to all enabled messages
356*4882a593Smuzhiyun  nullarbor:~ # echo -n '+mf' > <debugfs>/dynamic_debug/control
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun  // boot-args example, with newlines and comments for readability
359*4882a593Smuzhiyun  Kernel command line: ...
360*4882a593Smuzhiyun    // see whats going on in dyndbg=value processing
361*4882a593Smuzhiyun    dynamic_debug.verbose=1
362*4882a593Smuzhiyun    // enable pr_debugs in 2 builtins, #cmt is stripped
363*4882a593Smuzhiyun    dyndbg="module params +p #cmt ; module sys +p"
364*4882a593Smuzhiyun    // enable pr_debugs in 2 functions in a module loaded later
365*4882a593Smuzhiyun    pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p"
366