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
Copy file name to clipboardExpand all lines: docs/debugger/getting-started-with-the-debugger-cpp.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ ms.workload:
17
17
---
18
18
# Tutorial: Learn to debug C++ code using Visual Studio
19
19
20
-
This article introduces the features of the Visual Studio debugger in a step-by-step walkthrough. If you want a higher-level view of the debugger features, see [First look at the debugger](../../debugger/debugger-feature-tour.md). When you *debug your app*, it usually means that you are running your application with the debugger attached. When you do this, the debugger provides many ways to see what your code is doing while it runs. You can step through your code and look at the values stored in variables, you can set watches on variables to see when values change, you can examine the execution path of your code, see whether a branch of code is running, and so on. If this is the first time that you've tried to debug code, you may want to read [Debugging for absolute beginners](../../debugger/debugging-absolute-beginners.md) before going through this article.
20
+
This article introduces the features of the Visual Studio debugger in a step-by-step walkthrough. If you want a higher-level view of the debugger features, see [First look at the debugger](../debugger/debugger-feature-tour.md). When you *debug your app*, it usually means that you are running your application with the debugger attached. When you do this, the debugger provides many ways to see what your code is doing while it runs. You can step through your code and look at the values stored in variables, you can set watches on variables to see when values change, you can examine the execution path of your code, see whether a branch of code is running, and so on. If this is the first time that you've tried to debug code, you may want to read [Debugging for absolute beginners](../debugger/debugging-absolute-beginners.md) before going through this article.
21
21
22
22
Although the demo app is C++, most of the features are applicable to C#, Visual Basic, F#, Python, JavaScript, and other languages supported by Visual Studio (F# does not support Edit-and-continue. F# and JavaScript do not support the **Autos** window). The screenshots are in C++.
23
23
@@ -131,7 +131,7 @@ First, you'll create a C++ console application project. The project type comes w
131
131
132
132
## Start the debugger!
133
133
134
-
1. Press **F5** (**Debug > Start Debugging**) or the **Start Debugging** button  in the Debug Toolbar.
134
+
1. Press **F5** (**Debug > Start Debugging**) or the **Start Debugging** button  in the Debug Toolbar.
135
135
136
136
**F5** starts the app with the debugger attached to the app process, but right now we haven't done anything special to examine the code. So the app just loads and you see the console output.
137
137
@@ -150,7 +150,7 @@ First, you'll create a C++ console application project. The project type comes w
150
150
151
151
In this tutorial, we'll take a closer look at this app using the debugger and get a look at the debugger features.
152
152
153
-
2. Stop the debugger by pressing the red stop  button (**Shift** + **F5**).
153
+
2. Stop the debugger by pressing the red stop  button (**Shift** + **F5**).
154
154
155
155
3. In the console window, press a key and **Enter** to close the console window.
156
156
@@ -160,19 +160,19 @@ First, you'll create a C++ console application project. The project type comes w
160
160
161
161
`name += letters[i];`
162
162
163
-
A red circle  appears where you set the breakpoint.
163
+
A red circle  appears where you set the breakpoint.
164
164
165
165
Breakpoints are one of the most basic and essential features of reliable debugging. A breakpoint indicates where Visual Studio should suspend your running code so you can take a look at the values of variables, or the behavior of memory, or whether or not a branch of code is getting run.
166
166
167
-
2. Press **F5** or the **Start Debugging** button , the app starts, and the debugger runs to the line of code where you set the breakpoint.
167
+
2. Press **F5** or the **Start Debugging** button , the app starts, and the debugger runs to the line of code where you set the breakpoint.
168
168
169
169

170
170
171
171
The yellow arrow represents the statement on which the debugger paused, which also suspends app execution at the same point (this statement has not yet executed).
172
172
173
173
If the app is not yet running, **F5** starts the debugger and stops at the first breakpoint. Otherwise, **F5** continues running the app to the next breakpoint.
174
174
175
-
Breakpoints are a useful feature when you know the line of code or the section of code that you want to examine in detail. For information on the different types of breakpoints you can set, such as conditional breakpoints, see [Using breakpoints](../../debugger/using-breakpoints.md).
175
+
Breakpoints are a useful feature when you know the line of code or the section of code that you want to examine in detail. For information on the different types of breakpoints you can set, such as conditional breakpoints, see [Using breakpoints](../debugger/using-breakpoints.md).
176
176
177
177
## Navigate code in the debugger using step commands
178
178
@@ -190,7 +190,7 @@ Mostly, we use the keyboard shortcuts here, because it's a good way to get fast
190
190
191
191

192
192
193
-
F11 is the **Step Into** command and advances the app execution one statement at a time. F11 is a good way to examine the execution flow in the most detail. (To move faster through code, we show you some other options also.) By default, the debugger skips over non-user code (if you want more details, see [Just My Code](../../debugger/just-my-code.md)).
193
+
F11 is the **Step Into** command and advances the app execution one statement at a time. F11 is a good way to examine the execution flow in the most detail. (To move faster through code, we show you some other options also.) By default, the debugger skips over non-user code (if you want more details, see [Just My Code](../debugger/just-my-code.md)).
194
194
195
195
Let's say that you are done examining the `SendMessage` method, and you want to get out of the method but stay in the debugger. You can do this using the **Step Out** command.
196
196
@@ -206,28 +206,28 @@ Mostly, we use the keyboard shortcuts here, because it's a good way to get fast
206
206
207
207

208
208
209
-
Notice this time that the debugger does not step into the `SendMessage` method. **F10** advances the debugger without stepping into functions or methods in your app code (the code still executes). By pressing **F10** on the `SendMessage` method call (instead of **F11**), we skipped over the implementation code for `SendMessage` (which maybe we're not interested in right now). For more information on different ways to move through your code, see [Navigate code in the debugger](../../debugger/navigating-through-code-with-the-debugger.md).
209
+
Notice this time that the debugger does not step into the `SendMessage` method. **F10** advances the debugger without stepping into functions or methods in your app code (the code still executes). By pressing **F10** on the `SendMessage` method call (instead of **F11**), we skipped over the implementation code for `SendMessage` (which maybe we're not interested in right now). For more information on different ways to move through your code, see [Navigate code in the debugger](../debugger/navigating-through-code-with-the-debugger.md).
210
210
211
211
## Navigate code using Run to Click
212
212
213
213
1. Press **F5** to advance to the breakpoint.
214
214
215
-
1. In the code editor, scroll down and hover over the `std::wcout` function in the `SendMessage` method until the green **Run to Click** button  appears on the left. The tooltip for the button shows "Run execution to here".
215
+
1. In the code editor, scroll down and hover over the `std::wcout` function in the `SendMessage` method until the green **Run to Click** button  appears on the left. The tooltip for the button shows "Run execution to here".
216
216
217
217

218
218
219
219
> [!NOTE]
220
-
> The **Run to Click** button is new in [!include[vs_dev15](../../misc/includes/vs_dev15_md.md)]. (If you don't see the green arrow button, use **F11** in this example instead to advance the debugger to the right place.)
220
+
> The **Run to Click** button is new in [!include[vs_dev15](../misc/includes/vs_dev15_md.md)]. (If you don't see the green arrow button, use **F11** in this example instead to advance the debugger to the right place.)
221
221
222
-
2. Click the **Run to Click** button .
222
+
2. Click the **Run to Click** button .
223
223
224
224
The debugger advances to the `std::wcout` function.
225
225
226
226
Using this button is similar to setting a temporary breakpoint. **Run to Click** is handy for getting around quickly within a visible region of app code (you can click in any open file).
227
227
228
228
## Restart your app quickly
229
229
230
-
Click the **Restart**  button in the Debug Toolbar (**Ctrl** + **Shift** + **F5**).
230
+
Click the **Restart**  button in the Debug Toolbar (**Ctrl** + **Shift** + **F5**).
231
231
232
232
When you press **Restart**, it saves time versus stopping the app and restarting the debugger. The debugger pauses at the first breakpoint that is hit by executing code.
233
233
@@ -294,7 +294,7 @@ Features that allow you to inspect variables are one of the most useful features
294
294
295
295
You can double-click a line of code to go look at that source code and that also changes the current scope being inspected by the debugger. This action does not advance the debugger.
296
296
297
-
You can also use right-click menus from the **Call Stack** window to do other things. For example, you can insert breakpoints into specified functions, advance the debugger using **Run to Cursor**, and go examine source code. For more information, see [How to: Examine the Call Stack](../../debugger/how-to-use-the-call-stack-window.md).
297
+
You can also use right-click menus from the **Call Stack** window to do other things. For example, you can insert breakpoints into specified functions, advance the debugger using **Run to Cursor**, and go examine source code. For more information, see [How to: Examine the Call Stack](../debugger/how-to-use-the-call-stack-window.md).
298
298
299
299
## Change the execution flow
300
300
@@ -320,5 +320,5 @@ Features that allow you to inspect variables are one of the most useful features
320
320
In this tutorial, you've learned how to start the debugger, step through code, and inspect variables. You may want to get a high-level look at debugger features along with links to more information.
321
321
322
322
> [!div class="nextstepaction"]
323
-
> [First look at the debugger](../../debugger/debugger-feature-tour.md)
323
+
> [First look at the debugger](../debugger/debugger-feature-tour.md)
0 commit comments