You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
Copy file name to clipboardExpand all lines: docs/build/configure-cmake-debugging-sessions.md
+52-29
Original file line number
Diff line number
Diff line change
@@ -22,21 +22,21 @@ You can also start a debug session from Solution Explorer. First, switch to **CM
22
22
23
23

24
24
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.
26
26
27
27
## Customize debugger settings
28
28
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:
30
30
31
31
-**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.
32
32
33
33

34
34
35
35
-**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.
-**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.
40
40
41
41

42
42
@@ -61,6 +61,7 @@ To reference any key in a *CMakeSettings.json* file, preface it with `cmake.` in
61
61
]
62
62
}
63
63
```
64
+
64
65
**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**.
65
66
66
67
## Launch.vs.json reference
@@ -71,12 +72,12 @@ There are many *launch.vs.json* properties to support all your debugging scenari
71
72
72
73
-`env`: Additional environment variables to add with the syntax:
73
74
74
-
```json
75
+
```json
75
76
"env": {
76
77
"DEBUG_LOGGING_LEVEL": "trace;info",
77
78
"ENABLE_TRACING": "true"
78
79
}
79
-
```
80
+
```
80
81
81
82
-`args`: Command-line arguments passed to the program to debug.
82
83
@@ -127,50 +128,66 @@ Use the following options to separate your build machine (defined in CMakeSettin
127
128
-`executable`: Indicates whether the deployed file is an executable.
128
129
129
130
### Execute custom gdb commands
131
+
130
132
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)
131
133
132
134
### Enable logging
135
+
133
136
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)
134
137
135
138
### Configuration type `cppdbg`
136
139
137
140
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.
138
141
139
142
-`name`: A friendly name to identify the configuration in the **Startup Item** dropdown.
143
+
140
144
-`project`: Specifies the relative path to the project file. You shouldn't need to change this when debugging a CMake project.
145
+
141
146
-`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
+
142
148
-`args`: Command-line arguments passed on startup to the program being debugged.
149
+
143
150
-`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
+
144
152
-`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
+
145
154
-`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
+
146
156
-`cwd`: Defaults to `"${debugInfo.defaultWorkingDirectory}"`. Full Unix path to the directory on the remote system where `program` is run. The directory must exist.
157
+
147
158
-`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
+
162
160
```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
+
]
172
171
```
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
+
173
189
- Run a script before the execution of gdb. Ensure execute permissions are set on your script.
190
+
174
191
```json
175
192
"pipeArgs": [
176
193
"/s",
@@ -182,11 +199,17 @@ The following options can be used when debugging on a remote system or WSL using
182
199
"--tty=${debugInfo.tty}"
183
200
],
184
201
```
202
+
185
203
- `stopOnEntry`: A boolean that specifies whether to break as soon as the process is launched. The default is false.
204
+
186
205
- `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
+
187
207
- `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
+
188
209
- `setupCommands`: One or more gdb command(s) to execute, to set up the underlying debugger.
210
+
189
211
- `miDebuggerPath`: The full path to gdb. When unspecified, Visual Studio searches PATH first for the debugger.
212
+
190
213
- Finally, all of the deployment options defined for the `cppgdb` configuration type can be used with the `cppdbg` configuration type as well.
0 commit comments