欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > qemu 调试 Linux kernel 基于 x86_64

qemu 调试 Linux kernel 基于 x86_64

2025/4/19 13:46:56 来源:https://blog.csdn.net/eloudy/article/details/139974549  浏览:    关键词:qemu 调试 Linux kernel 基于 x86_64

1,配置编译qemu

配置qemu:

cd qemu/

mkdir build

cd build/

$ ../configure --enable-slirp \
--enable-slirp-smbd --smbd=/home/hipper/ex_ubuntu-22.4.4-live-server_qemu/smba_00 \
--target-list="riscv32-softmmu riscv64-softmmu x86_64-softmmu"

注意,不要enable_kvm 和 enable_debug

编译 qemu:

make -j

2,安装虚拟系统

2.1创建磁盘文件:

$ ./qemu/build/qemu-img create ubuntu-220404-kernel-00.qcow2 -f qcow2 150G

2.2 安装系统:

sudo ./qemu/build/qemu-system-x86_64 -m 196608M -smp 12 -boot c  \
-hda  ubuntu-220404-kernel-00.qcow2 \
-net nic -net user,smb=/home/hipper/ex_ubuntu-22.4.4-live-server_qemu/smba_00 \
--nographic -append console=ttyS0  \
-cdrom  ubuntu-22.04.4-live-server-amd64.iso  \
-kernel ./ubuntu-220404/iso_ubuntu-22.04.4-live-server-amd64/casper/vmlinuz  \
-initrd  ./ubuntu-220404/iso_ubuntu-22.04.4-live-server-amd64/casper/initrd

不带 -c host  --enable-kvm

2.3 重启验证:

sudo ./qemu/build/qemu-system-x86_64 -m 32768M -smp 6 -boot c  \
-hda  ubuntu-220404-kernel-00.qcow2   --nographic \
-net nic -net user,smb=/home/hipper/ex_ubuntu-22.4.4-live-server_qemu/smba_00,hostfwd=tcp::2222-:22

3,调试kernel:

3.1 指定 -kernel vmlinux 启动

sudo ./qemu/build/qemu-system-x86_64 -m 32768M -smp 6 -boot c  \
-kernel ./debug_kernel/linux-source-5.15.0/vmlinux \
-hda  ubuntu-220404-kernel-00.qcow2    --nographic \
-net nic -net user,smb=/home/hipper/ex_ubuntu-22.4.4-live-server_qemu/smba_00,hostfwd=tcp::2222-:22 \
-s -S

3.2 调试 kernel

host :

$ gdb

#载入 debug 版本的 vmlinux

(gdb) file ./debug_kernel/linux_5.15.0/vmlinux

(gdb) target remote:1234

(gdb) b start_kernel

(gdb) start #忘记这个要不要了

(gdb) c

效果:

断点处stop,

未完待续。。。

         

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词