如何使用QEMUn和GDB来调试内核

时间:2017-08-03 19:03:45

标签: debugging linux-kernel gdb qemu

我想知道如何使用QEMU和gdb调试linux内核。我在我的VM中编译了新的内核linux-3.18.6。我的VM环境是centos,内核版本是3.10.0-327.el7.x86_64。我使用命令“qemu-system-x86_64 -kernel /usr/src/linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -s -S”来运行新内核。然后,我使用另一个shell窗口来运行“gdb ./vmlinux”,到目前为止一切都很好。但是,当我继续输入“target remote localhost:1234”时。它打印出一些奇怪的消息。就像这个

(gdb) target remote localhost:1234

Remote debugging using localhost:1234

Remote 'g' packet reply is too long: 

00000000000000000000000000000000000000000000000063060000000000000000000000000000  
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000f0ff0000000000000200000000f0000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000007f0300000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000801f0000

(gdb) c

The program is not being run.

然后,当我输入'c'时。它将显示“程序未运行。”。我好几天都对这个问题感到困惑。任何人都可以帮我修复它并让程序运行。非常感谢。

1 个答案:

答案 0 :(得分:1)

这是gdb bug 13984。附加了patch可以解决此问题。