如何使用QEMUn和GDB调试内核 [英] How to use QEMUn and GDB to debug Kernel

查看:212
本文介绍了如何使用QEMUn和GDB调试内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用QEMU和gdb调试Linux内核。我在我的虚拟机中编译了新的内核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,一切都很好,直到现在。但是,当我继续输入目标远程本地主机:1234。它打印了一些奇怪的消息。像这样:

$ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g $ g使用本地主机:1234

遥控 'G' 包应答太长:

00000000000000000000000000000000000000000000000063060000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000f0ff0000000000000200000000f0000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
000000007f030000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000 $ b $ 000000000000000000000000801 f0000
$ b(gdb)c

该程序未运行。

然后,当我输入'c'时。它会显示程序没有运行。我好几天一直困惑于这个问题。任何人都可以帮助我解决它并让程序运行。非常感谢。

解决方案

这是gdb bug 13984 。附有一个补丁,可解决此错误。


I would like to know how to debug the linux kernel using QEMU and gdb. I have compiled new kernel linux-3.18.6 in my VM. My VM environment is centos and kernel version is 3.10.0-327.el7.x86_64. I use the command "qemu-system-x86_64 -kernel /usr/src/linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -s -S" to run the new kernel. Then, I use another shell window to run "gdb ./vmlinux", everything is good until now. But, when I keep going to input "target remote localhost:1234". It prints some weird messages.Like this

(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.

Then, when I type 'c'. It will show "The program is not being run.". I have been confused by this problem for several days. Can anybody help me to fix it and let the program run. Thanks a lot.

解决方案

This is gdb bug 13984. There is a patch attached to it which resolves this bug.

这篇关于如何使用QEMUn和GDB调试内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆