|
Loading a module file in gdb with kgdb 1.8 and
earlier:
You have to explicitly load module object files in gdb when using kgdb
versions 1.8 or earlier. This procedure is given below.
Procedure to be followed after
running the loadmodule.sh script:
For gdb to be able to use debugging information in a module object file
it has to be loaded in gdb. An object file is loaded in gdb with the
gdb command add-symbol-file. The gdb script generated by
loadmodule.sh script after loading a module file in the test kernel is
sourced in gdb to load the module object file in gdb. To force gdb to
wait for a user command, press Ctrl+C in the terminal running
gdb on the development machine. Then source the file in gdb.
Following example shows the procedure. Gdb is assumed to be connected
to the test kernel.
Use presses Ctrl + C.
Program received signal SIGTRAP, Trace/breakpoint trap.
breakpoint () at gdbstub.c:1153
1153 }
(gdb) source /mnt/work/gdbscripts/loadtrfs
add symbol table from file
"/mnt/work/build/old-pc/trfs/modules/trfs/trfs" at
.text_addr = 0xc1808060
.text.lock_addr =
0xc180968c
.rodata_addr = 0xc18097a0
__ksymtab_addr =
0xc1809a44
.data_addr = 0xc1809bc0
(gdb)
gdb is now all set for debugging the module trfs. We can
continue here.
(gdb) c
Continuing.
Procedure to be followed for
loading into gdb object files for modules not loaded using the loadmodule.sh
script:
A module may be loaded either automatically or using modprobe or insmod
commands. For modules which are not loaded using loadmodule.sh
script, you'll have to extract module information from the target
machine and give it to gdb. Use the script getsyms.sh on the target machine to get
the information needed by gdb. The script is available from downloads page. Let's say a kernel has a
module audio.o loaded in it. Run the script with module name as the
argument as shown below.
[amitkale@askii-pc amitkale]$ bash getsyms.sh audio.o
add-symbol-file audio.o 0xd00b4060 -s .rodata 0xd00bc9bc -s .bss 0x -s
.data 0xd00bf4e0
[amitkale@askii-pc amitkale]$
Supply the line printed by the script to gdb.
(gdb) add-symbol-file audio.o 0xd00b4060 -s .rodata 0xd00bc9bc -s
.bss 0x -s .data 0xd00bf4e0
add symbol table from file "audio.o" at
.text_addr = 0xd00b4060
.rodata_addr = 0xd00bc9bc
.bss_addr = 0x0
.data_addr = 0xd00bf4e0
(y or n) y
Reading symbols from audio.o...done.
(gdb)
Now gdb is ready with the debugging information about the module, so
you can place breakpoints in it and debug it.
init_module function in a module is run by the time getsyms.sh is run
on a machine, hence this procedure can't be used to debug init_module
function. You have to run the loadmodule.sh script and follow
the procedure corresponding to it.
|