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