利用Qemu + Buildroot 进行内核源码级调试

本文介绍了如何利用Qemu和Buildroot搭建内核源码级调试环境,包括在CentOS 7.2系统上配置Buildroot、开启内核调试信息、解决Gdb调试问题,以及如何运行和调试内核驱动模块。详细讲解了每个步骤,如编译选项设置、Gdb源码打patch和内核模块加载调试。
摘要由CSDN通过智能技术生成

利用Qemu + Buildroot 进行内核源码级调试

概要:最近想研究下内核里Bridge的具体实现过程,加之公司使用的嵌入式开发环境是基于Buildroot的,想着借用Buildroot来编译qemu可以使用的内核和文件系统,顺便熟悉下Buildroot环境,也省去自己编译内核通过busybox制作文件系统的麻烦。

一、环境

1. 宿主机(64位)系统:

$ lsb_release -d
Description: CentOS Linux release 7.2.1511 (Core)

2. Buildroot环境:

Buildroot是网上https://buildroot.org/download.html下载的最新版本:buildroot-2016.05.tar.gz,默认编译qemu_x86_64可用的版本。

$ tar zxvf buildroot-2016.05.tar.gz
$ cd buildroot-2016.05
$ make list-defconfigs                // 列出所有buildroot支持的平台的默认编译。
$ make qemu_x86_64_defconfig          //  Build for qemu_x86_64
$ make linux-menuconfig               //  打开内核编译选项

默认情况内核是没有开启调试信息的,需要开启内核调试信息,否则gdb时候会出现:no debugging symbols found,开启内核调试信息选项的方式如下:

图1
图2
图3
可能有些时候这个”Compile the kernel with debug info”选项没有直接显示,可能会依赖其他编译选项。开启选项然后保存。

$ make

直接编译,最后编译结果都会在output/images/目录下面:
图4

3. Gdb环境

[james_xie@james-desk images]$ gdb -v 
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

系统自带的gdb会有一个问题,当给内核设置断点之后,继续运行的时候回显示:

Remote 'g' packet reply is too long

再继续运行则显示:
图5
这样没办法进行跟踪调试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值