qemu调试命令备份

1. 普通执行:run_qemu_aarch64.sh

qemu-system-aarch64 -machine virt -cpu cortex-a53 -machine type=virt -nographic -m 8192 -smp 8 -kernel ~/linux-4.19.81/arch/arm64/boot/Image -initrd ./rootfs.cpio.gz --append "rdinit=/linuxrc console=ttyAMA0"

 

2. GDB调试:run_qemu_aarch64_gdb.sh
qemu-system-aarch64 -machine virt -cpu cortex-a53 -machine type=virt -nographic -m 2048 -smp 2 -kernel ~/linux-4.19.81/arch/arm64/boot/Image -initrd ./rootfs.cpio.gz --append "rdinit=/linuxrc console=ttyAMA0" -S -s

以下两条是配套的gdb远程链接命令:

# aarch64-linux-gnu-gdb ./vmlinux 
# target remote localhost:1234

 

3. 主机和qemu共享文件夹:

① 主机执行:mkdir /tmp/share

② run_qemu_aarch64_share.sh
qemu-system-aarch64 -machine virt -cpu cortex-a53 -machine type=virt -nographic -m 2048 -smp 2 -kernel ~/linux-4.19.81/arch/arm64/boot/Image -initrd ./rootfs.cpio.gz --append "rdinit=/linuxrc console=ttyAMA0" -fsdev local,security_model=passthrough,id=fsdev0,path=/tmp/share -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare

③ qemu里的arm64终端执行:
# mkdir /tmp/hostshare
# mount -t 9p -o trans=virtio,version=9p2000.L hostshare /tmp/hostshare

 

4. 增加swap分区(未验证成功): run_qemu_aarch64_swap.sh
qemu-system-aarch64 -machine virt -cpu cortex-a53 -machine type=virt -nographic -m 2048 -smp 2 -kernel ~/linux-4.19.81/arch/arm64/boot/Image -initrd ./rootfs.cpio.gz --append "rdinit=/linuxrc console=ttyAMA0" -drive file=swap.img,format=raw,index=0,media=disk  -net nic -net tap,ifname=tap0,script=no
 

5. qemu使用kdump

qemu启动的内核发生错误也可以用kdump生成vmcore文件。
(1) 首先先将qemu的panic重启关闭,防止coredump的时候发生了reboot

echo 0 > /proc/sys/kernel/panic

(2) 触发kernel panic

echo c > /proc/sysrq-trigger 

(3) kernel panic后,使得qemu进入monitor模式

ctrl + A, --->  c,   qemu进入monitor模式

(4) 进入monitor模式后,进行coredump

dump-guest-memory -z xxx-vmcore

详细请参考以下链接

https://blog.csdn.net/yhb1047818384/article/details/104115915

 

 

你可能感兴趣的:(调试工具,kernel分析)