# 回到主工作目录 cd ~/debug-linux-kernel-on-qemu # 创建并进入 rootfs 构建目录 mkdir rootfs cd rootfs # 创建 Linux 基本目录结构 mkdir -p bin sbin etc proc sys dev lib usr/bin usr/sbin 这些目录是 Linux 系统运行所必需的,例如 bin 和sbin 用于存
在shell 终端1 运行如下命令: # qemu-system-x86_64 -kernel arch/x86/boot/bzImage -initrd ./initrd.gz -m 512 -s -S 参数解释:-S,停止运行,等待远程gdb连接,-s, 开启gdbserver服务。 在shell终端2 运行如下命令: # gdb vmlinux # target remote localhost:1234 此时gdb就连接上啦。此时就可以像普通...
接着可以使用命令: 代码语言:javascript 代码运行次数:0 运行 AI代码解释 gdb-x command.gdb 就能设置断点并启动虚拟机,这个时候,gdb调试的就是QEMU自身了。 关于GDB的调试命令,有详细的介绍,可以上网慢慢学。可以参考:https://docs.dragonos.org/zh-cn/latest/kernel/debug/debug-kernel-with-gdb.html 常用的方...
Installation (manual)### DownloadQEMUsource complier hljs wget https://download.qemu.org/qemu-5.2.0.tar.xz tar xvJf qemu-5.2.0.tar.xz cdqemu-5.2.0 ./configure make Installation (automatic) Arch:pacman -S qemu Debian/Ubuntu/Deepin:apt-get install qemu Centos:yum install qemu-kvm Kernel ...
在内核编译选项中,开启如下"Compile the kernel with debug info" Kernel hacking —> Compile-time checks and compiler options —> [ ] Compile the kernel with debug info 示意图如下,利用键盘选中debug选项,然后敲"Y"勾选: (以上是别人博客中找到,确实类似gcc编译要gdb得加-g,但是我按照默认安装最后也默认...
$ qemu-system-arm -M versatilepb -m 16 -kernel vmlinuz-qemu-arm-2.6.20 -append "clocksource=pit quiet rw" -S -s 4. 调试内核 这里需要有一个包含调试信息的vmlinux文件,可以直接编译http://free-electrons.com/pub/qemu/demos/arm/directfb/1.0/src/linux-2.6.20.tar.7z ...
三、kernel debug 单步调试kernel 只需要三步: 第一步:qemu启动内核并暂停等待(暂停是可选的,如果不调启动,可以去掉),同时需要建立网络端口等待gdb attach; 第二步:启动gdb(target=arm64)加载对应kernel Image的vmlinux, attach到指定端口即可; 第三步:如果是启动是挂起,直接设置断点即可调试,如果未选择启动暂停,...
Kernel hacking ---> [*] Kernel debugging Compile-time checks and compiler options ---> [*] Compile the kernel with debug info [*] Provide GDB scripts for kernel debugging 一定要打开。还有下面的选项会导致打断点失败,一定要关闭:Processor type and features ---> [] Rand...
Kernel hacking---> Compile-time checks and compiler options ---> [*] Compile the kernel with debug info [*] Provide GDB scripts for kernel debugging 这里是使用Qemu实现的GDB stub来调试,所以不需要打开KGDB 。 KASLR可以在qemu启动参数里控制,也不需要专门配置。