Skip to content

Commit 9248d40

Browse files
author
Colin Robertson
authored
Update configure-cmake-debugging-sessions.md
Fix at least a couple of things Acrolinx will hate. @esweet431 The powers that be hate image files with capitalized extensions. Can you change the name and recommit cmake-targets-add-debug.PNG as cmake-targets-add-debug.png? Thanks!
1 parent a17d251 commit 9248d40

File tree

1 file changed

+52
-29
lines changed

1 file changed

+52
-29
lines changed

docs/build/configure-cmake-debugging-sessions.md

+52-29
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ You can also start a debug session from Solution Explorer. First, switch to **CM
2222

2323
![CMake targets view button](media/cmake-targets-view.png "CMake Targets View menu item")
2424

25-
Then, right-click on any executable and select **Debug**. This automatically starts debugging the selected target based on your active configuration.
25+
Then, right-click on an executable and select **Debug**. This command automatically starts debugging the selected target based on your active configuration.
2626

2727
## Customize debugger settings
2828

29-
You can customize the debugger settings for any executable CMake target in your project in a configuration file called *launch.vs.json* located in a *.vs* folder in your project root. For most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details. There are three entry points to this file:
29+
You can customize the debugger settings for any executable CMake target in your project in a configuration file called *launch.vs.json*, located in a *.vs* folder in your project root. A launch configuration file is useful in most debugging scenarios, because you can configure and save your debugging setup details. There are three entry points to this file:
3030

3131
- **Debug Menu:** Select **Debug > Debug and Launch Settings for ${activeDebugTarget}** from the main menu to customize the debug configuration specific to your active debug target. If you don't have a debug target selected, this option will be grayed out.
3232

3333
![Debug menu entry point](media/cmake-debug-menu.png "Debug menu entry point")
3434

3535
- **Targets View:** Navigate to **Targets View** in Solution Explorer. Then, right-click on a debug target and select **Add Debug Configuration** to customize the debug configuration specific to the selected target.
3636

37-
![Targets view entry point](media/cmake-targets-add-debug.PNG "Targets view entry point")
37+
![Targets view entry point](media/cmake-targets-add-debug.png "Targets view entry point")
3838

39-
- **Root CMakeLists.txt:** Right-click on a root CMakeLists.txt and select **Add Debug Configuration** to open the **Select a Debugger** dialog box. The dialog allows you to add *any* type of debug configuration, but you must manually specify the CMake target to invoke via the `projectTarget` property.
39+
- **Root CMakeLists.txt:** Right-click on a root *CMakeLists.txt* and select **Add Debug Configuration** to open the **Select a Debugger** dialog box. The dialog allows you to add *any* type of debug configuration, but you must manually specify the CMake target to invoke via the `projectTarget` property.
4040

4141
![Select a debugger dialog box](media/cmake-select-a-debugger.png "Select a debugger dialog box")
4242

@@ -61,6 +61,7 @@ To reference any key in a *CMakeSettings.json* file, preface it with `cmake.` in
6161
]
6262
}
6363
```
64+
6465
**Environment variables** defined in CMakeSettings.json can also be used in launch.vs.json using the syntax `${env.VARIABLE_NAME}`. In Visual Studio 2019 version 16.4 and later, debug targets are automatically launched with the environment you specify in CMakeSettings.json. You can unset an environment variable by setting it to **null**.
6566

6667
## Launch.vs.json reference
@@ -71,12 +72,12 @@ There are many *launch.vs.json* properties to support all your debugging scenari
7172

7273
- `env`: Additional environment variables to add with the syntax:
7374

74-
```json
75+
```json
7576
"env": {
7677
"DEBUG_LOGGING_LEVEL": "trace;info",
7778
"ENABLE_TRACING": "true"
7879
}
79-
```
80+
```
8081

8182
- `args`: Command-line arguments passed to the program to debug.
8283

@@ -127,50 +128,66 @@ Use the following options to separate your build machine (defined in CMakeSettin
127128
- `executable`: Indicates whether the deployed file is an executable.
128129

129130
### Execute custom gdb commands
131+
130132
Visual Studio supports executing custom gdb commands to interact directly with the underlying debugger. [Learn more](https://github.com/microsoft/MIEngine/wiki/Executing-custom-gdb-lldb-commands)
131133

132134
### Enable logging
135+
133136
Enable MIEngine logging to see what commands get sent to gdb, what output gdb returns, and how long each command takes. [Learn more](https://github.com/microsoft/MIEngine/wiki/Logging)
134137

135138
### Configuration type `cppdbg`
136139

137140
The following options can be used when debugging on a remote system or WSL using the `cppdbg` configuration type. In Visual Studio 2019 version 16.6 or later, configuration type `cppgdb` is recommended.
138141

139142
- `name`: A friendly name to identify the configuration in the **Startup Item** dropdown.
143+
140144
- `project`: Specifies the relative path to the project file. You shouldn't need to change this when debugging a CMake project.
145+
141146
- `projectTarget`: Specifies the CMake target to invoke when building the project. Visual Studio autopopulates this property if you enter *launch.vs.json* from the **Debug Menu** or **Targets View**. This value must match the name of an existing debug target listed in the **Startup Item** dropdown.
147+
142148
- `args`: Command-line arguments passed on startup to the program being debugged.
149+
143150
- `processID`: Linux process ID to attach to. Only used when attaching to a remote process. For more information, see [Troubleshoot attaching to processes using GDB](https://github.com/Microsoft/MIEngine/wiki/Troubleshoot-attaching-to-processes-using-GDB).
151+
144152
- `program`: Defaults to `"${debugInfo.fullTargetPath}"`. The Unix path to the application to debug. Only required if different than the target executable in the build or deploy location.
153+
145154
- `remoteMachineName`: Defaults to `"${debugInfo.remoteMachineName}"`. Name of the remote system that hosts the program to debug. Only required if different than the build system. Must have an existing entry in the [Connection Manager](../linux/connect-to-your-remote-linux-computer.md). Press **Ctrl+Space** to view a list of all existing remote connections.
155+
146156
- `cwd`: Defaults to `"${debugInfo.defaultWorkingDirectory}"`. Full Unix path to the directory on the remote system where `program` is run. The directory must exist.
157+
147158
- `environment`: Additional environment variables passed to the program being debugged. For example,
148-
```json
149-
"environment": [
150-
{
151-
"name": "ENV1",
152-
"value": "envvalue1"
153-
},
154-
{
155-
"name": "ENV2",
156-
"value": "envvalue2"
157-
}
158-
]
159-
```
160-
- `pipeArgs`: An array of command-line arguments passed to the pipe program to configure the connection. The pipe program is used to relay standard input/output between Visual Studio and gdb. Most of this array **does not need to be customized** when debugging CMake projects. The exception is the `${debuggerCommand}`. which launches gdb on the remote system and can be modified to:
161-
- Export the value of the environment variable DISPLAY on your Linux system. In the following example, this value is `:1`.
159+
162160
```json
163-
"pipeArgs": [
164-
"/s",
165-
"${debugInfo.remoteMachineId}",
166-
"/p",
167-
"${debugInfo.parentProcessId}",
168-
"/c",
169-
"export DISPLAY=:1;${debuggerCommand}",
170-
"--tty=${debugInfo.tty}"
171-
],
161+
"environment": [
162+
{
163+
"name": "ENV1",
164+
"value": "envvalue1"
165+
},
166+
{
167+
"name": "ENV2",
168+
"value": "envvalue2"
169+
}
170+
]
172171
```
172+
173+
- `pipeArgs`: An array of command-line arguments passed to the pipe program to configure the connection. The pipe program is used to relay standard input/output between Visual Studio and gdb. Most of this array **does not need to be customized** when debugging CMake projects. The exception is the `${debuggerCommand}`. which launches gdb on the remote system and can be modified to:
174+
175+
- Export the value of the environment variable DISPLAY on your Linux system. In the following example, this value is `:1`.
176+
177+
```json
178+
"pipeArgs": [
179+
"/s",
180+
"${debugInfo.remoteMachineId}",
181+
"/p",
182+
"${debugInfo.parentProcessId}",
183+
"/c",
184+
"export DISPLAY=:1;${debuggerCommand}",
185+
"--tty=${debugInfo.tty}"
186+
],
187+
```
188+
173189
- Run a script before the execution of gdb. Ensure execute permissions are set on your script.
190+
174191
```json
175192
"pipeArgs": [
176193
"/s",
@@ -182,11 +199,17 @@ The following options can be used when debugging on a remote system or WSL using
182199
"--tty=${debugInfo.tty}"
183200
],
184201
```
202+
185203
- `stopOnEntry`: A boolean that specifies whether to break as soon as the process is launched. The default is false.
204+
186205
- `visualizerFile`: A [.natvis file](/visualstudio/debugger/create-custom-views-of-native-objects) to use when debugging this process. This option is incompatible with gdb pretty printing. Also set `showDisplayString` when you set this property.
206+
187207
- `showDisplayString`: A boolean that enables the display string when a `visualizerFile` is specified. Setting this option to `true` can cause slower performance during debugging.
208+
188209
- `setupCommands`: One or more gdb command(s) to execute, to set up the underlying debugger.
210+
189211
- `miDebuggerPath`: The full path to gdb. When unspecified, Visual Studio searches PATH first for the debugger.
212+
190213
- Finally, all of the deployment options defined for the `cppgdb` configuration type can be used with the `cppdbg` configuration type as well.
191214

192215
::: moniker-end

0 commit comments

Comments
 (0)