1
votes

Im using vscode with the cortex-debug/jlink extension to debug my cortex m target.

I need the capability to issue GDB commands during launch (attach to debug and start session).

In this specific case, i wanna issue the command "directory C:...\BUILD" to GDB to replace absolute paths within the output file (*.elf).

However i have no clue how i can issue GDB commands in the VSCode launch.json file.

Example:

{
  // extension: cortex debug
  "version": "0.2.0",
  "configurations": [
    {
      "type": "cortex-debug",
      "request": "launch",
      "name": "Debug J-Link",
      "cwd": "${workspaceRoot}",
      "executable": "${workspaceRoot}/BUILD/output.elf",
      "serverpath": "/usr/bin/JLinkGDBServerExe",
      "servertype": "jlink",
      "device": "...",
      "interface": "swd",
      "serialNumber": "",
      "jlinkscript": "",
      "runToMain": true,
      "svdFile": ""
    },
    ...

How can i add GDB commands to this?

1

1 Answers

0
votes

You can use the "postStartSessionCommands" and "postAttachCommands" parameters. Full list of all supported parameters that can be placed in a launch.json is available on Cortex-debug github here : https://github.com/Marus/cortex-debug/blob/master/package.json. Remember that those accept arrays of strings, so an example would be:

    {
        "cwd": "${workspaceRoot}",
        "executable": "./build/zephyr/zephyr.signed.confirmed.hex",
        "postStartSessionCommands": [
            "file /x/y/z/zephyr.elf"
        ],
        "breakAfterReset": true,
        (...)
    }