Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 (2.6.34.7) 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
add comment

3 Answers 3

up vote 2 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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.