QEMU调试linux kernel
1.第一步下载linux源代码,执行make menuconfig, save
2. make ; make modules
3. 拷贝bzimage 和vmlinux到windows目录下
4.启动
5.使用tdm gcc套件里面的gdb
1 qemu-system-x86_64 -kernel bzImage -nographic -append "console=ttyS0 root=/dev/ram0 nokaslr" -initrd test.cpio.gz -m 2048 -s -S 2 3 qemu-system-x86_64 -kernel bzImage -nographic -append "console=ttyS0 root=/dev/ram0 nokaslr" -initrd test.cpio-wrapfs.gz -m 2048 -s -S 4 5 qemu-system-x86_64 -kernel bzImage -append "root=/dev/ram0 nokaslr" -initrd test.cpio-wrapfs.gz -m 2048 -s -S 6 7 $ gdb vmlinux 8 (gdb) source vmlinux-gdb.py 9 (gdb) target remote :1234 10 (gdb) hbreak start_kernel 11 (gdb) c 12 (gdb) lx-dmesg 13 14 15 set substitute-path E:\maojun\share\linux-5.3.0\linux-source-5.3.0 16 source dir:E:\\maojun\\share\\linux-5.3.0\\linux-source-5.3.0 17 18 dir E:\\maojun\\share\\linux-5.3.0\\linux-source-5.3.0 19 20 dir /cygdrive/e/maojun/share/linux-5.3.0/linux-source-5.3.0 21 22 cat /proc/modules 23 24 dir C:\\Users\\zbZle\\Desktop\\book\\qemu\\kernel-debug\\wrapfs-latest-e9c6d88\\ 25 26 dir C:\\Users\\zbZle\\Desktop\\book\\qemu\\kernel-debug\\netlink\\ 27 28 29 C:\\Users\\zbZle\\Desktop\\book\\qemu\\kernel-debug\\wrapfs-latest-e9c6d88\\wrapfs.ko 0xffffffffc0002000 30 31 // 32 // 加入 33 // 34 add-symbol-file C:\\Users\\zbZle\\Desktop\\book\\qemu\\kernel-debug\\wrapfs-latest-e9c6d88\\wrapfs.ko 0xffffffffc0002000 35 36 add-symbol-file C:\\Users\\zbZle\\Desktop\\book\\qemu\\kernel-debug\\netlink\\netlink-kernel.ko 0xffffffffc0002000 37 38 wrapfs 32768 0 - Live 0xffffffffc0002000 (OE)
1 解压 2 cpio -idmv < ../xxxxxxxxxxxxxxx.rootfs.cpio 3 1 4 压缩 5 find . | cpio -o -H newc > ../test.cpio 6 7 8 cd /cygdrive/c/Users/zbZle/Desktop/book/qemu/debian