KGDB Tutorial
Building a Kernel that supports KGDB
- Upstrteam documentation: Using kgdb and the kgdb Internals
- Set CONFIG_KGDB=y in your kernel .config (linux-2.6/lib/Kconfig.kgdb):
menuconfig KGDBbool "KGDB: kernel debugging with remote gdb"depends on HAVE_ARCH_KGDBdepends on DEBUG_KERNEL && EXPERIMENTALhelpIf you say Y here, it will be possible to remotely debug thekernel using gdb.
Set CONFIG_KGDB_CONSOLE=y to serve as the KGDB I/O driver (linux-2.6/lib/Kconfig.kgdb, linux-2.6/drivers/serial/kgdboc.c):
config KGDB_SERIAL_CONSOLEtristate "KGDB: use kgdb over the serial console"select CONSOLE_POLLselect MAGIC_SYSRQdefault yhelpShare a serial console with kgdb. Sysrq-g must be usedto break in initially.
KGDB Boot and Module Options
- Boot with kgdboc=<tty-device>,[baud] (ex: kgdboc=ttyAMA1 for qemu-system-arm)
- (alternatively) From sysfsecho TTY_DEVICE > /sys/module/kgdboc/parameters/kgdboc
Connecting GDB to the Kernel through QEMU Emulated Serial Port
- [arm-cross: linux-2.6]$ qemu-system-arm -nographic -s -M integratorcp -kernel
./zImage-2.6.32-integratorcp-v5 -serial tcp:localhost:2345,server -net
nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=./scripts/qemu-ifup
-append "console=ttyAMA0 root=/dev/nfs
nfsroot=172.20.0.1:/nfsroot/box,nfsvers=3 rw
ip=172.20.0.2::172.20.0.1:255.255.255.0 kgdboc=ttyAMA0 kgdbwait" - [arm-cross: linux-2.6]$ telnet localhost:2345
- Wait till the telnet session show "kgdb: Waiting for connection from remote gdb..." then terminate telnet with CTRL-] then CTRL-D
- [arm-cross: linux-2.6]$ gdb ./vmlinux
- (gdb) target remote localhost:2345
- Trouble Shooting: (gdb) set debug remote 1
Connecting GDB to the Kernel through a Physical Serial Port
[scottt@2530p linux-2.6]$ gdb ./vmlinux
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyS0
0 comments:
Post a Comment