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).