使用 Visual Studion Code 连接到 QEMU 中运行的 OP-TEE 的 gdb-server

HmT*_*HmT 4 debugging qemu gdbserver arm64 visual-studio-code

我正在 ARM-64 中设置 op-tee。我想知道是否可以使用在 ubuntu 18.04 下运行的 Visual Studio 代码来调试它。

到目前为止,我已经能够在 QEMU 中编译和运行 op-tee。并且还能够使用命令行 gdb 连接 gdb-server(点击此链接:https : //www.op-tee.org/docs/debug/)。

现在我想使用一些 GUI 而不是 gdb。由于我正在使用 Visual Studio 代码,所以我想知道是否可以配置 vsCode 来这样做?

我试过安装 cortex-debug 扩展(我不确定它是否正确),也试过 c/c++ 调试附加。但我不能让他们工作!

这是我的 launch.json 文件:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

    { 
        "name": "(gdb) Attach",
        "type": "cppdbg",
        "request": "attach",
        "program": "${workspaceFolder}/optee_os/out/arm/core/tee.elf",
        "miDebuggerServerAddress": "localhost:1234",
        "processId": "${command:pickProcess}",
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            },
            {
                "text": "optee"
            }
        ]
    },
    {
        "cwd": "${workspaceRoot}",
        "executable": "${workspaceFolder}/optee_os/out/arm/core/tee.elf",
        "name": "Debug Microcontroller",
        "request": "attach",
        "type": "cortex-debug",
        "servertype": "openocd"
    }
]
Run Code Online (Sandbox Code Playgroud)

}

我希望能够通过使用 Microsoft 可视代码远程连接到在 QEMU 下运行的 gdb-server 来调试 arm 应用程序。

任何使用扩展的建议表示赞赏。

HmT*_*HmT 6

我找到了对我有用的解决方案:

首先需要为 VS Code安装Native Debug扩展。

然后在launch.json文件中添加如下配置:

    {
        "type": "gdb",
        "request": "attach",
        "name": "Attach to QEMU",
        "executable": "${workspaceFolder}/optee_os/out/arm/core/tee.elf",
        "target": "localhost:1234",
        "remote": true,
        "cwd": "${workspaceRoot}", 
        "gdbpath": "~/devel/optee/toolchains/aarch64/bin/aarch64-linux-gnu-gdb"
    }
Run Code Online (Sandbox Code Playgroud)

笔记:

  • 仅当应用程序未运行时,您才能连接到 QEMU:
    • 在 QEMU 中键入 c 之前,它应该处于初始状态
    • 或者它在断点处停止
  • 不应该有其他客户端连接到它。

参考: