如何使用 QEMU 调试 Linux 内核模块? [英] How to debug Linux kernel modules with QEMU?

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

问题描述

我正在从事修改一些内核网络代码以及包含一个新的内核模块的学术项目.

I am working on academic project that modifies some Kernel Networking code as well as include a new Kernel module.

我正在使用 QEMU 加载修改后的内核并进行测试.

I am using QEMU to load modified kernel and test.

但是,我发现在某些 .img 中需要一个完整的操作系统才能进行调试.
没有它有可能吗?

However, i find that a complete OS is required in some .img to debug.
Is it possible without it ?

或者,这是可以与 Kernel 2.6 for system 一起使用的发行版.发行版不需要任何功能,除了运行程序的能力,包括网络支持.

Or, which is the distro that can be used with Kernel 2.6 for system. The distro need not have any features, except ability to run programs, including networking support.

推荐答案

我认为最简单的方法是使用 buildroothttp://buildroot.uclibc.org/

The easiest way in my opinion is to use buildroot http://buildroot.uclibc.org/

克隆它,将其配置为使用您的自定义内核(默认用户空间适合开始,您可能想稍后更改).

clone it, configure it to use your custom kernel (default userspace is fine for a start, you might want to change it later).

它将构建您的内核和根文件系统.整个过程大约需要半个小时,其中二十分钟就是编译怪物

it will build your kernel and root filesystem. the entire process takes about half an hour, twenty minutes of which is compiling the monster

我的运行线看起来有点像:qemu-system-i386-hda rootfs.ext2-内核 bzImage-m 512M-附加root=/dev/sda 控制台=ttyS0"-当地时间-串行标准输出

my run line looks something: qemu-system-i386 -hda rootfs.ext2 -kernel bzImage -m 512M -append "root=/dev/sda console=ttyS0" -localtime -serial stdio

以及更多关于点击设备的选项

and some more options regarding a tap device

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

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