Dynamic debug is designed to allow you to dynamically enable/disable kernel code to obtain additional kernel information. Currently, if CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_debug() calls can be dynamically enabled per-callsite.

Simple query language allows turning on and off debugging statements by matching any combination of:

  • source filename
  • function name
  • line number (including ranges of line numbers)
  • module name
  • format string
1
2
3
4
5
6
7
8
9
10
11
// enable the message at line 1603 of file svcsock.c
echo "file svcsock.c line 1603 +p" > /sys/kernel/debug/dynamic_debug/control

// enable all the messages in file svcsock.c
echo "file svcsock.c +p" > /sys/kernel/debug/dynamic_debug/control

// enable all the messages in the i915 module
echo "module i915 +p" > /sys/kernel/debug/dynamic_debug/control

// enable all messages in the function svc_process()
echo "func svc_process +p" > /sys/kernel/debug/dynamic_debug/control

参考资料:

  1. Documentation/dynamic-debug-howto.txt
  2. dynamic debug动态打印