vscode cortex-debug launch.json gdb external configuration, how to have the right parameters

The goal is to have a remote debug session configured and running from vscode with nrf52840 mcu.

I am at the moment configuring a remote debug session on an internal LAN network (out of a docker devcontainer) with:

Here is the launch.json configuration used:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"version": "0.2.0",
"configurations": [
{
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/application/_build/application.out",
"name": "Debug devcontainer launch",
"request": "launch",
"type": "cortex-debug",
"servertype": "external",
"gdbPath": "/usr/bin/gdb-multiarch",
"gdbTarget": "host.docker.internal:2331",
"device": "NRF52840_XXAA",
"runToEntryPoint": "main",
"svdFile": "${workspaceRoot}/nrf5_sdk/modules/nrfx/mdk/nrf52840.svd",
"showDevDebugOutput": "both"
},
]
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

After starting the debug session I can see that:

  • The debug session actually connects to the SEGGER GDB Server running on the windows host, reads the memory and programs it in case of needs as the log proves it:
    • Fullscreen
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      Connected to 127.0.0.1
      Reading all registers
      Read 4 bytes @ address 0x0004AB22 (Data = 0x21204A32)
      Read 4 bytes @ address 0x0004AB1E (Data = 0xAF00B088)
      Read 4 bytes @ address 0x0004AB22 (Data = 0x21204A32)
      Read 4 bytes @ address 0x0004AB1E (Data = 0xAF00B088)
      Read 2 bytes @ address 0x0004AB22 (Data = 0x4A32)
      Read 2 bytes @ address 0x0004AB20 (Data = 0xAF00)
      Read 2 bytes @ address 0x0004AB1E (Data = 0xB088)
      Read 2 bytes @ address 0x0004AB22 (Data = 0x4A32)
      Read 2 bytes @ address 0x0004AB20 (Data = 0xAF00)
      Read 2 bytes @ address 0x0004AB1E (Data = 0xB088)
      Read 4 bytes @ address 0x0004AB22 (Data = 0x21204A32)
      Read 4 bytes @ address 0x0004AB1E (Data = 0xAF00B088)
      Read 4 bytes @ address 0x0004AB22 (Data = 0x21204A32)
      Read 4 bytes @ address 0x0004AB1E (Data = 0xAF00B088)
      Read 4 bytes @ address 0x0004AB22 (Data = 0x21204A32)
      Read 4 bytes @ address 0x0004AB22 (Data = 0x21204A32)
      Read 4 bytes @ address 0x0004AB22 (Data = 0x21204A32)
      Received monitor command: reset halt
      Expected an decimal digit (0-9)
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  • Some GDB commands are somehow not expected by the J-Link GDB server as seen in the logs:
    • Received monitor command: reset halt
      Expected an decimal digit (0-9)
    • Any ideas regarding that?
  • The cortex-debug extension in vscode outputs the following log in DEBUG CONSOLE
    • Fullscreen
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      Cortex-Debug: VSCode debugger extension version 1.6.9 git(4c381ef). Usage info: https://github.com/Marus/cortex-debug#usage
      Reading symbols from /usr/bin/objdump-multiarch --syms -C -h -w /workspaces/fw-pod/application/_build/pod_application.out
      Reading symbols from /usr/bin/nm-multiarch --defined-only -S -l -C -p /workspaces/fw-pod/application/_build/pod_application.out
      Launching GDB: /usr/bin/gdb-multiarch -q --interpreter=mi2
      1-gdb-version
      Error: /usr/bin/nm-multiarch failed! statics/global/functions may not be properly classified: Error: spawn /usr/bin/nm-multiarch ENOENT
      Expecting `nm` next to `objdump`. If that is not the problem please report this.
      Error: objdump failed! statics/globals/functions may not be properly classified: Error: spawn /usr/bin/objdump-multiarch ENOENT ENOENT means program not found. If that is not the issue, please report this problem.Finished reading symbols from objdump: Time: 15 ms
      Finished reading symbols from nm: Time: 13 ms
      -> =thread-group-added,id="i1"
      GDB -> App: {"output":"","outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-added","output":[["id","i1"]]}]}
      -> ~"GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1\n"
      GDB -> App: {"output":"","outOfBandRecord":[{"isStream":true,"type":"console","content":"GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1\n"}]}
      -> ~"Copyright (C) 2022 Free Software Foundation, Inc.\n"
      GDB -> App: {"output":"","outOfBandRecord":[{"isStream":true,"type":"console","content":"Copyright (C) 2022 Free Software Foundation, Inc.\n"}]}
      -> ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
      GDB -> App: {"output":"","outOfBandRecord":[{"isStream":true,"type":"console","content":"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."}]}
      -> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
      GDB -> App: {"output":"","outOfBandRecord":[{"isStream":true,"type":"console","content":"\nType \"show copying\" and \"show warranty\" for details.\n"}]}
      -> ~"This GDB was configured as \"x86_64-linux-gnu\".\n"
      GDB -> App: {"output":"","outOfBandRecord":[{"isStream":true,"type":"console","content":"This GDB was configured as \"x86_64-linux-gnu\".\n"}]}
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Questions:

  • Do you have any inputs regarding the launch.json configuration and tools chosen?
    • Is it a good option, should I change something?
  • Is there some pre/post debug sequences I should add/adapt?
    • preLaunchCommands?
    • postLaunchCommands?
    • overrideResetCommands?
    • overrideRestartCommands?
    • postAttachCommands?
    • postLaunchCommands?
    • postResetCommands?
    • ect...
  • Any other inputs?

Thanks.
Matthieu