- 安装依赖:
sudo apt install -y --no-install-recommends \
build-essential \
sudo \
gcc-aarch64-linux-gnu \
libncurses-dev \
libyaml-dev \
flex \
bison \
git \
wget \
uuid-runtime \
qemu-kvm \
qemu-system-x86 \
qemu-system-arm \
sgabios \
gdb-multiarch- 克隆项目并进入目录:
git clone https://github.com/zju-aces-aios/OS-2026.git
cd app-helloworld- 初始化和编译:
UK_DEFCONFIG=$(pwd)/defconfigs/qemu-arm64 make defconfig
make -j8- 启动 QEMU 运行 helloworld:
qemu-system-aarch64 -kernel workdir/build/helloworld_qemu-arm64 -nographic -machine virt -cpu cortex-a57- 常用操作与命令:
- 退出 QEMU:按
Ctrl+A,然后按X
- 退出 QEMU:按
- 启动 QEMU 并开启 gdb 远程调试端口:
qemu-system-aarch64 -kernel workdir/build/helloworld_qemu-arm64 -nographic -machine virt -cpu cortex-a57 -s -S参数说明:
-s:等价于-gdb tcp::1234,在 1234 端口开启 gdb 远程调试。-S:QEMU 启动后暂停,等待 gdb 连接。
- 另开一个终端,使用 gdb-multiarch 连接 QEMU:
gdb-multiarch workdir/build/helloworld_qemu-arm64.dbg --eval-command="target remote :1234"- 设置断点并开始调试,例如:
(gdb) b main
(gdb) c- 查看汇编代码,推荐使用 TUI 模式:
(gdb) layout asm- 该命令会在 gdb 中打开汇编窗口,方便单步跟踪。
- 可用
Ctrl+X A切换回普通模式。