1

我正在使用 GDB 连接到远程 GDB 服务器(OpenOCD、ARM)。目标上的程序使用半托管打印一些调试消息。

我需要在 GDB 中运行这些命令:

target remote 127.0.0.1:3333
monitor arm semihosting enable

请注意,我必须先连接到远程目标,然后才能启用半主机。

这在从命令行运行 OpenOCD 和 gdb-multiarch 时效果很好。现在我想使用一个 IDE:Theia 和 CPP 调试扩展(基于 VS Code 插件 cdt-gdb-vscode)。如何确保在连接到目标后自动运行“monitor arm semihosting enable”?

launch.json 如下:

{
  "version": "0.2.0",
  "configurations": [

      {
          "gdb": "gdb-multiarch",
          "type": "gdbtarget",
          "request": "attach",
          "verbose": true,
          "openGdbConsole": true,
          "openDebug": "openOnDebugBreak",
          "name": "Remote debug",
          "target": {"port": "1234", "host": "127.0.0.1"},
          "program": "${workspaceFolder}/target/thumbv7m-none-eabi/debug/example-embedded"
      }
  ]
}

我尝试将命令添加到 .gdbinit。这些命令在我使用命令行时运行,但在使用 IDE 时不会运行(可能 GDB 是从不同的工作目录启动的)。

4

0 回答 0