Specifications
Now you can list the source code of the module, set break points or inspect variables as usual:
(gdb) l fun
61 static RT_TASK *thread;
62
63 static int cpu_used[NR_RT_CPUS];
64
65 static void fun(int t)
66 {
67 unsigned int loops = LOOPS;
68 while(loops--) {
69 cpu_used[hard_cpu_id()]++;
70 rt_leds_set_mask(1,t);
(gdb)
(gdb) b ex_sw.c:69
Breakpoint 1 at 0xcf03007c: file ex_sw.c, line 69.
(gdb) c
Continuing.
Breakpoint 1, fun (t=1) at ex_sw.c:69
69 cpu_used[hard_cpu_id()]++;
(gdb) p ntasks
$1 = 16
(gdb) p stack_size
$2 = 3000
The next section demonstrates a way to automate the symbol table loading procedure.
10.2.3. GDB Macros to Simplify Module Loading
The following GDB macros and scripts help you to load kernel modules into GDB in a half-automatic way. It
assumes, that the module on the target has been installed with the command:
bash# insmod -m my_module.o > my_module.o.map
In your $HOME directory you need the scripts add-symbol-file.sh and the GDB startup file .gdbinit, which are
listed in 10.3. GDB Startup File and Utility Scripts below.
Now you can include the symbol definition into GDB with:
bash$ ${CROSS_COMPILE}gdb vmlinux
GNU gdb 5.1.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i386-redhat-linux --target=ppc-linux".
0x00000100 in ?? ()
c
Continuing.
^C
Program received signal SIGSTOP, Stopped (signal).
0xcf02a91c in ?? ()
(gdb) add-module rtai4/examples/sw/ex_sw.o
add symbol table from file "/HHL/8xx/target/home/wolf/rtai4/examples/sw/ex_sw.o" at
.text_addr = 0xcf030060
.rodata_addr = 0xcf030340
.data_addr = 0xcf030464
.sdata_addr = 0xcf030464
.bss_addr = 0xcf0304f5
.sbss_addr = 0xcf0304f8
(gdb) b ex_sw.c:69
Breakpoint 1 at 0xcf03007c: file ex_sw.c, line 69.
10.2.2. Dynamically Loaded Device Drivers (Modules) 133