xref: /linux/Documentation/admin-guide/dynamic-debug-howto.rst (revision fa0805207066ce3bdc414fb14fda95a3b7ba87bb)
19d85025bSMauro Carvalho ChehabDynamic debug
29d85025bSMauro Carvalho Chehab+++++++++++++
39d85025bSMauro Carvalho Chehab
49d85025bSMauro Carvalho Chehab
59d85025bSMauro Carvalho ChehabIntroduction
69d85025bSMauro Carvalho Chehab============
79d85025bSMauro Carvalho Chehab
89d85025bSMauro Carvalho ChehabThis document describes how to use the dynamic debug (dyndbg) feature.
99d85025bSMauro Carvalho Chehab
109d85025bSMauro Carvalho ChehabDynamic debug is designed to allow you to dynamically enable/disable
119d85025bSMauro Carvalho Chehabkernel code to obtain additional kernel information.  Currently, if
129d85025bSMauro Carvalho Chehab``CONFIG_DYNAMIC_DEBUG`` is set, then all ``pr_debug()``/``dev_dbg()`` and
139d85025bSMauro Carvalho Chehab``print_hex_dump_debug()``/``print_hex_dump_bytes()`` calls can be dynamically
149d85025bSMauro Carvalho Chehabenabled per-callsite.
159d85025bSMauro Carvalho Chehab
16ceabef7dSOrson ZhaiIf you do not want to enable dynamic debug globally (i.e. in some embedded
17ceabef7dSOrson Zhaisystem), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic
18ceabef7dSOrson Zhaidebug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any
19ceabef7dSOrson Zhaimodules which you'd like to dynamically debug later.
20ceabef7dSOrson Zhai
219d85025bSMauro Carvalho ChehabIf ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is just
229d85025bSMauro Carvalho Chehabshortcut for ``print_hex_dump(KERN_DEBUG)``.
239d85025bSMauro Carvalho Chehab
249d85025bSMauro Carvalho ChehabFor ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is
259d85025bSMauro Carvalho Chehabits ``prefix_str`` argument, if it is constant string; or ``hexdump``
268c188759SRandy Dunlapin case ``prefix_str`` is built dynamically.
279d85025bSMauro Carvalho Chehab
289d85025bSMauro Carvalho ChehabDynamic debug has even more useful features:
299d85025bSMauro Carvalho Chehab
309d85025bSMauro Carvalho Chehab * Simple query language allows turning on and off debugging
319d85025bSMauro Carvalho Chehab   statements by matching any combination of 0 or 1 of:
329d85025bSMauro Carvalho Chehab
339d85025bSMauro Carvalho Chehab   - source filename
349d85025bSMauro Carvalho Chehab   - function name
359d85025bSMauro Carvalho Chehab   - line number (including ranges of line numbers)
369d85025bSMauro Carvalho Chehab   - module name
379d85025bSMauro Carvalho Chehab   - format string
389d85025bSMauro Carvalho Chehab
399d85025bSMauro Carvalho Chehab * Provides a debugfs control file: ``<debugfs>/dynamic_debug/control``
409d85025bSMauro Carvalho Chehab   which can be read to display the complete list of known debug
419d85025bSMauro Carvalho Chehab   statements, to help guide you
429d85025bSMauro Carvalho Chehab
439d85025bSMauro Carvalho ChehabControlling dynamic debug Behaviour
449d85025bSMauro Carvalho Chehab===================================
459d85025bSMauro Carvalho Chehab
469d85025bSMauro Carvalho ChehabThe behaviour of ``pr_debug()``/``dev_dbg()`` are controlled via writing to a
479d85025bSMauro Carvalho Chehabcontrol file in the 'debugfs' filesystem. Thus, you must first mount
489d85025bSMauro Carvalho Chehabthe debugfs filesystem, in order to make use of this feature.
499d85025bSMauro Carvalho ChehabSubsequently, we refer to the control file as:
509d85025bSMauro Carvalho Chehab``<debugfs>/dynamic_debug/control``. For example, if you want to enable
519d85025bSMauro Carvalho Chehabprinting from source file ``svcsock.c``, line 1603 you simply do::
529d85025bSMauro Carvalho Chehab
539d85025bSMauro Carvalho Chehab  nullarbor:~ # echo 'file svcsock.c line 1603 +p' >
549d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
559d85025bSMauro Carvalho Chehab
569d85025bSMauro Carvalho ChehabIf you make a mistake with the syntax, the write will fail thus::
579d85025bSMauro Carvalho Chehab
589d85025bSMauro Carvalho Chehab  nullarbor:~ # echo 'file svcsock.c wtf 1 +p' >
599d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
609d85025bSMauro Carvalho Chehab  -bash: echo: write error: Invalid argument
619d85025bSMauro Carvalho Chehab
62239a5791SGreg Kroah-HartmanNote, for systems without 'debugfs' enabled, the control file can be
63239a5791SGreg Kroah-Hartmanfound in ``/proc/dynamic_debug/control``.
64239a5791SGreg Kroah-Hartman
659d85025bSMauro Carvalho ChehabViewing Dynamic Debug Behaviour
669d85025bSMauro Carvalho Chehab===============================
679d85025bSMauro Carvalho Chehab
689d85025bSMauro Carvalho ChehabYou can view the currently configured behaviour of all the debug
699d85025bSMauro Carvalho Chehabstatements via::
709d85025bSMauro Carvalho Chehab
719d85025bSMauro Carvalho Chehab  nullarbor:~ # cat <debugfs>/dynamic_debug/control
729d85025bSMauro Carvalho Chehab  # filename:lineno [module]function flags format
73e20e310cSJim Cromie  net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012"
74e20e310cSJim Cromie  net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline       : %d\012"
75e20e310cSJim Cromie  net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth         : %d\012"
76e20e310cSJim Cromie  net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests     : %d\012"
779d85025bSMauro Carvalho Chehab  ...
789d85025bSMauro Carvalho Chehab
799d85025bSMauro Carvalho Chehab
809d85025bSMauro Carvalho ChehabYou can also apply standard Unix text manipulation filters to this
819d85025bSMauro Carvalho Chehabdata, e.g.::
829d85025bSMauro Carvalho Chehab
839d85025bSMauro Carvalho Chehab  nullarbor:~ # grep -i rdma <debugfs>/dynamic_debug/control  | wc -l
849d85025bSMauro Carvalho Chehab  62
859d85025bSMauro Carvalho Chehab
869d85025bSMauro Carvalho Chehab  nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l
879d85025bSMauro Carvalho Chehab  42
889d85025bSMauro Carvalho Chehab
899d85025bSMauro Carvalho ChehabThe third column shows the currently enabled flags for each debug
909d85025bSMauro Carvalho Chehabstatement callsite (see below for definitions of the flags).  The
919d85025bSMauro Carvalho Chehabdefault value, with no flags enabled, is ``=_``.  So you can view all
929d85025bSMauro Carvalho Chehabthe debug statement callsites with any non-default flags::
939d85025bSMauro Carvalho Chehab
949d85025bSMauro Carvalho Chehab  nullarbor:~ # awk '$3 != "=_"' <debugfs>/dynamic_debug/control
959d85025bSMauro Carvalho Chehab  # filename:lineno [module]function flags format
96e20e310cSJim Cromie  net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012"
979d85025bSMauro Carvalho Chehab
989d85025bSMauro Carvalho ChehabCommand Language Reference
999d85025bSMauro Carvalho Chehab==========================
1009d85025bSMauro Carvalho Chehab
1019d85025bSMauro Carvalho ChehabAt the lexical level, a command comprises a sequence of words separated
1029d85025bSMauro Carvalho Chehabby spaces or tabs.  So these are all equivalent::
1039d85025bSMauro Carvalho Chehab
10431fc93d5SSteven Price  nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
1059d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
10631fc93d5SSteven Price  nullarbor:~ # echo -n '  file   svcsock.c     line  1603 +p  ' >
1079d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
1089d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
1099d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
1109d85025bSMauro Carvalho Chehab
1119d85025bSMauro Carvalho ChehabCommand submissions are bounded by a write() system call.
1129d85025bSMauro Carvalho ChehabMultiple commands can be written together, separated by ``;`` or ``\n``::
1139d85025bSMauro Carvalho Chehab
1149d85025bSMauro Carvalho Chehab  ~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \
1159d85025bSMauro Carvalho Chehab     > <debugfs>/dynamic_debug/control
1169d85025bSMauro Carvalho Chehab
1179d85025bSMauro Carvalho ChehabIf your query set is big, you can batch them too::
1189d85025bSMauro Carvalho Chehab
1199d85025bSMauro Carvalho Chehab  ~# cat query-batch-file > <debugfs>/dynamic_debug/control
1209d85025bSMauro Carvalho Chehab
1211afc5fb5SRandy DunlapAnother way is to use wildcards. The match rule supports ``*`` (matches
1229d85025bSMauro Carvalho Chehabzero or more characters) and ``?`` (matches exactly one character). For
1239d85025bSMauro Carvalho Chehabexample, you can match all usb drivers::
1249d85025bSMauro Carvalho Chehab
1259d85025bSMauro Carvalho Chehab  ~# echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control
1269d85025bSMauro Carvalho Chehab
1279d85025bSMauro Carvalho ChehabAt the syntactical level, a command comprises a sequence of match
1289d85025bSMauro Carvalho Chehabspecifications, followed by a flags change specification::
1299d85025bSMauro Carvalho Chehab
1309d85025bSMauro Carvalho Chehab  command ::= match-spec* flags-spec
1319d85025bSMauro Carvalho Chehab
1329d85025bSMauro Carvalho ChehabThe match-spec's are used to choose a subset of the known pr_debug()
1339d85025bSMauro Carvalho Chehabcallsites to which to apply the flags-spec.  Think of them as a query
1349d85025bSMauro Carvalho Chehabwith implicit ANDs between each pair.  Note that an empty list of
1359d85025bSMauro Carvalho Chehabmatch-specs will select all debug statement callsites.
1369d85025bSMauro Carvalho Chehab
1379d85025bSMauro Carvalho ChehabA match specification comprises a keyword, which controls the
1389d85025bSMauro Carvalho Chehabattribute of the callsite to be compared, and a value to compare
1399d85025bSMauro Carvalho Chehabagainst.  Possible keywords are:::
1409d85025bSMauro Carvalho Chehab
1419d85025bSMauro Carvalho Chehab  match-spec ::= 'func' string |
1429d85025bSMauro Carvalho Chehab		 'file' string |
1439d85025bSMauro Carvalho Chehab		 'module' string |
1449d85025bSMauro Carvalho Chehab		 'format' string |
1459d85025bSMauro Carvalho Chehab		 'line' line-range
1469d85025bSMauro Carvalho Chehab
1479d85025bSMauro Carvalho Chehab  line-range ::= lineno |
1489d85025bSMauro Carvalho Chehab		 '-'lineno |
1499d85025bSMauro Carvalho Chehab		 lineno'-' |
1509d85025bSMauro Carvalho Chehab		 lineno'-'lineno
1519d85025bSMauro Carvalho Chehab
1529d85025bSMauro Carvalho Chehab  lineno ::= unsigned-int
1539d85025bSMauro Carvalho Chehab
1549d85025bSMauro Carvalho Chehab.. note::
1559d85025bSMauro Carvalho Chehab
1569d85025bSMauro Carvalho Chehab  ``line-range`` cannot contain space, e.g.
1579d85025bSMauro Carvalho Chehab  "1-30" is valid range but "1 - 30" is not.
1589d85025bSMauro Carvalho Chehab
1599d85025bSMauro Carvalho Chehab
1609d85025bSMauro Carvalho ChehabThe meanings of each keyword are:
1619d85025bSMauro Carvalho Chehab
1629d85025bSMauro Carvalho Chehabfunc
1639d85025bSMauro Carvalho Chehab    The given string is compared against the function name
1649d85025bSMauro Carvalho Chehab    of each callsite.  Example::
1659d85025bSMauro Carvalho Chehab
1669d85025bSMauro Carvalho Chehab	func svc_tcp_accept
1679d85025bSMauro Carvalho Chehab
1689d85025bSMauro Carvalho Chehabfile
169e20e310cSJim Cromie    The given string is compared against either the src-root relative
170e20e310cSJim Cromie    pathname, or the basename of the source file of each callsite.
171e20e310cSJim Cromie    Examples::
1729d85025bSMauro Carvalho Chehab
1739d85025bSMauro Carvalho Chehab	file svcsock.c
174e20e310cSJim Cromie	file kernel/freezer.c	# ie column 1 of control file
1759d85025bSMauro Carvalho Chehab
1769d85025bSMauro Carvalho Chehabmodule
1779d85025bSMauro Carvalho Chehab    The given string is compared against the module name
1789d85025bSMauro Carvalho Chehab    of each callsite.  The module name is the string as
1799d85025bSMauro Carvalho Chehab    seen in ``lsmod``, i.e. without the directory or the ``.ko``
1809d85025bSMauro Carvalho Chehab    suffix and with ``-`` changed to ``_``.  Examples::
1819d85025bSMauro Carvalho Chehab
1829d85025bSMauro Carvalho Chehab	module sunrpc
1839d85025bSMauro Carvalho Chehab	module nfsd
1849d85025bSMauro Carvalho Chehab
1859d85025bSMauro Carvalho Chehabformat
1869d85025bSMauro Carvalho Chehab    The given string is searched for in the dynamic debug format
1879d85025bSMauro Carvalho Chehab    string.  Note that the string does not need to match the
1889d85025bSMauro Carvalho Chehab    entire format, only some part.  Whitespace and other
1899d85025bSMauro Carvalho Chehab    special characters can be escaped using C octal character
1909d85025bSMauro Carvalho Chehab    escape ``\ooo`` notation, e.g. the space character is ``\040``.
1919d85025bSMauro Carvalho Chehab    Alternatively, the string can be enclosed in double quote
1929d85025bSMauro Carvalho Chehab    characters (``"``) or single quote characters (``'``).
1939d85025bSMauro Carvalho Chehab    Examples::
1949d85025bSMauro Carvalho Chehab
1959d85025bSMauro Carvalho Chehab	format svcrdma:         // many of the NFS/RDMA server pr_debugs
1969d85025bSMauro Carvalho Chehab	format readahead        // some pr_debugs in the readahead cache
1979d85025bSMauro Carvalho Chehab	format nfsd:\040SETATTR // one way to match a format with whitespace
1989d85025bSMauro Carvalho Chehab	format "nfsd: SETATTR"  // a neater way to match a format with whitespace
1999d85025bSMauro Carvalho Chehab	format 'nfsd: SETATTR'  // yet another way to match a format with whitespace
2009d85025bSMauro Carvalho Chehab
2019d85025bSMauro Carvalho Chehabline
2029d85025bSMauro Carvalho Chehab    The given line number or range of line numbers is compared
2039d85025bSMauro Carvalho Chehab    against the line number of each ``pr_debug()`` callsite.  A single
2049d85025bSMauro Carvalho Chehab    line number matches the callsite line number exactly.  A
2059d85025bSMauro Carvalho Chehab    range of line numbers matches any callsite between the first
2069d85025bSMauro Carvalho Chehab    and last line number inclusive.  An empty first number means
2078c188759SRandy Dunlap    the first line in the file, an empty last line number means the
2088c188759SRandy Dunlap    last line number in the file.  Examples::
2099d85025bSMauro Carvalho Chehab
2109d85025bSMauro Carvalho Chehab	line 1603           // exactly line 1603
2119d85025bSMauro Carvalho Chehab	line 1600-1605      // the six lines from line 1600 to line 1605
2129d85025bSMauro Carvalho Chehab	line -1605          // the 1605 lines from line 1 to line 1605
2139d85025bSMauro Carvalho Chehab	line 1600-          // all lines from line 1600 to the end of the file
2149d85025bSMauro Carvalho Chehab
2159d85025bSMauro Carvalho ChehabThe flags specification comprises a change operation followed
2169d85025bSMauro Carvalho Chehabby one or more flag characters.  The change operation is one
2179d85025bSMauro Carvalho Chehabof the characters::
2189d85025bSMauro Carvalho Chehab
2199d85025bSMauro Carvalho Chehab  -    remove the given flags
2209d85025bSMauro Carvalho Chehab  +    add the given flags
2219d85025bSMauro Carvalho Chehab  =    set the flags to the given flags
2229d85025bSMauro Carvalho Chehab
2239d85025bSMauro Carvalho ChehabThe flags are::
2249d85025bSMauro Carvalho Chehab
2259d85025bSMauro Carvalho Chehab  p    enables the pr_debug() callsite.
2269d85025bSMauro Carvalho Chehab  f    Include the function name in the printed message
2279d85025bSMauro Carvalho Chehab  l    Include line number in the printed message
2289d85025bSMauro Carvalho Chehab  m    Include module name in the printed message
2299d85025bSMauro Carvalho Chehab  t    Include thread ID in messages not generated from interrupt context
2309d85025bSMauro Carvalho Chehab  _    No flags are set. (Or'd with others on input)
2319d85025bSMauro Carvalho Chehab
2329d85025bSMauro Carvalho ChehabFor ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` flag
2339d85025bSMauro Carvalho Chehabhave meaning, other flags ignored.
2349d85025bSMauro Carvalho Chehab
2359d85025bSMauro Carvalho ChehabFor display, the flags are preceded by ``=``
2369d85025bSMauro Carvalho Chehab(mnemonic: what the flags are currently equal to).
2379d85025bSMauro Carvalho Chehab
2389d85025bSMauro Carvalho ChehabNote the regexp ``^[-+=][flmpt_]+$`` matches a flags specification.
2399d85025bSMauro Carvalho ChehabTo clear all flags at once, use ``=_`` or ``-flmpt``.
2409d85025bSMauro Carvalho Chehab
2419d85025bSMauro Carvalho Chehab
2429d85025bSMauro Carvalho ChehabDebug messages during Boot Process
2439d85025bSMauro Carvalho Chehab==================================
2449d85025bSMauro Carvalho Chehab
2459d85025bSMauro Carvalho ChehabTo activate debug messages for core code and built-in modules during
2469d85025bSMauro Carvalho Chehabthe boot process, even before userspace and debugfs exists, use
2479d85025bSMauro Carvalho Chehab``dyndbg="QUERY"``, ``module.dyndbg="QUERY"``, or ``ddebug_query="QUERY"``
2489d85025bSMauro Carvalho Chehab(``ddebug_query`` is obsoleted by ``dyndbg``, and deprecated).  QUERY follows
2499d85025bSMauro Carvalho Chehabthe syntax described above, but must not exceed 1023 characters.  Your
2509d85025bSMauro Carvalho Chehabbootloader may impose lower limits.
2519d85025bSMauro Carvalho Chehab
2529d85025bSMauro Carvalho ChehabThese ``dyndbg`` params are processed just after the ddebug tables are
253*fa080520SJim Cromieprocessed, as part of the early_initcall.  Thus you can enable debug
254*fa080520SJim Cromiemessages in all code run after this early_initcall via this boot
2559d85025bSMauro Carvalho Chehabparameter.
2569d85025bSMauro Carvalho Chehab
2579d85025bSMauro Carvalho ChehabOn an x86 system for example ACPI enablement is a subsys_initcall and::
2589d85025bSMauro Carvalho Chehab
2599d85025bSMauro Carvalho Chehab   dyndbg="file ec.c +p"
2609d85025bSMauro Carvalho Chehab
2619d85025bSMauro Carvalho Chehabwill show early Embedded Controller transactions during ACPI setup if
2629d85025bSMauro Carvalho Chehabyour machine (typically a laptop) has an Embedded Controller.
2639d85025bSMauro Carvalho ChehabPCI (or other devices) initialization also is a hot candidate for using
2649d85025bSMauro Carvalho Chehabthis boot parameter for debugging purposes.
2659d85025bSMauro Carvalho Chehab
2669d85025bSMauro Carvalho ChehabIf ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at
2679d85025bSMauro Carvalho Chehabboot time, without effect, but will be reprocessed when module is
268005ae6dfSRandy Dunlaploaded later. ``ddebug_query=`` and bare ``dyndbg=`` are only processed at
2699d85025bSMauro Carvalho Chehabboot.
2709d85025bSMauro Carvalho Chehab
2719d85025bSMauro Carvalho Chehab
2729d85025bSMauro Carvalho ChehabDebug Messages at Module Initialization Time
2739d85025bSMauro Carvalho Chehab============================================
2749d85025bSMauro Carvalho Chehab
2759d85025bSMauro Carvalho ChehabWhen ``modprobe foo`` is called, modprobe scans ``/proc/cmdline`` for
2769d85025bSMauro Carvalho Chehab``foo.params``, strips ``foo.``, and passes them to the kernel along with
2779d85025bSMauro Carvalho Chehabparams given in modprobe args or ``/etc/modprob.d/*.conf`` files,
2789d85025bSMauro Carvalho Chehabin the following order:
2799d85025bSMauro Carvalho Chehab
2809d85025bSMauro Carvalho Chehab1. parameters given via ``/etc/modprobe.d/*.conf``::
2819d85025bSMauro Carvalho Chehab
2829d85025bSMauro Carvalho Chehab	options foo dyndbg=+pt
2839d85025bSMauro Carvalho Chehab	options foo dyndbg # defaults to +p
2849d85025bSMauro Carvalho Chehab
2859d85025bSMauro Carvalho Chehab2. ``foo.dyndbg`` as given in boot args, ``foo.`` is stripped and passed::
2869d85025bSMauro Carvalho Chehab
2879d85025bSMauro Carvalho Chehab	foo.dyndbg=" func bar +p; func buz +mp"
2889d85025bSMauro Carvalho Chehab
2899d85025bSMauro Carvalho Chehab3. args to modprobe::
2909d85025bSMauro Carvalho Chehab
2919d85025bSMauro Carvalho Chehab	modprobe foo dyndbg==pmf # override previous settings
2929d85025bSMauro Carvalho Chehab
2939d85025bSMauro Carvalho ChehabThese ``dyndbg`` queries are applied in order, with last having final say.
2949d85025bSMauro Carvalho ChehabThis allows boot args to override or modify those from ``/etc/modprobe.d``
2959d85025bSMauro Carvalho Chehab(sensible, since 1 is system wide, 2 is kernel or boot specific), and
2969d85025bSMauro Carvalho Chehabmodprobe args to override both.
2979d85025bSMauro Carvalho Chehab
2989d85025bSMauro Carvalho ChehabIn the ``foo.dyndbg="QUERY"`` form, the query must exclude ``module foo``.
2999d85025bSMauro Carvalho Chehab``foo`` is extracted from the param-name, and applied to each query in
3009d85025bSMauro Carvalho Chehab``QUERY``, and only 1 match-spec of each type is allowed.
3019d85025bSMauro Carvalho Chehab
3029d85025bSMauro Carvalho ChehabThe ``dyndbg`` option is a "fake" module parameter, which means:
3039d85025bSMauro Carvalho Chehab
3049d85025bSMauro Carvalho Chehab- modules do not need to define it explicitly
3059d85025bSMauro Carvalho Chehab- every module gets it tacitly, whether they use pr_debug or not
3069d85025bSMauro Carvalho Chehab- it doesn't appear in ``/sys/module/$module/parameters/``
3079d85025bSMauro Carvalho Chehab  To see it, grep the control file, or inspect ``/proc/cmdline.``
3089d85025bSMauro Carvalho Chehab
3099d85025bSMauro Carvalho ChehabFor ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or
3109d85025bSMauro Carvalho Chehabenabled by ``-DDEBUG`` flag during compilation) can be disabled later via
311005ae6dfSRandy Dunlapthe debugfs interface if the debug messages are no longer needed::
3129d85025bSMauro Carvalho Chehab
3139d85025bSMauro Carvalho Chehab   echo "module module_name -p" > <debugfs>/dynamic_debug/control
3149d85025bSMauro Carvalho Chehab
3159d85025bSMauro Carvalho ChehabExamples
3169d85025bSMauro Carvalho Chehab========
3179d85025bSMauro Carvalho Chehab
3189d85025bSMauro Carvalho Chehab::
3199d85025bSMauro Carvalho Chehab
3209d85025bSMauro Carvalho Chehab  // enable the message at line 1603 of file svcsock.c
3219d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
3229d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
3239d85025bSMauro Carvalho Chehab
3249d85025bSMauro Carvalho Chehab  // enable all the messages in file svcsock.c
3259d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n 'file svcsock.c +p' >
3269d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
3279d85025bSMauro Carvalho Chehab
3289d85025bSMauro Carvalho Chehab  // enable all the messages in the NFS server module
3299d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n 'module nfsd +p' >
3309d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
3319d85025bSMauro Carvalho Chehab
3329d85025bSMauro Carvalho Chehab  // enable all 12 messages in the function svc_process()
3339d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n 'func svc_process +p' >
3349d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
3359d85025bSMauro Carvalho Chehab
3369d85025bSMauro Carvalho Chehab  // disable all 12 messages in the function svc_process()
3379d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n 'func svc_process -p' >
3389d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
3399d85025bSMauro Carvalho Chehab
3409d85025bSMauro Carvalho Chehab  // enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
3419d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n 'format "nfsd: READ" +p' >
3429d85025bSMauro Carvalho Chehab				<debugfs>/dynamic_debug/control
3439d85025bSMauro Carvalho Chehab
3449d85025bSMauro Carvalho Chehab  // enable messages in files of which the paths include string "usb"
3459d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n '*usb* +p' > <debugfs>/dynamic_debug/control
3469d85025bSMauro Carvalho Chehab
3479d85025bSMauro Carvalho Chehab  // enable all messages
3489d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control
3499d85025bSMauro Carvalho Chehab
3509d85025bSMauro Carvalho Chehab  // add module, function to all enabled messages
3519d85025bSMauro Carvalho Chehab  nullarbor:~ # echo -n '+mf' > <debugfs>/dynamic_debug/control
3529d85025bSMauro Carvalho Chehab
3539d85025bSMauro Carvalho Chehab  // boot-args example, with newlines and comments for readability
3549d85025bSMauro Carvalho Chehab  Kernel command line: ...
3559d85025bSMauro Carvalho Chehab    // see whats going on in dyndbg=value processing
3569d85025bSMauro Carvalho Chehab    dynamic_debug.verbose=1
3579d85025bSMauro Carvalho Chehab    // enable pr_debugs in 2 builtins, #cmt is stripped
3589d85025bSMauro Carvalho Chehab    dyndbg="module params +p #cmt ; module sys +p"
3599d85025bSMauro Carvalho Chehab    // enable pr_debugs in 2 functions in a module loaded later
3609d85025bSMauro Carvalho Chehab    pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p"
361