在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就连接上啦。此时就可以像普通...
在MMU开启之前,内核代码是位置无关的代码(Position Independent Code, PIC),可以在任意地址上运行,也就导致了运行地址与链接地址不一致的情况,需要加载symbol到相应的位置才能进行debug。而在MMU开启之后,内核开始运行在虚拟地址上,此时运行地址和链接地址是一致的。 01 确定kernel的加载地址 要调试kernel需要知道kernel被...
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 ...
找到Randomize the address of the kernel image (KASLR)选项,按空格键取消选中(确保显示为[ ])。这将设置CONFIG_RANDOMIZE_BASE=n,禁用内核地址空间布局随机化(Kernel Address Space Layout Randomization, KASLR)。禁用 KASLR 后,内核每次加载到内存的基地址都是固定的,这极大地简化了在 GDB 中设置早期断点和理解...
Debug information Rely on the toolchain's implicit default DWARF version 然后重新编译kernel: make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j12 编译完成后运行qemu: ./run.sh -S -s 此时qemu等待gdb连接 在启动gdb之前我们还需要看一下kernel的各个段的地址,在linux源码目录下执行如下命令: ...
在内核编译选项中,开启如下"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,但是我按照默认安装最后也默认...
6. Now we can boot the kernel with qemu and debug it. To just run the newly compiled kernel we can use the command: qemu-system-i386 -kernel bzImage 1. Here since I have created the soft-link and my kernel is 64bits, I can use ...
关于GDB的调试命令,有详细的介绍,可以上网慢慢学。可以参考:https://docs.dragonos.org/zh-cn/latest/kernel/debug/debug-kernel-with-gdb.html 常用的方法 起始断点与普通断点 调试的时候,我们可以一次性设置很多断点。断点按照用途,我个人认为可以分为两类(起始定位断点和普通断点)。起始定位断点是“要调试的上下...
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...