Friday, September 18, 2015

Ubuntu KGDB

This is for 12.04 and I believe that this should work for 14.04.

Kernel build
Make sure .config contains
1
2
3
CONFIG_HAVE_ARCH_KGDB=y
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y

GRUB
On this line:
1
linux /boot/vmlinux-4.1.3-XXXX root=UUID=XXXXX ro consoleblank=0

append at the end
1
kgdbwait kgdboc=ttyS2,115200

Serial Port
Check which serial port is available
1
dmesg | grep ttyS

Configure serial port
Install setserial
1
sudo apt-get install setserial

Check port configuration
1
sudo setserial -g /dev/ttyS3

Install minicom
1
sudo apt-get install minicom

Configure port
1
sudo minicom -s

After configuration choose "Exit" and started session.

Ctrl-A Z and then, choose "Hang up".

GDB
Fire up gdb
1
sudo gdb vmlinux

Connect serial port
1
2
3
4
5
6
7
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyS3
Remote debugging using /dev/ttyS3
Ignoring packet error, continuing...
kgdb_breakpoint ()
    at /home/wre/work/OS/linux-4.1.3/kernel/debug/debug_core.c:1072
1072  wmb(); /* Sync point after breakpoint */

Set a break point
1
2
(gdb) b /home/nobody/work/OS/linux-4.1.3/drivers/base/core.c:1970
Breakpoint 1 at 0xc1556b68: file /home/nobody/work/OS/linux-4.1.3/drivers/base/core.c, line 1970.


No comments:

Post a Comment