Skip to content

Commit a88f176

Browse files
Merge pull request #10319 from Mikejo5000/mikejo-br16
Update debugger get started topics for C++
2 parents 6e866c9 + 8b54a82 commit a88f176

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

docs/debugger/getting-started-with-the-debugger-cpp.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Tutorial: Debug C++ code"
33
description: Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C++ application.
44
ms.custom: "debug-experiment, vs-acquisition, get-started"
5-
ms.date: 02/04/2020
5+
ms.date: 08/18/2022
66
ms.technology: vs-ide-debug
77
ms.topic: tutorial
88
dev_langs:
@@ -53,9 +53,6 @@ If you need to install the workload but already have Visual Studio, go to **Tool
5353

5454
First, you'll create a C++ console application project. The project type comes with all the template files you'll need, before you've even added anything!
5555

56-
57-
::: moniker range=">=vs-2019"
58-
5956
1. Open Visual Studio.
6057

6158
If the start window is not open, choose **File** > **Start Window**.
@@ -66,7 +63,12 @@ First, you'll create a C++ console application project. The project type comes w
6663

6764
After you apply the language and platform filters, choose the **Console App** template, and then choose **Next**.
6865

69-
![Choose the C++ template for the Console App](../debugger/media/vs-2019/get-started-create-console-project-cpp.png)
66+
::: moniker range=">= vs-2022"
67+
![Screenshot of choosing the C++ template for the Console App.](../debugger/media/vs-2022/get-started-create-console-project-cpp.png)
68+
::: moniker-end
69+
::: moniker range="vs-2019"
70+
![Screenshot of choosing the C++ template for the Console App.](../debugger/media/vs-2019/get-started-create-console-project-cpp.png)
71+
::: moniker-end
7072

7173
> [!NOTE]
7274
> If you do not see the **Console App** template, you can install it from the **Create a new project** window. In the **Not finding what you're looking for?** message, choose the **Install more tools and features** link. Then, in the Visual Studio Installer, choose the **Desktop development with C++** workload.
@@ -75,8 +77,6 @@ First, you'll create a C++ console application project. The project type comes w
7577

7678
Visual Studio opens your new project.
7779

78-
::: moniker-end
79-
8080
## Create the application
8181

8282
1. In *get-started-debugging.cpp*, replace all of the default code with the following code instead:
@@ -146,7 +146,7 @@ First, you'll create a C++ console application project. The project type comes w
146146
147147
2. Press **F5** or the **Start Debugging** button ![Start Debugging](../debugger/media/dbg-tour-start-debugging.png "Start Debugging"), the app starts, and the debugger runs to the line of code where you set the breakpoint.
148148
149-
![Set and hit a breakpoint](../debugger/media/get-started-set-breakpoint-cpp.png)
149+
![Screenshot of setting and hitting a breakpoint.](../debugger/media/get-started-set-breakpoint-cpp.png)
150150
151151
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).
152152
@@ -168,7 +168,7 @@ Mostly, we use the keyboard shortcuts here, because it's a good way to get fast
168168
169169
The yellow pointer advances into the `SendMessage` method.
170170
171-
![Use F11 to Step Into code](../debugger/media/get-started-f11-cpp.png "F10 Step Into")
171+
![Screenshot of using F11 to Step Into code.](../debugger/media/get-started-f11-cpp.png "F10 Step Into")
172172
173173
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)).
174174
@@ -184,7 +184,7 @@ Mostly, we use the keyboard shortcuts here, because it's a good way to get fast
184184
185185
1. While paused at the method call, press **F10** (or choose **Debug > Step Over**) once.
186186
187-
![Use F10 to Step Over code](../debugger/media/get-started-step-over-cpp.png "F10 Step Over")
187+
![Screenshot of using F10 to Step Over code.](../debugger/media/get-started-step-over-cpp.png "F10 Step Over")
188188
189189
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).
190190
@@ -194,7 +194,7 @@ Mostly, we use the keyboard shortcuts here, because it's a good way to get fast
194194
195195
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 ![Run to Click](../debugger/media/dbg-tour-run-to-click.png "RunToClick") appears on the left. The tooltip for the button shows "Run execution to here".
196196
197-
![Use the Run to Click feature](../debugger/media/get-started-run-to-click-cpp.png "Run to Click")
197+
![Screenshot of using the Run to Click feature.](../debugger/media/get-started-run-to-click-cpp.png "Run to Click")
198198
199199
> [!NOTE]
200200
> 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.)
@@ -225,7 +225,7 @@ Features that allow you to inspect variables are one of the most useful features
225225
226226
1. Press **F5** (or **Debug** > **Continue**) a few times to iterate several times through the `for` loop, pausing again at the breakpoint, and hovering over the `name` variable each time to check its value.
227227
228-
![View a data tip](../debugger/media/get-started-data-tip-cpp.png "View a Data Tip")
228+
![Screenshot of viewing a data tip.](../debugger/media/get-started-data-tip-cpp.png "View a Data Tip")
229229
230230
The value of the variable changes with each iteration of the `for` loop, showing values of `f`, then `fr`, then `fre`, and so on.
231231
@@ -243,9 +243,14 @@ Features that allow you to inspect variables are one of the most useful features
243243
244244
1. Expand the `letters` variable to show the elements that it contains.
245245
246-
![Inspect variables in the Locals Window](../debugger/media/get-started-locals-window-cpp.png "Locals Window")
246+
::: moniker range=">= vs-2022"
247+
![Screenshot of inspecting variables in the Locals Window.](../debugger/media/vs-2022/get-started-locals-window-cpp.png "Locals Window")
248+
::: moniker-end
249+
::: moniker range="vs-2019"
250+
![Screenshot of inspecting variables in the Locals Window.](../debugger/media/get-started-locals-window-cpp.png "Locals Window")
251+
::: moniker-end
247252
248-
The **Locals** window shows you the variables that are in the current [scope](https://www.wikipedia.org/wiki/Scope_(computer_science)), that is, the current execution context.
253+
The **Locals** window shows you the variables that are in the current [scope](https://www.wikipedia.org/wiki/Scope_(computer_science)), that is, the current execution context.
249254
250255
## Set a watch
251256
@@ -263,7 +268,12 @@ Features that allow you to inspect variables are one of the most useful features
263268
264269
2. Click **F11** a few times until you see the debugger pause in the `SendMessage` method. Look at the **Call Stack** window.
265270
266-
![Examine the call stack](../debugger/media/get-started-call-stack-cpp.png "ExamineCallStack")
271+
::: moniker range=">= vs-2022"
272+
![Screenshot of examining the call stack.](../debugger/media/vs-2022/get-started-call-stack-cpp.png "ExamineCallStack")
273+
::: moniker-end
274+
::: moniker range="vs-2019"
275+
![Screenshot of examining the call stack.](../debugger/media/get-started-call-stack-cpp.png "ExamineCallStack")
276+
::: moniker-end
267277
268278
The **Call Stack** window shows the order in which methods and functions are getting called. The top line shows the current function (the `SendMessage` method in this app). The second line shows that `SendMessage` was called from the `main` method, and so on.
269279
Loading
Loading
Loading

0 commit comments

Comments
 (0)