We will highlight some of the most common methods employed by kernel developers to debug kernel issues.
Above all, debugging the Linux kernel remains a manual process, and the most important developer tool is the ability to print debug messages.
The kernel uses the printk
function, which is very similar syntactically to the printf
function call from standard C libraries, with the addition of an optional log level. The allowed formats are documented in the kernel source under Documentation/printk-formats.txt
.
The printk
functionality needs to be compiled into the kernel with the CONFIG_PRINTK
configuration variable. You can also configure the Linux kernel to prepend a precise timestamp to every message with the CONFIG_PRINTK_TIME
configuration variable, or even better, with the printk.time
kernel command-line argument or through the sysfs
under /sys/module/printk/parameters
.