[lug] Kernel Level Debug Tools

Timothy C. Klein teece at silverklein.net
Fri Jan 10 15:04:46 MST 2003


* r_ms (r_msmit at hotmail.com) wrote:
> .What kernel level debug tools are available .... interested in what
> experiences others have had also with the tools, and how they rate them as
> to
> effectiveness, usability, etc.
> 
> Thanks,
> 

How fortuitous, I just finished reading the debugging section in _Linux
Device Drivers._

The simplest answer:  printk.  If you have an oops, use ksymoops to
track down the function.

If you really want to get the kernel into a traditional debugger, you
have to do more work.  Supposedly you can use gdb on the kernel, but it
has limitations, and I have never tried it.  There were a couple of
other kernel specific debugger options mentioned, but they were all
patches to the kernel to insert debugging info.  Seems like SGI and IBM
had each made something.

There is also the option of running User Mode Linux.  That is just a
special port of the kernel that runs as a user space process.  The last
time I tried it (which has been a while), though, it allowed no access
to the real hardware, which was a severe limitation.

But really, I think printk and ksymoops are the most useful. Wrap the
calls to printk in a C preprocessor directive, that only compiles them
if a global variable is set at compile time. That way, you can have all
the debug stuff in the code, but not have it increase the module size
when you release.

Thus, with debugging on, you have the kernel code print a litany of info
to the kernel log buffer: mod_foo in mod_open, mod_foo in mod_read,
mod_foo in mod_write, Oops, unable to handle NULL dereference in
mod_write ...

If your kernel code is so complicated to you that you have to do an
intricate, step-by-step trace to track down the problem,  your code is
no good.  At least, that is the attitude Linus has. "Real men don't use
debuggers," seems to be his philosophy.  

Tim
--
==============================================
==  Timothy Klein || teece at silverklein.net  ==
==  http://i148.denver.dsl.forethought.net  ==
== ---------------------------------------- ==
== "Hello, World" 17 Errors, 31 Warnings... ==
==============================================



More information about the LUG mailing list