我是
靠谱客的博主
疯狂水池,这篇文章主要介绍
dynamic_debug,现在分享给大家,希望可以做个参考。
2Introduction
3============
4
5This document describes how to use the dynamic debug (dyndbg) feature.
6
7Dynamic debug is designed to allow you to dynamically enable/disable
8kernel code to obtain additional kernel information. Currently, if
9CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() and
10print_hex_dump_debug()/print_hex_dump_bytes() calls can be dynamically
11enabled per-callsite.
12
13If CONFIG_DYNAMIC_DEBUG is not set, print_hex_dump_debug() is just
14shortcut for print_hex_dump(KERN_DEBUG).
15
16For print_hex_dump_debug()/print_hex_dump_bytes(), format string is
17its 'prefix_str' argument, if it is constant string; or "hexdump"
18in case 'prefix_str' is build dynamically.
19
20Dynamic debug has even more useful features:
21
22 * Simple query language allows turning on and off debugging
23 statements by matching any combination of 0 or 1 of:
24
25 - source filename
26 - function name
27 - line number (including ranges of line numbers)
28 - module name
29 - format string
30
31 * Provides a debugfs control file: <debugfs>/dynamic_debug/control
32 which can be read to display the complete list of known debug
33 statements, to help guide you
34
35Controlling dynamic debug Behaviour
36===================================
37
38The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a
39control file in the 'debugfs' filesystem. Thus, you must first mount
40the debugfs filesystem, in order to make use of this feature.
41Subsequently, we refer to the control file as:
42<debugfs>/dynamic_debug/control. For example, if you want to enable
43printing from source file 'svcsock.c', line 1603 you simply do:
44
45nullarbor:~ # echo 'file svcsock.c line 1603 +p' >
46 <debugfs>/dynamic_debug/control
47
48If you make a mistake with the syntax, the write will fail thus:
49
50nullarbor:~ # echo 'file svcsock.c wtf 1 +p' >
51 <debugfs>/dynamic_debug/control
52-bash: echo: write error: Invalid argument
53
54Viewing Dynamic Debug Behaviour
55===========================
56
57You can view the currently configured behaviour of all the debug
58statements via:
59
60nullarbor:~ # cat <debugfs>/dynamic_debug/control
61# filename:lineno [module]function flags format
62/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 12"
63/usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "