1

I want to debug a kernel module with kgdb,do as the following:

gdb: add-symbol-file /home/gaoqiang/kernel-32/fs/ext4/ext4.ko 0xffffffffa0122000 -s .bss 0xffffffffa016b380 -s .data 0xffffffffa0168400

gdb: break ext4_getattr gdb: c

I successfully get to the break point,but gdb told me :"[ No Source Available ]" then how to get gdb to find source code for the module?

Eugene
  • 5,977
  • 2
  • 29
  • 46
  • Is it a kernel you have built or a kernel provided by your Linux distro? For the latter, the debug info GDB needs can actually be in a separate file rather than in ext4.ko itself. You can look for the packages like kernel-\*-debug, kernel-\*-debuginfo, etc., in the repositories of your distro. – Eugene Dec 28 '12 at 07:24
  • BTW, could you describe a bit what you are trying to find out about ext4 with kgdb? In some cases, there could be easier ways to collect the data you need than using a debugger. – Eugene Dec 28 '12 at 07:27

2 Answers2

1

As per your problem

(gdb) add-symbol-file /home/gaoqiang/kernel-32/fs/ext4/ext4.ko 0xffffffffa0122000 -s .bss 0xffffffffa016b380 -s .data 0xffffffffa0168400

I assume that the module is present in the directory /home/gaoqiang/kernel-32/fs/ext4/. If your source code is also in directory the gdb would not have given the error/warning.

So if the source files for ext4.ko module say ext4.c and the rest are not present in that directory, copy them to the directory.

GeekFactory
  • 399
  • 2
  • 13
1
 (gdb)set solib-search-path /home/gaoqiang/kernel-32/fs/ext4/
Milind Dumbare
  • 3,104
  • 2
  • 19
  • 32