6 There are many debug infrastructure and support in Linux. We are going to look
7 at some of them, including:
13 We are also going to point out at some documentation for other debug support.
17 printk adds messages to the kernel log system. It may be read by the syslog
18 syscall (klogctl in glibc). It's also present in /proc/kmsg and is usually read
21 The *dmesg* program may be used to read these log messages. It's usually asked
26 dmesg may configure which levels are output to console. Those log levels are
27 also used by the syslog daemon to filter what messages go where.
29 /proc/sys/kernel/printk shows the current console loglevel, the default level
30 (for messages that miss the level), the minimum level and the boot time console
35 The following macros are used for log levels in printk:
48 You may limit the rate of the messages printed.
51 * You may test for printk\\_ratelimit
52 - limits to *burst* messages in *interval* seconds
53 * Default burst is 10 times in 5 seconds
54 * /proc/sys/kernel/printk\\_ratelimit*
55 * printk\\_ratelimited uses only the default values
66 * pr\\_debug - only if DEBUG macro defined or with dynamic\\_debug
67 * pr\\_devel - only if DEBUG macro defined
69 # Printing from device drivers
71 * include linux/device.h
72 * dev\\_printk(level, device, fmt, ...)
74 * dev\\_warn and not dev\\_warning
75 * dev\\_dbg - only if DEBUG macro defined or with dynamic\\_debug
77 # Defining the DEBUG macro
79 Let's take a look at an example of defining the DEBUG macro for some code and
80 allowing the user to configure it.
82 * drivers/usb/core/Kconfig
83 * drivers/usb/core/Makefile
87 * Allow developers or users to filter debug messages by subsystem, file and line
88 * CONFIG\\_DYNAMIC\\_DEBUG should be defined
89 * Depends on DEBUG\\_FS
90 * Documented in the Kconfig help at lib/Kconfig.debug
91 * Also documented at Documentation/dynamic-debug-howto.txt