diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/app_debug.png b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/app_debug.png new file mode 100644 index 0000000000000000000000000000000000000000..0b5f19a0526210c8167989f68dbfb00e0c555fa1 Binary files /dev/null and b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/figures/app_debug.png differ diff --git a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md index 2c96b989d52b602c2feb8aaf55f0ba9f4d683871..3cde910ae0116d707d3532a7c83c05d4086cbf27 100644 --- a/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md +++ b/rt-thread-version/rt-thread-smart/debug/qemu-arm-linux/qemu-arm-linux.md @@ -78,9 +78,11 @@ export PATH="$RTT_EXEC_PATH:$PATH" 在 userapps 中,编译 app: +用户态的应用用xmake编默认没有调试符号 + ``` cd apps -xmake f -a aarch64 # 配置为 aarch64 平台 +xmake f -m debug -a aarch64 # 配置为 aarch64 平台,并指定debug模式,就有调试信息了 xmake -j8 ``` @@ -88,7 +90,7 @@ xmake -j8 ``` xmake smart-rootfs -xmake smart-image -o ../prebuilt/qemu-virt64-aarch64-ext4/ext4.img # 将镜像输出至 qemu-virt64-aarch64-ext4 目录 +xmake smart-image -o ../prebuilt/qemu-virt64-aarch64/ext4.img # 将镜像输出至 qemu-virt64-aarch64 目录 ``` > 注意事项: @@ -119,8 +121,8 @@ xmake smart-image -o ../prebuilt/qemu-virt64-aarch64-ext4/ext4.img # 将镜像 要想使用 VSCode 调试用户态应用,需要先在工程路径下添加调试配置。 -1. 首先在终端使用命令 `code .`,使用 VSCode 打开该目录。 -2. 修改 `\rt-thread\bsp\qemu-virt64-aarch64` 目录下 `.vscode` 文件夹中的 `launch.json` 配置,如下所示(需要更新实际的 gdb 路径): +1. 首先在 `\userapps` 目录下使用命令 `code .`,使用 VSCode 打开该目录。 +2. 在 `\userapps` 目录下创建launch.json ,如下所示(需要更新实际的 gdb 路径): ```json { @@ -134,16 +136,16 @@ xmake smart-image -o ../prebuilt/qemu-virt64-aarch64-ext4/ext4.img # 将镜像 "stopAtEntry": true, "externalConsole": true, "cwd": "${workspaceRoot}", - "program": "${workspaceRoot}/rtthread.elf", + "program": "${workspaceRoot}/apps/build/rootfs/bin/smart-fetch", "serverLaunchTimeout": 2000, - "miDebuggerPath":"/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gdb", + "miDebuggerPath":"/usr/bin/gdb-multiarch", "miDebuggerServerAddress": ":1234", "setupCommands": [ { "text": "cd ${workspaceRoot}" }, { - "text": "file rtthread.elf" + "text": "file ${workspaceRoot}/apps/build/rootfs/bin/smart-fetch" }, { "text": "break main" @@ -154,8 +156,11 @@ xmake smart-image -o ../prebuilt/qemu-virt64-aarch64-ext4/ext4.img # 将镜像 }, ] } + ``` +launch.json 配置文件中的 `smart-fetch`,改为自己要调试的应用。 + 如果上述配置 launch.json 的文件无法进行调试,那就使用以下配置: ```json @@ -199,12 +204,16 @@ launch.json 配置文件中的 `rtthread.elf`,改为自己要调试的应用 ![](figures/run_debug.png) -2. 在 VSCode 终端输入 `./run.sh`,如果调试的是内核,可以看到启动过程被挂起,等待调试前端来连接。 +2. 在 VSCode 终端输入 `./run.sh`,如果调试的是内核,可以看到启动过程被挂起,等待调试前端来连接。 3. 在 VSCode 中按下 F5 开始调试内核,可以看到应用的源码文件被打开,运行的代码将停在断点处。 ![image-20221026104404817](figures/vsc-debug.png) +4. 如果调试的是用户态应用,我们以 smart_fetch 为例,在VSCode终端输入 `./run.sh`,并按下F5开始调试,选择要运行的用户态应用,运行的代码将停在断点处 + + + 5. 后续就可以单步调试用户态应用了。单步运行后,应用代码执行的打印将显示在终端上。 ![image-20221026104855575](figures/debug_rtthread.png)