0

我可以像这样在虚拟机(此处为 ab21q)上运行 ubuntu 20.04。磁盘上drive0已经安装了 ubuntu (ab21q-ubuntu-20.04-image.img)。

qemu-system-aarch64 -nographic -machine ab21q,gic-version=max -m 512M -cpu max -smp 4 -netdev user,id=vnet,hostfwd=:127.0.0.1:0-:22 -device virtio-net-pci,netdev=vnet -drive file=ab21q-ubuntu-20.04-image.img,if=none,id=drive0,cache=writeback -device virtio-blk,drive=drive0,bootindex=0 -drive file=ubuntu-20.04-mini.iso,if=none,id=drive1,cache=writeback -device virtio-blk,drive=drive1,bootindex=1 -drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash

我必须在 ubuntu 上调试应用程序和驱动程序,为此我想通过在 qemu 代码中设置断点来检查传递的数据来查看 qemu 代码。如果我要在虚拟机上调试“应用程序”,我曾经使用“-s -S”选项运行 qemu,并使用虚拟机的调试器为 elf 文件运行 gdb。但是这次我想调试qemu。我试着跑步

ddd -command=gdb_script_qemu --args qemu-system-aarch64 -nographic -machine ab21q,gic-version=max -m 512M -cpu max -smp 4 -netdev user,id=vnet,hostfwd=:127.0.0.1:0-:22 -device virtio-net-pci,netdev=vnet -drive file=ab21q-ubuntu-20.04-image.img,if=none,id=drive0,cache=writeback -device virtio-blk,drive=drive0,bootindex=0 -drive file=ubuntu-20.04-mini.iso,if=none,id=drive1,cache=writeback -device virtio-blk,drive=drive1,bootindex=1 -drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash

但调试器窗口显示 linux 启动消息并提示我输入用户名和密码。我输入登录 ID 后花了很长时间,所以我退出了这个过程。(即使我进入了 ubuntu,我也可以将 linux shell 用作 gdb shell 吗?)我想要做的是像我一样运行程序,然后将带有 qemu-system-aarch64 可执行映像的调试器附加到正在运行的进程。我试过ddd qemu-system-aarch64 pid了,但这要求我从一开始就启动 qemu-system-aarch64,而不是使用 pid 附加到进程。我该怎么做?

4

0 回答 0