Debug a kernel module being loaded
<p>I am wondering if it is possible to debug a kernel module being loaded.</p>

<p>Note I am currently trying this on Linux 2.0.18. I've followed this great <a href="https://www.linux.com/learn/kernel-newbie-corner-kernel-and-module-debugging-gdb" rel="nofollow">tutorial</a>. Since the kernel config options <code>CONFIG_PROC_KCORE</code> and <code>CONFIG_DEBUG_INFO</code> don't seem to be available in this kernel version, I've added <code>-g -gdwarf</code> to <code>CFLAGS</code> in the Makefile, recompiled the kernel and modules and rebooted.</p>

<p>Then I can run <code>gdb vmlinux /proc/kcore</code> and then <code>p jiffies</code> which gives me <code>$1 = 1470917</code>.</p>

<p>That's where I am starting to get lost, also because there seems to be no <code>/sys/module/gdb1/sections</code> on that kernel version, as it seems required to debug a loaded module.</p>

<p>So I just tried to load the symbols of the module "ne":</p>

<p><code>(gdb) symbol-file modules/ne.o</code></p>

<p>which loads the symbols after confirming with "y". Then I set a breakpoint:</p>

<pre><code>(gdb) break ne.c:148
Breakpoint 1 at 0xa: file ne.c, line 148.
</code></pre>

<p>Now I'd like to do <code>modprobe ne</code> and reach the breakpoint, but I think I am completely on the wrong path.</p>

<p>Is it possible at all? Even if it is not on such an old kernel, I'd be happy to know how to debug a module being loaded on a current kernel as well.</p>