How to customize launch and debug configurations¶
You can customize and bind specific actions when launching the debugger in VS Code, similarly to the build and flash task configuration.
To tweak the debugging configuration for your specific setup, open and edit a launch.json
file.
This allows you to launch the debugger with custom debugging setup, including:
- launch.json attributes native to Visual Studio Code;
-
extension-specific configuration fields for debugging with the extension's debug type. These configuration fields allow you to do the following actions:
- Launch against a server that already runs.
- Target non-localhost servers.
- Use servers other than SEGGER's (for example, west debug).
- Run without a configured toolchain.
You can read more about the general uses of launch configurations in VS Code's documentation.
There are two ways to open a launch.json
file and start adding custom debugging configurations.
How to open launch.json from the Actions View¶
To start customizing from the Actions View, complete the following steps:
- Hover your cursor over Debug.
- Click the cogwheel icon called Configure debugging.
How to open launch.json from the menu bar¶
To start customizing from the top-level menu bar, complete the following steps:
- Go to Run > Add Configuration.... A list of debuggers appears.
- Choose
nRF Connect
.
Examples¶
The following example shows a launch.json
file using the nrf-connect
debug type.
{
"version": "0.2.0",
"configurations": [
{
"type": "nrf-connect",
"request": "launch",
"name": "Launch active build configuration",
"config": "${activeConfig}",
"runToEntryPoint": "main",
"preLaunchTask": "nRF Connect: Build active configuration"
},
{
"name": "Launch build_nrf52840dk_nrf52840",
"type": "nrf-connect",
"request": "launch",
"config": "c:\\Users\\joe\\workspace\\apps\\hello_world\\build_nrf52840",
"runToEntryPoint": "main"
}
]
}
The following example shows a launch.json
file using the nrf-connect
debug type, like in the previous example, but with the configuration that allows you to launch the debugger against a debugging server that is already running. This is done by changing the value of the request
configuration field to attach
and removing the runToEntryPoint
configuration field.
{
"version": "0.2.0",
"configurations": [
{
"type": "nrf-connect",
"request": "attach",
"name": "Launch active build configuration",
"config": "${activeConfig}"
}
]
}
The following example shows a configuration that lets you set up a debug session against a remote GDB server.
The server is already running on the IP address 10.0.0.84
, port 2331
, using the serverAddress
and flash
configuration fields:
{
"configurations": [
{
"type": "nrf-connect",
"request": "attach",
"config": "${activeConfig}",
"serverpath": null,
"serverAddress": "10.0.0.84:2331",
"flash": false
}
]
}