162306a36Sopenharmony_ciDynamic debug 262306a36Sopenharmony_ci+++++++++++++ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciIntroduction 662306a36Sopenharmony_ci============ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciDynamic debug allows you to dynamically enable/disable kernel 962306a36Sopenharmony_cidebug-print code to obtain additional kernel information. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciIf ``/proc/dynamic_debug/control`` exists, your kernel has dynamic 1262306a36Sopenharmony_cidebug. You'll need root access (sudo su) to use this. 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciDynamic debug provides: 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci * a Catalog of all *prdbgs* in your kernel. 1762306a36Sopenharmony_ci ``cat /proc/dynamic_debug/control`` to see them. 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci * a Simple query/command language to alter *prdbgs* by selecting on 2062306a36Sopenharmony_ci any combination of 0 or 1 of: 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci - source filename 2362306a36Sopenharmony_ci - function name 2462306a36Sopenharmony_ci - line number (including ranges of line numbers) 2562306a36Sopenharmony_ci - module name 2662306a36Sopenharmony_ci - format string 2762306a36Sopenharmony_ci - class name (as known/declared by each module) 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciViewing Dynamic Debug Behaviour 3062306a36Sopenharmony_ci=============================== 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciYou can view the currently configured behaviour in the *prdbg* catalog:: 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci :#> head -n7 /proc/dynamic_debug/control 3562306a36Sopenharmony_ci # filename:lineno [module]function flags format 3662306a36Sopenharmony_ci init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012 3762306a36Sopenharmony_ci init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012" 3862306a36Sopenharmony_ci init/main.c:1424 [main]run_init_process =_ " with arguments:\012" 3962306a36Sopenharmony_ci init/main.c:1426 [main]run_init_process =_ " %s\012" 4062306a36Sopenharmony_ci init/main.c:1427 [main]run_init_process =_ " with environment:\012" 4162306a36Sopenharmony_ci init/main.c:1429 [main]run_init_process =_ " %s\012" 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciThe 3rd space-delimited column shows the current flags, preceded by 4462306a36Sopenharmony_cia ``=`` for easy use with grep/cut. ``=p`` shows enabled callsites. 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ciControlling dynamic debug Behaviour 4762306a36Sopenharmony_ci=================================== 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ciThe behaviour of *prdbg* sites are controlled by writing 5062306a36Sopenharmony_ciquery/commands to the control file. Example:: 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci # grease the interface 5362306a36Sopenharmony_ci :#> alias ddcmd='echo $* > /proc/dynamic_debug/control' 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci :#> ddcmd '-p; module main func run* +p' 5662306a36Sopenharmony_ci :#> grep =p /proc/dynamic_debug/control 5762306a36Sopenharmony_ci init/main.c:1424 [main]run_init_process =p " with arguments:\012" 5862306a36Sopenharmony_ci init/main.c:1426 [main]run_init_process =p " %s\012" 5962306a36Sopenharmony_ci init/main.c:1427 [main]run_init_process =p " with environment:\012" 6062306a36Sopenharmony_ci init/main.c:1429 [main]run_init_process =p " %s\012" 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ciError messages go to console/syslog:: 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci :#> ddcmd mode foo +p 6562306a36Sopenharmony_ci dyndbg: unknown keyword "mode" 6662306a36Sopenharmony_ci dyndbg: query parse failed 6762306a36Sopenharmony_ci bash: echo: write error: Invalid argument 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ciIf debugfs is also enabled and mounted, ``dynamic_debug/control`` is 7062306a36Sopenharmony_cialso under the mount-dir, typically ``/sys/kernel/debug/``. 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ciCommand Language Reference 7362306a36Sopenharmony_ci========================== 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciAt the basic lexical level, a command is a sequence of words separated 7662306a36Sopenharmony_ciby spaces or tabs. So these are all equivalent:: 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci :#> ddcmd file svcsock.c line 1603 +p 7962306a36Sopenharmony_ci :#> ddcmd "file svcsock.c line 1603 +p" 8062306a36Sopenharmony_ci :#> ddcmd ' file svcsock.c line 1603 +p ' 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ciCommand submissions are bounded by a write() system call. 8362306a36Sopenharmony_ciMultiple commands can be written together, separated by ``;`` or ``\n``:: 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" 8662306a36Sopenharmony_ci :#> ddcmd <<"EOC" 8762306a36Sopenharmony_ci func pnpacpi_get_resources +p 8862306a36Sopenharmony_ci func pnp_assign_mem +p 8962306a36Sopenharmony_ci EOC 9062306a36Sopenharmony_ci :#> cat query-batch-file > /proc/dynamic_debug/control 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ciYou can also use wildcards in each query term. The match rule supports 9362306a36Sopenharmony_ci``*`` (matches zero or more characters) and ``?`` (matches exactly one 9462306a36Sopenharmony_cicharacter). For example, you can match all usb drivers:: 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci :#> ddcmd file "drivers/usb/*" +p # "" to suppress shell expansion 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ciSyntactically, a command is pairs of keyword values, followed by a 9962306a36Sopenharmony_ciflags change or setting:: 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci command ::= match-spec* flags-spec 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ciThe match-spec's select *prdbgs* from the catalog, upon which to apply 10462306a36Sopenharmony_cithe flags-spec, all constraints are ANDed together. An absent keyword 10562306a36Sopenharmony_ciis the same as keyword "*". 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ciA match specification is a keyword, which selects the attribute of 10962306a36Sopenharmony_cithe callsite to be compared, and a value to compare against. Possible 11062306a36Sopenharmony_cikeywords are::: 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci match-spec ::= 'func' string | 11362306a36Sopenharmony_ci 'file' string | 11462306a36Sopenharmony_ci 'module' string | 11562306a36Sopenharmony_ci 'format' string | 11662306a36Sopenharmony_ci 'class' string | 11762306a36Sopenharmony_ci 'line' line-range 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci line-range ::= lineno | 12062306a36Sopenharmony_ci '-'lineno | 12162306a36Sopenharmony_ci lineno'-' | 12262306a36Sopenharmony_ci lineno'-'lineno 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci lineno ::= unsigned-int 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci.. note:: 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci ``line-range`` cannot contain space, e.g. 12962306a36Sopenharmony_ci "1-30" is valid range but "1 - 30" is not. 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ciThe meanings of each keyword are: 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_cifunc 13562306a36Sopenharmony_ci The given string is compared against the function name 13662306a36Sopenharmony_ci of each callsite. Example:: 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci func svc_tcp_accept 13962306a36Sopenharmony_ci func *recv* # in rfcomm, bluetooth, ping, tcp 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_cifile 14262306a36Sopenharmony_ci The given string is compared against either the src-root relative 14362306a36Sopenharmony_ci pathname, or the basename of the source file of each callsite. 14462306a36Sopenharmony_ci Examples:: 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci file svcsock.c 14762306a36Sopenharmony_ci file kernel/freezer.c # ie column 1 of control file 14862306a36Sopenharmony_ci file drivers/usb/* # all callsites under it 14962306a36Sopenharmony_ci file inode.c:start_* # parse :tail as a func (above) 15062306a36Sopenharmony_ci file inode.c:1-100 # parse :tail as a line-range (above) 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_cimodule 15362306a36Sopenharmony_ci The given string is compared against the module name 15462306a36Sopenharmony_ci of each callsite. The module name is the string as 15562306a36Sopenharmony_ci seen in ``lsmod``, i.e. without the directory or the ``.ko`` 15662306a36Sopenharmony_ci suffix and with ``-`` changed to ``_``. Examples:: 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci module sunrpc 15962306a36Sopenharmony_ci module nfsd 16062306a36Sopenharmony_ci module drm* # both drm, drm_kms_helper 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ciformat 16362306a36Sopenharmony_ci The given string is searched for in the dynamic debug format 16462306a36Sopenharmony_ci string. Note that the string does not need to match the 16562306a36Sopenharmony_ci entire format, only some part. Whitespace and other 16662306a36Sopenharmony_ci special characters can be escaped using C octal character 16762306a36Sopenharmony_ci escape ``\ooo`` notation, e.g. the space character is ``\040``. 16862306a36Sopenharmony_ci Alternatively, the string can be enclosed in double quote 16962306a36Sopenharmony_ci characters (``"``) or single quote characters (``'``). 17062306a36Sopenharmony_ci Examples:: 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci format svcrdma: // many of the NFS/RDMA server pr_debugs 17362306a36Sopenharmony_ci format readahead // some pr_debugs in the readahead cache 17462306a36Sopenharmony_ci format nfsd:\040SETATTR // one way to match a format with whitespace 17562306a36Sopenharmony_ci format "nfsd: SETATTR" // a neater way to match a format with whitespace 17662306a36Sopenharmony_ci format 'nfsd: SETATTR' // yet another way to match a format with whitespace 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ciclass 17962306a36Sopenharmony_ci The given class_name is validated against each module, which may 18062306a36Sopenharmony_ci have declared a list of known class_names. If the class_name is 18162306a36Sopenharmony_ci found for a module, callsite & class matching and adjustment 18262306a36Sopenharmony_ci proceeds. Examples:: 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci class DRM_UT_KMS # a DRM.debug category 18562306a36Sopenharmony_ci class JUNK # silent non-match 18662306a36Sopenharmony_ci // class TLD_* # NOTICE: no wildcard in class names 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ciline 18962306a36Sopenharmony_ci The given line number or range of line numbers is compared 19062306a36Sopenharmony_ci against the line number of each ``pr_debug()`` callsite. A single 19162306a36Sopenharmony_ci line number matches the callsite line number exactly. A 19262306a36Sopenharmony_ci range of line numbers matches any callsite between the first 19362306a36Sopenharmony_ci and last line number inclusive. An empty first number means 19462306a36Sopenharmony_ci the first line in the file, an empty last line number means the 19562306a36Sopenharmony_ci last line number in the file. Examples:: 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci line 1603 // exactly line 1603 19862306a36Sopenharmony_ci line 1600-1605 // the six lines from line 1600 to line 1605 19962306a36Sopenharmony_ci line -1605 // the 1605 lines from line 1 to line 1605 20062306a36Sopenharmony_ci line 1600- // all lines from line 1600 to the end of the file 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ciThe flags specification comprises a change operation followed 20362306a36Sopenharmony_ciby one or more flag characters. The change operation is one 20462306a36Sopenharmony_ciof the characters:: 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci - remove the given flags 20762306a36Sopenharmony_ci + add the given flags 20862306a36Sopenharmony_ci = set the flags to the given flags 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ciThe flags are:: 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ci p enables the pr_debug() callsite. 21362306a36Sopenharmony_ci _ enables no flags. 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci Decorator flags add to the message-prefix, in order: 21662306a36Sopenharmony_ci t Include thread ID, or <intr> 21762306a36Sopenharmony_ci m Include module name 21862306a36Sopenharmony_ci f Include the function name 21962306a36Sopenharmony_ci s Include the source file name 22062306a36Sopenharmony_ci l Include line number 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ciFor ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only 22362306a36Sopenharmony_cithe ``p`` flag has meaning, other flags are ignored. 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ciNote the regexp ``^[-+=][fslmpt_]+$`` matches a flags specification. 22662306a36Sopenharmony_ciTo clear all flags at once, use ``=_`` or ``-fslmpt``. 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ciDebug messages during Boot Process 23062306a36Sopenharmony_ci================================== 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ciTo activate debug messages for core code and built-in modules during 23362306a36Sopenharmony_cithe boot process, even before userspace and debugfs exists, use 23462306a36Sopenharmony_ci``dyndbg="QUERY"`` or ``module.dyndbg="QUERY"``. QUERY follows 23562306a36Sopenharmony_cithe syntax described above, but must not exceed 1023 characters. Your 23662306a36Sopenharmony_cibootloader may impose lower limits. 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ciThese ``dyndbg`` params are processed just after the ddebug tables are 23962306a36Sopenharmony_ciprocessed, as part of the early_initcall. Thus you can enable debug 24062306a36Sopenharmony_cimessages in all code run after this early_initcall via this boot 24162306a36Sopenharmony_ciparameter. 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ciOn an x86 system for example ACPI enablement is a subsys_initcall and:: 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci dyndbg="file ec.c +p" 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ciwill show early Embedded Controller transactions during ACPI setup if 24862306a36Sopenharmony_ciyour machine (typically a laptop) has an Embedded Controller. 24962306a36Sopenharmony_ciPCI (or other devices) initialization also is a hot candidate for using 25062306a36Sopenharmony_cithis boot parameter for debugging purposes. 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_ciIf ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at 25362306a36Sopenharmony_ciboot time, without effect, but will be reprocessed when module is 25462306a36Sopenharmony_ciloaded later. Bare ``dyndbg=`` is only processed at boot. 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ciDebug Messages at Module Initialization Time 25862306a36Sopenharmony_ci============================================ 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ciWhen ``modprobe foo`` is called, modprobe scans ``/proc/cmdline`` for 26162306a36Sopenharmony_ci``foo.params``, strips ``foo.``, and passes them to the kernel along with 26262306a36Sopenharmony_ciparams given in modprobe args or ``/etc/modprob.d/*.conf`` files, 26362306a36Sopenharmony_ciin the following order: 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci1. parameters given via ``/etc/modprobe.d/*.conf``:: 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci options foo dyndbg=+pt 26862306a36Sopenharmony_ci options foo dyndbg # defaults to +p 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci2. ``foo.dyndbg`` as given in boot args, ``foo.`` is stripped and passed:: 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_ci foo.dyndbg=" func bar +p; func buz +mp" 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci3. args to modprobe:: 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci modprobe foo dyndbg==pmf # override previous settings 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_ciThese ``dyndbg`` queries are applied in order, with last having final say. 27962306a36Sopenharmony_ciThis allows boot args to override or modify those from ``/etc/modprobe.d`` 28062306a36Sopenharmony_ci(sensible, since 1 is system wide, 2 is kernel or boot specific), and 28162306a36Sopenharmony_cimodprobe args to override both. 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ciIn the ``foo.dyndbg="QUERY"`` form, the query must exclude ``module foo``. 28462306a36Sopenharmony_ci``foo`` is extracted from the param-name, and applied to each query in 28562306a36Sopenharmony_ci``QUERY``, and only 1 match-spec of each type is allowed. 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ciThe ``dyndbg`` option is a "fake" module parameter, which means: 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_ci- modules do not need to define it explicitly 29062306a36Sopenharmony_ci- every module gets it tacitly, whether they use pr_debug or not 29162306a36Sopenharmony_ci- it doesn't appear in ``/sys/module/$module/parameters/`` 29262306a36Sopenharmony_ci To see it, grep the control file, or inspect ``/proc/cmdline.`` 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ciFor ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or 29562306a36Sopenharmony_cienabled by ``-DDEBUG`` flag during compilation) can be disabled later via 29662306a36Sopenharmony_cithe debugfs interface if the debug messages are no longer needed:: 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci echo "module module_name -p" > /proc/dynamic_debug/control 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ciExamples 30162306a36Sopenharmony_ci======== 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci:: 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci // enable the message at line 1603 of file svcsock.c 30662306a36Sopenharmony_ci :#> ddcmd 'file svcsock.c line 1603 +p' 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci // enable all the messages in file svcsock.c 30962306a36Sopenharmony_ci :#> ddcmd 'file svcsock.c +p' 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_ci // enable all the messages in the NFS server module 31262306a36Sopenharmony_ci :#> ddcmd 'module nfsd +p' 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_ci // enable all 12 messages in the function svc_process() 31562306a36Sopenharmony_ci :#> ddcmd 'func svc_process +p' 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ci // disable all 12 messages in the function svc_process() 31862306a36Sopenharmony_ci :#> ddcmd 'func svc_process -p' 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_ci // enable messages for NFS calls READ, READLINK, READDIR and READDIR+. 32162306a36Sopenharmony_ci :#> ddcmd 'format "nfsd: READ" +p' 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci // enable messages in files of which the paths include string "usb" 32462306a36Sopenharmony_ci :#> ddcmd 'file *usb* +p' > /proc/dynamic_debug/control 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_ci // enable all messages 32762306a36Sopenharmony_ci :#> ddcmd '+p' > /proc/dynamic_debug/control 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_ci // add module, function to all enabled messages 33062306a36Sopenharmony_ci :#> ddcmd '+mf' > /proc/dynamic_debug/control 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci // boot-args example, with newlines and comments for readability 33362306a36Sopenharmony_ci Kernel command line: ... 33462306a36Sopenharmony_ci // see what's going on in dyndbg=value processing 33562306a36Sopenharmony_ci dynamic_debug.verbose=3 33662306a36Sopenharmony_ci // enable pr_debugs in the btrfs module (can be builtin or loadable) 33762306a36Sopenharmony_ci btrfs.dyndbg="+p" 33862306a36Sopenharmony_ci // enable pr_debugs in all files under init/ 33962306a36Sopenharmony_ci // and the function parse_one, #cmt is stripped 34062306a36Sopenharmony_ci dyndbg="file init/* +p #cmt ; func parse_one +p" 34162306a36Sopenharmony_ci // enable pr_debugs in 2 functions in a module loaded later 34262306a36Sopenharmony_ci pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p" 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ciKernel Configuration 34562306a36Sopenharmony_ci==================== 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ciDynamic Debug is enabled via kernel config items:: 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci CONFIG_DYNAMIC_DEBUG=y # build catalog, enables CORE 35062306a36Sopenharmony_ci CONFIG_DYNAMIC_DEBUG_CORE=y # enable mechanics only, skip catalog 35162306a36Sopenharmony_ci 35262306a36Sopenharmony_ciIf you do not want to enable dynamic debug globally (i.e. in some embedded 35362306a36Sopenharmony_cisystem), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic 35462306a36Sopenharmony_cidebug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any 35562306a36Sopenharmony_cimodules which you'd like to dynamically debug later. 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ciKernel *prdbg* API 35962306a36Sopenharmony_ci================== 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ciThe following functions are cataloged and controllable when dynamic 36262306a36Sopenharmony_cidebug is enabled:: 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci pr_debug() 36562306a36Sopenharmony_ci dev_dbg() 36662306a36Sopenharmony_ci print_hex_dump_debug() 36762306a36Sopenharmony_ci print_hex_dump_bytes() 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ciOtherwise, they are off by default; ``ccflags += -DDEBUG`` or 37062306a36Sopenharmony_ci``#define DEBUG`` in a source file will enable them appropriately. 37162306a36Sopenharmony_ci 37262306a36Sopenharmony_ciIf ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is 37362306a36Sopenharmony_cijust a shortcut for ``print_hex_dump(KERN_DEBUG)``. 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ciFor ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is 37662306a36Sopenharmony_ciits ``prefix_str`` argument, if it is constant string; or ``hexdump`` 37762306a36Sopenharmony_ciin case ``prefix_str`` is built dynamically. 378