Where does dev_dbg log?

In the source of the device driver in the Linux tree I saw dev_dbg(...)

and dev_err(...)

where can I find the logged message?

One link suggests adding #define DEBUG

. Another link includes dynamic debugs and debugfs and I am lost.

+3


source to share


1 answer


dev_dbg()

expands to dynamic_dev_dbg()

, dev_printk()

or no-op depending on the compilation flags.

#if defined(CONFIG_DYNAMIC_DEBUG)
#define dev_dbg(dev, format, ...)                    \
do {                                                 \
    dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
} while (0)
#elif defined(DEBUG)
#define dev_dbg(dev, format, arg...)            \
    dev_printk(KERN_DEBUG, dev, format, ##arg)
#else
#define dev_dbg(dev, format, arg...)                            \
({                                                              \
    if (0)                                                  \
            dev_printk(KERN_DEBUG, dev, format, ##arg);     \
})
#endif

      

dynamic_dev_dbg()

and the dev_printk()

call dev_printk_emit()

that calls vprintk_emit()

.

This same function is called normally when you are executing only printk()

. Just note that the rest of the functions, such as dev_err()

, will end up in the same function.



Thus, it is obvious that the buffer is the same, that is, the core of the intravenous buffer.

The registered message at the end is printed on

  • The current console if the kernel loglevel (can be changed with the kernel command line or via procf) is sufficient for a specific message, here KERN_DEBUG.
  • An internal buffer that can be read by executing the command dmesg

    .

Note. The data in 2 is retained as long as there is no space in the buffer. Because it is limited and cool, new data is inferior to old data.

+3


source







All Articles