Setting up GDB in VSCode (Windows Example)
Configuring GDB Debugging in VSCode
In VSCode install the
C/C++extension(CTRL+SHIFT+Pand chooseExtensions: Install Extensions)In your project's top most directory create a folder and name it
.vscodeCreate a file
launch.jsoninside the.vscodefolder
Open
launch.jsonand add the following(replacing#...#sections with correct paths) :
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(arm-none-eabi-gdb) Launch",
"type": "cppdbg",
"request": "launch",
"miDebuggerPath": #ABSOLUTLE/PATH/TO/DEBUGGER#, // e.g. "C:\\Program Files\\arm-none-eabi-gcc\\bin\\arm-none-eabi-gdb.exe"
"targetArchitecture": "arm",
"program": #PATH\TO\IMAGE\FILE(relative path ok)#, //e.g. "${workspaceFolder}/_build/app/app",
"setupCommands": [
{"text": "set remotetimeout 5"},
{"text": "target remote localhost:3333"},
{"text": "monitor reset halt"},
{"text": #file ABSOLUTE\PATH\TO\IMAGE#, //e.g. "file C:\\Projects\\demo\\_build\\app\\app.elf"},
{"text": "load"},
{"text": "break main","ignoreFailures": true},
],
"launchCompleteCommand": "None",
"externalConsole": false,
"cwd": "${workspaceFolder}",
}
]
}
Launching GDB Debugging in VSCode with Lager
Plug device into Lager Gateway
Connect to device, e.g.
lager connect --device stm32f3x --interface stlink --transport hla_swdStart gdb server
~ lager gdbserver
Serving GDB on localhost:3333. Press Ctrl+C to quit.
In VSCode launch debugger with
CTRL + SHIFT + DPress
F5to begin debugging.
Note: breakpoints set in the launch.json file (i.e. "text": "break main} will not be visible during debugging, but they ARE active. When one of these breakpoints is hit the Debugger will display it as "Exception has occurred." which is not an error.


