Linux – KGDB remote debugging reports errors

KGDB remote debugging reports errors… here is a solution to the problem.

KGDB remote debugging reports errors

I’m trying to debug the Linux kernel using kgdb. I’m using qemu as the target machine. Ubuntu 12.04 is my host operating system. I tried this command

cyborg@skynet:~$ qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/bin/sh kgdboc=ttyAMA0,115200 kgdbwait"

Power on and wait for display

kgdb: Waiting for connection from remote gdb

When I try to debug with gdb on a Linux host using the command

cyborg@skynet: arm-none-linux-gnueabi-gdb vmlinux

(gdb): Sets the remote baud rate of 115200

(gdb) Target remote/dev/ttyS0
Use /dev/ttyS0 for remote debugging
Ignore packet errors and continue….

Warning: The unrecognized item in the qSupported response “Timed out”

Ignore packet errors and continue….

Ignore packet errors and continue….

Ignore packet errors and continue….

Ignore packet errors and continue….

The offset query response is malformed and times out

I am not really getting what I am missing !

P.S. I compiled linux kernel 2.6.39.4 with the KGDB option enabled. I followed these instructions for running the kernel on qemu.

Solution

If you reference /dev/ttyS0 on the host, gdb attempts to use the physical serial port that exists. You must connect QEMU's analog serial port to GDB.
Reading the qemu manual, obviously you can redirect the analog port to the TCP network by adding something like: -serial tcp:::1234, server to the qemu command line. In gdb, you can connect using target remote :1234.

Related Problems and Solutions