Where does dev_dbg writes log to?

Viewed 6975

In a device driver source in the Linux tree, I saw dev_dbg(...) and dev_err(...), where do I find the logged message?

One reference suggest to add #define DEBUG . The other reference involves dynamic debug and debugfs, and I got lost.

2 Answers

you can find dev_err(...) in kernel messages. As the name implies, dev_err(...) messages are error messages, so they will definitely be printed if the execution comes to that point. dev_dbg(...) are debug messages which are more generously used in the kernel driver code and they are not printed by default. So everything you have read about dynamic_debugging comes into play with dev_dbg(...).

There are several pre-conditions to have dynamic debugging working, below 1. and 2. are general preconditions for dynamic debugging. 3. and later are for your particular driver/module/subsystem and can be .

  1. Dynamic debugging support has to be in your kernel config CONFIG_DYNAMIC_DEBUG=y. You may check if it is the case zgrep DYNAMIC_DEBUG /proc/config.gz
  2. debugfs has to be mounted. You can check with sudo mount | grep debugfs and if not existing, you can mount with sudo mount -t debugfs /sys/kernel/debug
  3. refer to dynamic_debugging and enable the particular file/function/line you are interested
Related