You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker容器内QEMU环境下VSCode调试Launch.json配置求助

解决VSCode附加QEMU远程调试时“未指定可执行文件”的问题

我是Docker、QEMU、GDB新手,通过CLI执行make debug和make gdb能正常调试,但用VSCode调试器附加运行中的QEMU目标时,弹出“未指定可执行文件”错误。当前在x86/64机器的Ubuntu开发容器里工作,问题出在VSCode误把ARM目标ELF当成本地x86 ELF文件识别。

目标ELF文件信息

root@6d0880bb1ed3:/work/RapidPatch/VulDevices/qemu-stm32-p103/build# file ./arm-start.elf 
./arm-start.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

当前Launch.json配置

{
    "version": "0.2.0",
    "configurations": [
        {
            "useExtendedRemote": true,
            "name": "Attach to QEMU (GDB Remote)",
            "type": "cppdbg",
            "request": "attach",
            "MIMode": "gdb",
            "miDebuggerServerAddress": "localhost:1234",
            "miDebuggerPath": "${workspaceFolder}/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gdb",
            "program": "${workspaceFolder}/RapidPatch/VulDevices/qemu-stm32-p103/build/arm-start.elf"
        }
    ]
}

修复步骤

问题根源是VSCode的cppdbg调试器默认会检查program指定的ELF是否与本地系统架构匹配,而ARM ELF和x86/64容器架构不兼容,导致误判。需要添加两个配置项解决:

  1. 添加targetArchitecture字段,明确指定目标架构为ARM
  2. 添加skipExecutableCheck字段,禁用本地可执行文件兼容性检查

修改后的完整Launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "useExtendedRemote": true,
            "name": "Attach to QEMU (GDB Remote)",
            "type": "cppdbg",
            "request": "attach",
            "MIMode": "gdb",
            "miDebuggerServerAddress": "localhost:1234",
            "miDebuggerPath": "${workspaceFolder}/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gdb",
            "program": "${workspaceFolder}/RapidPatch/VulDevices/qemu-stm32-p103/build/arm-start.elf",
            "targetArchitecture": "arm",
            "skipExecutableCheck": true
        }
    ]
}

内容的提问来源于stack exchange,提问作者Chang Jia Jun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 16:20:04