Linux Audio

Check our new training course

Loading...
v6.13.7
  1Dynamic debug
  2+++++++++++++
  3
  4
  5Introduction
  6============
  7
  8Dynamic debug allows you to dynamically enable/disable kernel
  9debug-print code to obtain additional kernel information.
 10
 11If ``/proc/dynamic_debug/control`` exists, your kernel has dynamic
 12debug.  You'll need root access (sudo su) to use this.
 13
 14Dynamic debug provides:
 15
 16 * a Catalog of all *prdbgs* in your kernel.
 17   ``cat /proc/dynamic_debug/control`` to see them.
 18
 19 * a Simple query/command language to alter *prdbgs* by selecting on
 20   any combination of 0 or 1 of:
 21
 22   - source filename
 23   - function name
 24   - line number (including ranges of line numbers)
 25   - module name
 26   - format string
 27   - class name (as known/declared by each module)
 28
 29NOTE: To actually get the debug-print output on the console, you may
 30need to adjust the kernel ``loglevel=``, or use ``ignore_loglevel``.
 31Read about these kernel parameters in
 32Documentation/admin-guide/kernel-parameters.rst.
 33
 34Viewing Dynamic Debug Behaviour
 35===============================
 36
 37You can view the currently configured behaviour in the *prdbg* catalog::
 38
 39  :#> head -n7 /proc/dynamic_debug/control
 40  # filename:lineno [module]function flags format
 41  init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012
 42  init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012"
 43  init/main.c:1424 [main]run_init_process =_ "  with arguments:\012"
 44  init/main.c:1426 [main]run_init_process =_ "    %s\012"
 45  init/main.c:1427 [main]run_init_process =_ "  with environment:\012"
 46  init/main.c:1429 [main]run_init_process =_ "    %s\012"
 47
 48The 3rd space-delimited column shows the current flags, preceded by
 49a ``=`` for easy use with grep/cut. ``=p`` shows enabled callsites.
 50
 51Controlling dynamic debug Behaviour
 52===================================
 53
 54The behaviour of *prdbg* sites are controlled by writing
 55query/commands to the control file.  Example::
 56
 57  # grease the interface
 58  :#> alias ddcmd='echo $* > /proc/dynamic_debug/control'
 59
 60  :#> ddcmd '-p; module main func run* +p'
 61  :#> grep =p /proc/dynamic_debug/control
 62  init/main.c:1424 [main]run_init_process =p "  with arguments:\012"
 63  init/main.c:1426 [main]run_init_process =p "    %s\012"
 64  init/main.c:1427 [main]run_init_process =p "  with environment:\012"
 65  init/main.c:1429 [main]run_init_process =p "    %s\012"
 66
 67Error messages go to console/syslog::
 68
 69  :#> ddcmd mode foo +p
 70  dyndbg: unknown keyword "mode"
 71  dyndbg: query parse failed
 72  bash: echo: write error: Invalid argument
 73
 74If debugfs is also enabled and mounted, ``dynamic_debug/control`` is
 75also under the mount-dir, typically ``/sys/kernel/debug/``.
 76
 77Command Language Reference
 78==========================
 79
 80At the basic lexical level, a command is a sequence of words separated
 81by spaces or tabs.  So these are all equivalent::
 82
 83  :#> ddcmd file svcsock.c line 1603 +p
 84  :#> ddcmd "file svcsock.c line 1603 +p"
 85  :#> ddcmd '  file   svcsock.c     line  1603 +p  '
 86
 87Command submissions are bounded by a write() system call.
 88Multiple commands can be written together, separated by ``;`` or ``\n``::
 89
 90  :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p"
 91  :#> ddcmd <<"EOC"
 92  func pnpacpi_get_resources +p
 93  func pnp_assign_mem +p
 94  EOC
 95  :#> cat query-batch-file > /proc/dynamic_debug/control
 96
 97You can also use wildcards in each query term. The match rule supports
 98``*`` (matches zero or more characters) and ``?`` (matches exactly one
 99character). For example, you can match all usb drivers::
100
101  :#> ddcmd file "drivers/usb/*" +p	# "" to suppress shell expansion
102
103Syntactically, a command is pairs of keyword values, followed by a
104flags change or setting::
105
106  command ::= match-spec* flags-spec
107
108The match-spec's select *prdbgs* from the catalog, upon which to apply
109the flags-spec, all constraints are ANDed together.  An absent keyword
110is the same as keyword "*".
111
112
113A match specification is a keyword, which selects the attribute of
114the callsite to be compared, and a value to compare against.  Possible
115keywords are:::
116
117  match-spec ::= 'func' string |
118		 'file' string |
119		 'module' string |
120		 'format' string |
121		 'class' string |
122		 'line' line-range
123
124  line-range ::= lineno |
125		 '-'lineno |
126		 lineno'-' |
127		 lineno'-'lineno
128
129  lineno ::= unsigned-int
130
131.. note::
132
133  ``line-range`` cannot contain space, e.g.
134  "1-30" is valid range but "1 - 30" is not.
135
136
137The meanings of each keyword are:
138
139func
140    The given string is compared against the function name
141    of each callsite.  Example::
142
143	func svc_tcp_accept
144	func *recv*		# in rfcomm, bluetooth, ping, tcp
145
146file
147    The given string is compared against either the src-root relative
148    pathname, or the basename of the source file of each callsite.
149    Examples::
150
151	file svcsock.c
152	file kernel/freezer.c	# ie column 1 of control file
153	file drivers/usb/*	# all callsites under it
154	file inode.c:start_*	# parse :tail as a func (above)
155	file inode.c:1-100	# parse :tail as a line-range (above)
156
157module
158    The given string is compared against the module name
159    of each callsite.  The module name is the string as
160    seen in ``lsmod``, i.e. without the directory or the ``.ko``
161    suffix and with ``-`` changed to ``_``.  Examples::
162
163	module sunrpc
164	module nfsd
165	module drm*	# both drm, drm_kms_helper
166
167format
168    The given string is searched for in the dynamic debug format
169    string.  Note that the string does not need to match the
170    entire format, only some part.  Whitespace and other
171    special characters can be escaped using C octal character
172    escape ``\ooo`` notation, e.g. the space character is ``\040``.
173    Alternatively, the string can be enclosed in double quote
174    characters (``"``) or single quote characters (``'``).
175    Examples::
176
177	format svcrdma:         // many of the NFS/RDMA server pr_debugs
178	format readahead        // some pr_debugs in the readahead cache
179	format nfsd:\040SETATTR // one way to match a format with whitespace
180	format "nfsd: SETATTR"  // a neater way to match a format with whitespace
181	format 'nfsd: SETATTR'  // yet another way to match a format with whitespace
182
183class
184    The given class_name is validated against each module, which may
185    have declared a list of known class_names.  If the class_name is
186    found for a module, callsite & class matching and adjustment
187    proceeds.  Examples::
188
189	class DRM_UT_KMS	# a DRM.debug category
190	class JUNK		# silent non-match
191	// class TLD_*		# NOTICE: no wildcard in class names
192
193line
194    The given line number or range of line numbers is compared
195    against the line number of each ``pr_debug()`` callsite.  A single
196    line number matches the callsite line number exactly.  A
197    range of line numbers matches any callsite between the first
198    and last line number inclusive.  An empty first number means
199    the first line in the file, an empty last line number means the
200    last line number in the file.  Examples::
201
202	line 1603           // exactly line 1603
203	line 1600-1605      // the six lines from line 1600 to line 1605
204	line -1605          // the 1605 lines from line 1 to line 1605
205	line 1600-          // all lines from line 1600 to the end of the file
206
207The flags specification comprises a change operation followed
208by one or more flag characters.  The change operation is one
209of the characters::
210
211  -    remove the given flags
212  +    add the given flags
213  =    set the flags to the given flags
214
215The flags are::
216
217  p    enables the pr_debug() callsite.
218  _    enables no flags.
219
220  Decorator flags add to the message-prefix, in order:
221  t    Include thread ID, or <intr>
222  m    Include module name
223  f    Include the function name
224  s    Include the source file name
225  l    Include line number
226
227For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only
228the ``p`` flag has meaning, other flags are ignored.
229
230Note the regexp ``^[-+=][fslmpt_]+$`` matches a flags specification.
231To clear all flags at once, use ``=_`` or ``-fslmpt``.
232
233
234Debug messages during Boot Process
235==================================
236
237To activate debug messages for core code and built-in modules during
238the boot process, even before userspace and debugfs exists, use
239``dyndbg="QUERY"`` or ``module.dyndbg="QUERY"``.  QUERY follows
240the syntax described above, but must not exceed 1023 characters.  Your
241bootloader may impose lower limits.
242
243These ``dyndbg`` params are processed just after the ddebug tables are
244processed, as part of the early_initcall.  Thus you can enable debug
245messages in all code run after this early_initcall via this boot
246parameter.
247
248On an x86 system for example ACPI enablement is a subsys_initcall and::
249
250   dyndbg="file ec.c +p"
251
252will show early Embedded Controller transactions during ACPI setup if
253your machine (typically a laptop) has an Embedded Controller.
254PCI (or other devices) initialization also is a hot candidate for using
255this boot parameter for debugging purposes.
256
257If ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at
258boot time, without effect, but will be reprocessed when module is
259loaded later. Bare ``dyndbg=`` is only processed at boot.
260
261
262Debug Messages at Module Initialization Time
263============================================
264
265When ``modprobe foo`` is called, modprobe scans ``/proc/cmdline`` for
266``foo.params``, strips ``foo.``, and passes them to the kernel along with
267params given in modprobe args or ``/etc/modprobe.d/*.conf`` files,
268in the following order:
269
2701. parameters given via ``/etc/modprobe.d/*.conf``::
271
272	options foo dyndbg=+pt
273	options foo dyndbg # defaults to +p
274
2752. ``foo.dyndbg`` as given in boot args, ``foo.`` is stripped and passed::
276
277	foo.dyndbg=" func bar +p; func buz +mp"
278
2793. args to modprobe::
280
281	modprobe foo dyndbg==pmf # override previous settings
282
283These ``dyndbg`` queries are applied in order, with last having final say.
284This allows boot args to override or modify those from ``/etc/modprobe.d``
285(sensible, since 1 is system wide, 2 is kernel or boot specific), and
286modprobe args to override both.
287
288In the ``foo.dyndbg="QUERY"`` form, the query must exclude ``module foo``.
289``foo`` is extracted from the param-name, and applied to each query in
290``QUERY``, and only 1 match-spec of each type is allowed.
291
292The ``dyndbg`` option is a "fake" module parameter, which means:
293
294- modules do not need to define it explicitly
295- every module gets it tacitly, whether they use pr_debug or not
296- it doesn't appear in ``/sys/module/$module/parameters/``
297  To see it, grep the control file, or inspect ``/proc/cmdline.``
298
299For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or
300enabled by ``-DDEBUG`` flag during compilation) can be disabled later via
301the debugfs interface if the debug messages are no longer needed::
302
303   echo "module module_name -p" > /proc/dynamic_debug/control
304
305Examples
306========
307
308::
309
310  // enable the message at line 1603 of file svcsock.c
311  :#> ddcmd 'file svcsock.c line 1603 +p'
312
313  // enable all the messages in file svcsock.c
314  :#> ddcmd 'file svcsock.c +p'
315
316  // enable all the messages in the NFS server module
317  :#> ddcmd 'module nfsd +p'
318
319  // enable all 12 messages in the function svc_process()
320  :#> ddcmd 'func svc_process +p'
321
322  // disable all 12 messages in the function svc_process()
323  :#> ddcmd 'func svc_process -p'
324
325  // enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
326  :#> ddcmd 'format "nfsd: READ" +p'
327
328  // enable messages in files of which the paths include string "usb"
329  :#> ddcmd 'file *usb* +p'
330
331  // enable all messages
332  :#> ddcmd '+p'
333
334  // add module, function to all enabled messages
335  :#> ddcmd '+mf'
336
337  // boot-args example, with newlines and comments for readability
338  Kernel command line: ...
339    // see what's going on in dyndbg=value processing
340    dynamic_debug.verbose=3
341    // enable pr_debugs in the btrfs module (can be builtin or loadable)
342    btrfs.dyndbg="+p"
343    // enable pr_debugs in all files under init/
344    // and the function parse_one, #cmt is stripped
345    dyndbg="file init/* +p #cmt ; func parse_one +p"
346    // enable pr_debugs in 2 functions in a module loaded later
347    pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p"
348
349Kernel Configuration
350====================
351
352Dynamic Debug is enabled via kernel config items::
353
354  CONFIG_DYNAMIC_DEBUG=y	# build catalog, enables CORE
355  CONFIG_DYNAMIC_DEBUG_CORE=y	# enable mechanics only, skip catalog
356
357If you do not want to enable dynamic debug globally (i.e. in some embedded
358system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic
359debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any
360modules which you'd like to dynamically debug later.
361
362
363Kernel *prdbg* API
364==================
365
366The following functions are cataloged and controllable when dynamic
367debug is enabled::
368
369  pr_debug()
370  dev_dbg()
371  print_hex_dump_debug()
372  print_hex_dump_bytes()
373
374Otherwise, they are off by default; ``ccflags += -DDEBUG`` or
375``#define DEBUG`` in a source file will enable them appropriately.
376
377If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is
378just a shortcut for ``print_hex_dump(KERN_DEBUG)``.
379
380For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is
381its ``prefix_str`` argument, if it is constant string; or ``hexdump``
382in case ``prefix_str`` is built dynamically.
v6.8
  1Dynamic debug
  2+++++++++++++
  3
  4
  5Introduction
  6============
  7
  8Dynamic debug allows you to dynamically enable/disable kernel
  9debug-print code to obtain additional kernel information.
 10
 11If ``/proc/dynamic_debug/control`` exists, your kernel has dynamic
 12debug.  You'll need root access (sudo su) to use this.
 13
 14Dynamic debug provides:
 15
 16 * a Catalog of all *prdbgs* in your kernel.
 17   ``cat /proc/dynamic_debug/control`` to see them.
 18
 19 * a Simple query/command language to alter *prdbgs* by selecting on
 20   any combination of 0 or 1 of:
 21
 22   - source filename
 23   - function name
 24   - line number (including ranges of line numbers)
 25   - module name
 26   - format string
 27   - class name (as known/declared by each module)
 28
 
 
 
 
 
 29Viewing Dynamic Debug Behaviour
 30===============================
 31
 32You can view the currently configured behaviour in the *prdbg* catalog::
 33
 34  :#> head -n7 /proc/dynamic_debug/control
 35  # filename:lineno [module]function flags format
 36  init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012
 37  init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012"
 38  init/main.c:1424 [main]run_init_process =_ "  with arguments:\012"
 39  init/main.c:1426 [main]run_init_process =_ "    %s\012"
 40  init/main.c:1427 [main]run_init_process =_ "  with environment:\012"
 41  init/main.c:1429 [main]run_init_process =_ "    %s\012"
 42
 43The 3rd space-delimited column shows the current flags, preceded by
 44a ``=`` for easy use with grep/cut. ``=p`` shows enabled callsites.
 45
 46Controlling dynamic debug Behaviour
 47===================================
 48
 49The behaviour of *prdbg* sites are controlled by writing
 50query/commands to the control file.  Example::
 51
 52  # grease the interface
 53  :#> alias ddcmd='echo $* > /proc/dynamic_debug/control'
 54
 55  :#> ddcmd '-p; module main func run* +p'
 56  :#> grep =p /proc/dynamic_debug/control
 57  init/main.c:1424 [main]run_init_process =p "  with arguments:\012"
 58  init/main.c:1426 [main]run_init_process =p "    %s\012"
 59  init/main.c:1427 [main]run_init_process =p "  with environment:\012"
 60  init/main.c:1429 [main]run_init_process =p "    %s\012"
 61
 62Error messages go to console/syslog::
 63
 64  :#> ddcmd mode foo +p
 65  dyndbg: unknown keyword "mode"
 66  dyndbg: query parse failed
 67  bash: echo: write error: Invalid argument
 68
 69If debugfs is also enabled and mounted, ``dynamic_debug/control`` is
 70also under the mount-dir, typically ``/sys/kernel/debug/``.
 71
 72Command Language Reference
 73==========================
 74
 75At the basic lexical level, a command is a sequence of words separated
 76by spaces or tabs.  So these are all equivalent::
 77
 78  :#> ddcmd file svcsock.c line 1603 +p
 79  :#> ddcmd "file svcsock.c line 1603 +p"
 80  :#> ddcmd '  file   svcsock.c     line  1603 +p  '
 81
 82Command submissions are bounded by a write() system call.
 83Multiple commands can be written together, separated by ``;`` or ``\n``::
 84
 85  :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p"
 86  :#> ddcmd <<"EOC"
 87  func pnpacpi_get_resources +p
 88  func pnp_assign_mem +p
 89  EOC
 90  :#> cat query-batch-file > /proc/dynamic_debug/control
 91
 92You can also use wildcards in each query term. The match rule supports
 93``*`` (matches zero or more characters) and ``?`` (matches exactly one
 94character). For example, you can match all usb drivers::
 95
 96  :#> ddcmd file "drivers/usb/*" +p	# "" to suppress shell expansion
 97
 98Syntactically, a command is pairs of keyword values, followed by a
 99flags change or setting::
100
101  command ::= match-spec* flags-spec
102
103The match-spec's select *prdbgs* from the catalog, upon which to apply
104the flags-spec, all constraints are ANDed together.  An absent keyword
105is the same as keyword "*".
106
107
108A match specification is a keyword, which selects the attribute of
109the callsite to be compared, and a value to compare against.  Possible
110keywords are:::
111
112  match-spec ::= 'func' string |
113		 'file' string |
114		 'module' string |
115		 'format' string |
116		 'class' string |
117		 'line' line-range
118
119  line-range ::= lineno |
120		 '-'lineno |
121		 lineno'-' |
122		 lineno'-'lineno
123
124  lineno ::= unsigned-int
125
126.. note::
127
128  ``line-range`` cannot contain space, e.g.
129  "1-30" is valid range but "1 - 30" is not.
130
131
132The meanings of each keyword are:
133
134func
135    The given string is compared against the function name
136    of each callsite.  Example::
137
138	func svc_tcp_accept
139	func *recv*		# in rfcomm, bluetooth, ping, tcp
140
141file
142    The given string is compared against either the src-root relative
143    pathname, or the basename of the source file of each callsite.
144    Examples::
145
146	file svcsock.c
147	file kernel/freezer.c	# ie column 1 of control file
148	file drivers/usb/*	# all callsites under it
149	file inode.c:start_*	# parse :tail as a func (above)
150	file inode.c:1-100	# parse :tail as a line-range (above)
151
152module
153    The given string is compared against the module name
154    of each callsite.  The module name is the string as
155    seen in ``lsmod``, i.e. without the directory or the ``.ko``
156    suffix and with ``-`` changed to ``_``.  Examples::
157
158	module sunrpc
159	module nfsd
160	module drm*	# both drm, drm_kms_helper
161
162format
163    The given string is searched for in the dynamic debug format
164    string.  Note that the string does not need to match the
165    entire format, only some part.  Whitespace and other
166    special characters can be escaped using C octal character
167    escape ``\ooo`` notation, e.g. the space character is ``\040``.
168    Alternatively, the string can be enclosed in double quote
169    characters (``"``) or single quote characters (``'``).
170    Examples::
171
172	format svcrdma:         // many of the NFS/RDMA server pr_debugs
173	format readahead        // some pr_debugs in the readahead cache
174	format nfsd:\040SETATTR // one way to match a format with whitespace
175	format "nfsd: SETATTR"  // a neater way to match a format with whitespace
176	format 'nfsd: SETATTR'  // yet another way to match a format with whitespace
177
178class
179    The given class_name is validated against each module, which may
180    have declared a list of known class_names.  If the class_name is
181    found for a module, callsite & class matching and adjustment
182    proceeds.  Examples::
183
184	class DRM_UT_KMS	# a DRM.debug category
185	class JUNK		# silent non-match
186	// class TLD_*		# NOTICE: no wildcard in class names
187
188line
189    The given line number or range of line numbers is compared
190    against the line number of each ``pr_debug()`` callsite.  A single
191    line number matches the callsite line number exactly.  A
192    range of line numbers matches any callsite between the first
193    and last line number inclusive.  An empty first number means
194    the first line in the file, an empty last line number means the
195    last line number in the file.  Examples::
196
197	line 1603           // exactly line 1603
198	line 1600-1605      // the six lines from line 1600 to line 1605
199	line -1605          // the 1605 lines from line 1 to line 1605
200	line 1600-          // all lines from line 1600 to the end of the file
201
202The flags specification comprises a change operation followed
203by one or more flag characters.  The change operation is one
204of the characters::
205
206  -    remove the given flags
207  +    add the given flags
208  =    set the flags to the given flags
209
210The flags are::
211
212  p    enables the pr_debug() callsite.
213  _    enables no flags.
214
215  Decorator flags add to the message-prefix, in order:
216  t    Include thread ID, or <intr>
217  m    Include module name
218  f    Include the function name
219  s    Include the source file name
220  l    Include line number
221
222For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only
223the ``p`` flag has meaning, other flags are ignored.
224
225Note the regexp ``^[-+=][fslmpt_]+$`` matches a flags specification.
226To clear all flags at once, use ``=_`` or ``-fslmpt``.
227
228
229Debug messages during Boot Process
230==================================
231
232To activate debug messages for core code and built-in modules during
233the boot process, even before userspace and debugfs exists, use
234``dyndbg="QUERY"`` or ``module.dyndbg="QUERY"``.  QUERY follows
235the syntax described above, but must not exceed 1023 characters.  Your
236bootloader may impose lower limits.
237
238These ``dyndbg`` params are processed just after the ddebug tables are
239processed, as part of the early_initcall.  Thus you can enable debug
240messages in all code run after this early_initcall via this boot
241parameter.
242
243On an x86 system for example ACPI enablement is a subsys_initcall and::
244
245   dyndbg="file ec.c +p"
246
247will show early Embedded Controller transactions during ACPI setup if
248your machine (typically a laptop) has an Embedded Controller.
249PCI (or other devices) initialization also is a hot candidate for using
250this boot parameter for debugging purposes.
251
252If ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at
253boot time, without effect, but will be reprocessed when module is
254loaded later. Bare ``dyndbg=`` is only processed at boot.
255
256
257Debug Messages at Module Initialization Time
258============================================
259
260When ``modprobe foo`` is called, modprobe scans ``/proc/cmdline`` for
261``foo.params``, strips ``foo.``, and passes them to the kernel along with
262params given in modprobe args or ``/etc/modprobe.d/*.conf`` files,
263in the following order:
264
2651. parameters given via ``/etc/modprobe.d/*.conf``::
266
267	options foo dyndbg=+pt
268	options foo dyndbg # defaults to +p
269
2702. ``foo.dyndbg`` as given in boot args, ``foo.`` is stripped and passed::
271
272	foo.dyndbg=" func bar +p; func buz +mp"
273
2743. args to modprobe::
275
276	modprobe foo dyndbg==pmf # override previous settings
277
278These ``dyndbg`` queries are applied in order, with last having final say.
279This allows boot args to override or modify those from ``/etc/modprobe.d``
280(sensible, since 1 is system wide, 2 is kernel or boot specific), and
281modprobe args to override both.
282
283In the ``foo.dyndbg="QUERY"`` form, the query must exclude ``module foo``.
284``foo`` is extracted from the param-name, and applied to each query in
285``QUERY``, and only 1 match-spec of each type is allowed.
286
287The ``dyndbg`` option is a "fake" module parameter, which means:
288
289- modules do not need to define it explicitly
290- every module gets it tacitly, whether they use pr_debug or not
291- it doesn't appear in ``/sys/module/$module/parameters/``
292  To see it, grep the control file, or inspect ``/proc/cmdline.``
293
294For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or
295enabled by ``-DDEBUG`` flag during compilation) can be disabled later via
296the debugfs interface if the debug messages are no longer needed::
297
298   echo "module module_name -p" > /proc/dynamic_debug/control
299
300Examples
301========
302
303::
304
305  // enable the message at line 1603 of file svcsock.c
306  :#> ddcmd 'file svcsock.c line 1603 +p'
307
308  // enable all the messages in file svcsock.c
309  :#> ddcmd 'file svcsock.c +p'
310
311  // enable all the messages in the NFS server module
312  :#> ddcmd 'module nfsd +p'
313
314  // enable all 12 messages in the function svc_process()
315  :#> ddcmd 'func svc_process +p'
316
317  // disable all 12 messages in the function svc_process()
318  :#> ddcmd 'func svc_process -p'
319
320  // enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
321  :#> ddcmd 'format "nfsd: READ" +p'
322
323  // enable messages in files of which the paths include string "usb"
324  :#> ddcmd 'file *usb* +p'
325
326  // enable all messages
327  :#> ddcmd '+p'
328
329  // add module, function to all enabled messages
330  :#> ddcmd '+mf'
331
332  // boot-args example, with newlines and comments for readability
333  Kernel command line: ...
334    // see what's going on in dyndbg=value processing
335    dynamic_debug.verbose=3
336    // enable pr_debugs in the btrfs module (can be builtin or loadable)
337    btrfs.dyndbg="+p"
338    // enable pr_debugs in all files under init/
339    // and the function parse_one, #cmt is stripped
340    dyndbg="file init/* +p #cmt ; func parse_one +p"
341    // enable pr_debugs in 2 functions in a module loaded later
342    pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p"
343
344Kernel Configuration
345====================
346
347Dynamic Debug is enabled via kernel config items::
348
349  CONFIG_DYNAMIC_DEBUG=y	# build catalog, enables CORE
350  CONFIG_DYNAMIC_DEBUG_CORE=y	# enable mechanics only, skip catalog
351
352If you do not want to enable dynamic debug globally (i.e. in some embedded
353system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic
354debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any
355modules which you'd like to dynamically debug later.
356
357
358Kernel *prdbg* API
359==================
360
361The following functions are cataloged and controllable when dynamic
362debug is enabled::
363
364  pr_debug()
365  dev_dbg()
366  print_hex_dump_debug()
367  print_hex_dump_bytes()
368
369Otherwise, they are off by default; ``ccflags += -DDEBUG`` or
370``#define DEBUG`` in a source file will enable them appropriately.
371
372If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is
373just a shortcut for ``print_hex_dump(KERN_DEBUG)``.
374
375For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is
376its ``prefix_str`` argument, if it is constant string; or ``hexdump``
377in case ``prefix_str`` is built dynamically.