A script that used by GDB to load the symbols from Linux kernel modules

Hui Zhu teawater@gmail.com
Wed Aug 17 05:46:00 GMT 2011


Hi,

When use GDB to debug or trace your kernel with KGDB, QEMU debug
interface or KGTP.  You must get some trouble with LKM symbols.  For
example:
(gdb) target remote localhost:12345
Remote debugging using localhost:12345
native_safe_halt () at
/home/teawater/big/kernel/linux-2.6/arch/x86/include/asm/irqflags.h:50
50	}
(gdb) b e100_poll
Function "e100_poll" not defined.
Make breakpoint pending on future shared library load? (y or [n])
This is because GDB didn't get the LKM symbols.  You can do it with
your hand.  But if you have a lot of LKMs, it will need some time.

Now, GDB support python script.  The attachment is a script to load
all symbols from Linux kernel modules to GDB.
For example:
(gdb) target remote localhost:12345
Remote debugging using localhost:12345
native_safe_halt () at
/home/teawater/big/kernel/linux-2.6/arch/x86/include/asm/irqflags.h:50
50	}
(gdb) so ~/kernel/svn/branches/teawater/getmod.py
(gdb) b e100_poll
Breakpoint 1 at 0xc889db40: file
/home/teawater/big/kernel/linux-2.6/drivers/net/e100.c, line 2165.

This script will include in KGTP(https://code.google.com/p/kgtp/) source.

Thanks,
Hui
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getmod.py
Type: text/x-python
Size: 3056 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20110817/059950e0/attachment.py>


More information about the Gdb mailing list