Software Development with Linux

Easy Linux kernel debugging

MON, 01 JUN 2009

One important part of every software developer is debugging. Even if we would like it to be different, there are bugs in every software projects. In the process of solving those issues, using a software debugger can often provide insightful information and help you fix that thing quickly and elegantly.

But what happens when the software project you're working on is inside the kernel? Either by being a kernel module (device drivers, network module, etc.) or direct modifications of the Linux kernel's source code?

One possibility is to do remote kernel debugging, using KGDB. But this may not always be the most efficient method.

Another possibility is to use User-Mode Linux.
User-Mode Linux is a safe, secure way of running Linux versions and Linux processes. Run buggy software, experiment with new Linux kernels or distributions , and poke around in the internals of Linux, all without risking your main Linux setup. -- User-Mode Linux's web site
User-Mode Linux can be used for a lot of stuff, but debugging Linux kernel (or modules) is something you can easily do with it.

The interesting part, is that you can use gdb to debug it like you would do for any other normal program. So, any tools you have that use gdb can be used for this. You can even do remote debugging with gdb-server.

Here's some good starting point for doing that :

For those who like books, there's "User-Mode Linux" by Jeff Dike, its creator. It's not specific about debugging, but it may be interesting anyway to learn more about User-Mode Linux.