Debugging Linux Kernel Modules

I am aware of debugging linux applications using gdb and ddd.
Now I have written a simple kernel module having init_module, exit _module and some functions for tasklets and workqueues.
I want to debug these kernel modules like I used to debug applications setting breakpoints etc.
How can I debug linux kernel modules?
How to attach gdb to the modules and how to set breakpoints in them?

You don't. kernel code runs in kernel mode where gdb and any other user-mode code debugger cannot get at it. It's just not the same.

The kernel has its own debugger, kdb, about which I unfortunately don't know much.

1 Like