Specifications
(gdb) c
Continuing.
Breakpoint 1, fun (t=0x1) at ex_sw.c:69
69 cpu_used[hard_cpu_id()]++;
(gdb) p/d loops
$2 = 999986939
(gdb) p t
$3 = 0x1
(gdb) d b
Delete all breakpoints? (y or n) y
(gdb) c
Continuing.
10.3. GDB Startup File and Utility Scripts
In addition to the add-module macro, the followin example GDB startup file contains a few other useful
settings and macros, which you may want to adjust to your local environment:
set output-radix 16
target remote bdi:2001
define reset
detach
target remote bdi:2001
end
define add-module
shell ~/add-symbol-file.sh $arg0
source ~/add-symbol-file.gdb
end
document add-module
Usage: add-module <module>
Do add-symbol-file for module <module> automatically.
Note: A map file with the extension ".map" must have
been created with "insmod -m <module> > <module>.map"
in advance.
end
The following shell script ~/add-symbol-file.sh is used to run the GDB add-symbol-file command
automatically:
#!/bin/sh
#
# Constructs the GDB "add-symbol-file" command string
# from the map file of the specified kernel module.
add_sect() {
ADDR=`awk '/^'$1' / {print $3}' $MAPFILE`
if [ "$ADDR" != "" ]; then
echo "-s $1 0x`awk '/^'$1' / {print $3}' $MAPFILE`"
fi
}
[ $# == 1 ] && [ -r "$1" ] || { echo "Usage: $0 <module>" >&2 ; exit 1 ; }
MAPFILE=$1.map
ARGS="0x`awk '/^.text / {print $3}' $MAPFILE`\
`add_sect .rodata`\
10.3. GDB Startup File and Utility Scripts 134