From the course: Linux Device Drivers
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Use printk() for tracing and debugging - Linux Tutorial
From the course: Linux Device Drivers
Use printk() for tracing and debugging
- [Instructor] Let's now look more closely at printk and see some differences from printf. printk is popular. In my kernel tree, it's called over 20,000 times. It's the most common debugging technique in the Linux kernel. So we'll look at the format string a bit. We'll look at what are known as log levels. And we'll talk about seeing the messages with the console and the dmesg command. So the printk formats are pretty much just like C's printf formats, except the format string for printk can begin with what's known as a log level, essentially a priority, how important this message is. And depending on the importance, different things can happen. You're logging dmenu can be configured to do different things with the messages based on level, for example. And just a reminder, you don't use floating point in the Linux kernel. So even though you might try the floating point format, they don't work in the kernel. So…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.