linux kernel dynamic debug

来源:互联网 发布:韦小宝和康熙 知乎 编辑:程序博客网 时间:2024/05/21 09:01

refs:

http://lwn.net/Articles/434833/

https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt


= Use dynamic debug(ddebug) =

==config==

enabe debugfs, enable CONFIG_DYNAMIC_DEBUG

for some subsystem which debug based on ddebug, e.g. xhci_dbg, you also need to enable subsystem's debug


==usage==

mount -t debugfs none /sys/kernel/debug

echo 8 > /proc/sys/kernel/printk

echo "file xx.c line xxx +p" > /sys/kernel/debug/dynamic_debug/control

#also has other support to enable debug info, check Documentation/dynamic-debug-howto.txt for details.

awk '$3 != "-" ' /sys/kernel/debug/dynamic_debug/control

#check the enabled debug info is same as expected or not.

OK. now run what you want to debug and get the info you care.

Enjoy it.


= others about dynamic debug =

Dynamic debug operates on print statements written with either of:

    pr_debug(char *format, ...);    dev_dbg(struct device *dev, char *format, ...);

If the CONFIG_DYNAMIC_DEBUG option is not set, and if DEBUG is defined, the above functionswill be turned into normalprintk() statements at theKERN_DEBUG level.

So another way to enable dev_dbg is:

 - define DEBUG before #include<linux/device.h> in the file which you want to debug.

原创粉丝点击