Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to study the flow of some linux device drivers and some minimal flow of kernel (threading cum context switching and interrupt management).

How can I debug the linux kernel? What are the basic steps for doing that?

Recently i successfully compiled and integrated new kernel ( into my machine running the 2.6.29 kernel.

share|improve this question
Linus is adamantly opposed to debuggers, so the support for that is rather scanty. Try to decipher the data flow you are interested in by reading the code, hanging out in lwn.net or kernelnewbies.org, reading books, ... [The problem is that much is time-critical, can't stop to take a peek, printk might mess up execution, ...] – vonbrand Jan 23 '13 at 20:01
up vote 3 down vote accepted

It depends on what you really need. Probably simple printk() function is gonna be OK for the beginning. There is also the /proc interface you can use to get useful information from kernel.

If you need something more complicated, use KGDB (kernel debugger).

share|improve this answer
Yes. I need the information about the usage of KGDB itself. – Renjith G Oct 16 '10 at 20:49
Renjith, kgdb.linsyssoft.com/using.htm – Oleksandr Kravchuk Oct 16 '10 at 20:52
Thanks. I will closely look into it. – Renjith G Oct 16 '10 at 21:06
there is kernel-probes, and then stap, DTrace for Solaris/BSD/Mac? kernels. Pretty innovatively useful. – Nikhil Mulley Jan 28 '12 at 8:28

Go to your kernel sources folder and have a look inside Documentation/ folder. Start with going through the file kernel-parameters.txt looking for references to debugging.

If your kernel is compiled with CONFIG_DEBUG_KERNEL option set, you can easily adjust the verbosity of kernel messages via the loglevel boot option.

share|improve this answer

The other options other then KGDB would be debugging the kernel using the QEMU and GDB. Unlike the KGDB, the QEMU-GDB combine requires only a single machine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.