1

I'm using GDB to connect to a remote GDB server (OpenOCD, ARM). The program on the target uses semi hosting to print some debug messages.

I need to run in GDB these commands:

target remote 127.0.0.1:3333
monitor arm semihosting enable

Note that I must first connect to the remote target and then enable semihosting.

This works fine when running OpenOCD and gdb-multiarch from the command line. Now I would like to use an IDE: Theia and the CPP debug extension (which is based on the VS Code plugin cdt-gdb-vscode). How can I ensure that "monitor arm semihosting enable" is ran automatically after connecting to the target?

The launch.json is as follows:

{
  "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"
      }
  ]
}

I have tried adding commands to .gdbinit. Those commands are ran when I use the command line but not when using the IDE (Probably GDB is started from a different working directory).

Gama11
  • 31,714
  • 9
  • 78
  • 100
dwjbosman
  • 906
  • 9
  • 33
  • 1
    > different working directory If you put it in ~/.gdbinit, working directory shouldn't matter (but it's still possible that the IDE disables reading it for some reason) – Christian B Sep 22 '19 at 21:42

0 Answers0