如何使用gdb结合qemu调试linux内核源码

来源:互联网 发布:mysql安装版 64位 编辑:程序博客网 时间:2024/05/17 03:40

原文地址:http://blog.csdn.net/varistor/article/details/8099780

1.编译linux内核源码

$make menuconfig

进入选项Kernel hacking选项,选中kernel debugging和Compile kernel with debug info选项,保存退出。

$make

成功编译后产生arch/i386/boot/bzImage

 

 

2.从qemu官网下载linux-0.2.img

 

3.开始测试

 

【使用sda硬盘】

$qemu -S -kernel arch/i386/boot/bzImage -hda ../linux-0.2.img -append "root=/dev/sda"

(Ctr l+ Al t+ 2)

 

【使用sda硬盘】

或者直接运行:qemu -S -kernel arch/i386/boot/bzImage -hda linux-0.2.img -append "root=/dev/sda" -gdb tcp::1234

等价于:qemu -s -S -kernel arch/i386/boot/bzImage -hda linux-0.2.img -append "root=/dev/sda"

这样是可成功挂载文件系统的。

 

$netstat -tlnp

 

$gdb vmlinux

 

 

vimgdb效果图

 

其中的使用细节可参考http://blog.csdn.net/sanlinux/archive/2010/07/10/5725995.aspx

 

《Android中使用arm-eabi-gdb和vim进行调试 》

尤其注意在target remote的情况下运行的命令是c,而不是run。


来自:http://blog.csdn.net/sanlinux/article/details/5727293