Skip to content

Commit d95049d

Browse files
authored
Merge pull request #3371 from v-thepet/code-map
Refresh code map article
2 parents 34babbd + d4a2f92 commit d95049d

File tree

2 files changed

+67
-96
lines changed

2 files changed

+67
-96
lines changed
Lines changed: 67 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Create a visual map of the call stack | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "05/18/2017"
4+
ms.date: "11/26/2018"
55
ms.technology: "vs-ide-debug"
66
ms.topic: "conceptual"
77
f1_keywords:
@@ -32,160 +32,131 @@ manager: douge
3232
ms.workload:
3333
- "multiple"
3434
---
35-
# Create a visual map of the call stack while debugging in Visual Studio Enterprise
36-
Create a code map to visually trace the call stack while you're debugging. You can make notes on the map to track what the code is doing so you can focus on finding bugs.
35+
# Create a visual map of the call stack while debugging
3736

38-
You'll need:
37+
Create a code map to visually trace the call stack while you're debugging. You can make notes on the map to track what the code is doing, so you can focus on finding bugs.
3938

40-
- [Visual Studio Enterprise](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=button+cta&utm_content=download+vs2017)
39+
For a walkthrough, watch this video:
40+
[Video: Debug visually with Code Map debugger integration (Channel 9)](http://go.microsoft.com/fwlink/?LinkId=293418)
4141

42-
- Code that you can debug, such as Visual C#, Visual Basic, C++, JavaScript, or X++
42+
For details of commands and actions you can use with code maps, see [Browse and rearrange code maps](../modeling/browse-and-rearrange-code-maps.md).
43+
44+
>[!IMPORTANT]
45+
>You can create code maps only in [Visual Studio Enterprise edition](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=button+cta&utm_content=download+vs2017).
4346
4447
Here's a quick look at a code map:
4548

4649
![Debugging with call stacks on code maps](../debugger/media/debuggermap_overview.png "DebuggerMap_Overview")
4750

48-
See:
49-
50-
- [Video: Debug visually with Code Map debugger integration (Channel 9)](http://go.microsoft.com/fwlink/?LinkId=293418)
51+
## <a name="MapStack"></a> Map the call stack
5152

52-
- [Map the call stack](#MapStack)
53+
1. In a Visual Studio Enterprise C#, Visual Basic, C++, JavaScript, or X++ project, start debugging by selecting **Debug** > **Start Debugging** or pressing **F5**.
54+
55+
1. After your app enters break mode or you step into a function, select **Debug** > **Code Map**, or press **Ctrl**+**Shift**+**`**.
5356

54-
- [Make notes about the code](#MakeNotes)
57+
The current call stack appears in orange on a new code map:
5558

56-
- [Update the map with the next call stack](#UpdateMap)
59+
![See call stack on code map](../debugger/media/debuggermap_seeundocallstack.png "DebuggerMap_SeeUndoCallStack")
5760

58-
- [Add related code to the map](#AddRelatedCode)
61+
The code map updates automatically as you continue debugging. Changing map items or layout doesn't affect the code in any way. Feel free to rename, move, or remove anything on the map.
5962

60-
- [Find bugs using the map](#FindBugs)
63+
To get more information about an item, hover over it and look at the item's tooltip. You can also select **Legend** in the toolbar to learn what each icon means.
6164

62-
- [Q & A](#QA)
65+
![Code Map Legend](../debugger/media/debuggermap_showlegend.png "Code Map Legend")
6366

64-
For details of the commands and actions you can use when working with code maps, see [Browse and rearrange code maps](../modeling/browse-and-rearrange-code-maps.md).
67+
>[!NOTE]
68+
>The message **The diagram may be based on an older version of the code** at the top of the code map means that the code might have changed after you last updated the map. For example, a call on the map might not exist in code anymore. Close the message, then try rebuilding the solution before updating the map again.
6569
66-
## <a name="MapStack"></a> Map the call stack
70+
## Map external code
6771

68-
1. Start debugging. (Keyboard: **F5**)
72+
By default, only your own code appears on the map. To see external code on the map:
73+
74+
- Right-click in the **Call Stack** window and select **Show External Code**:
75+
76+
![Display external code using the Call Stack window](../debugger/media/debuggermap_callstackmenu.png "DebuggerMap_CallStackMenu")
77+
- Or, deselect **Enable Just My Code** in Visual Studio **Tools** (or **Debug**) > **Options** > **Debugging**:
78+
79+
![Show external code using Options dialog](../debugger/media/debuggermap_debugoptions.png "DebuggerMap_DebugOptions")
6980

70-
2. After your app enters break mode or you step into a function, choose **Code Map**. (Keyboard: **Ctrl** + **Shift** + **`**)
81+
## Control the map's layout
7182

72-
![Choose Code Map to start mapping call stack](../debugger/media/debuggermap_choosecodemap.png "DebuggerMap_ChooseCodeMap")
83+
Changing the map's layout doesn't affect the code in any way.
7384

74-
The current call stack appears in orange on a new code map:
85+
To control the map's layout, select the **Layout** menu on the map toolbar.
7586

76-
![See call stack on code map](../debugger/media/debuggermap_seeundocallstack.png "DebuggerMap_SeeUndoCallStack")
87+
In the **Layout** menu, you can:
7788

78-
The map will update automatically while you continue debugging. See [Update the map with the next call stack](#UpdateMap).
89+
- Change the default layout.
90+
- Stop rearranging the map automatically, by deselecting **Automatically Layout when Debugging**.
91+
- Rearrange the map as little as possible when you add items, by deselecting **Incremental Layout**.
7992

8093
## <a name="MakeNotes"></a> Make notes about the code
81-
Add comments to track what's happening in the code. To add a new line in a comment, press **Shift + Return**.
94+
95+
You can add comments to track what's happening in the code.
96+
97+
To add a comment, right-click in the code map and select **Edit** > **New Comment**, then type the comment.
98+
99+
To add a new line in a comment, press **Shift**+**Enter**.
82100

83101
![Add comment to call stack on code map](../debugger/media/debuggermap_addcomment.png "DebuggerMap_AddComment")
84102

85103
## <a name="UpdateMap"></a> Update the map with the next call stack
86-
Run your app to the next breakpoint or step into a function. The map adds a new call stack.
87104

88-
![Update code map with next call stack](../debugger/media/debuggermap_addclearcallstack.png "DebuggerMap_AddClearCallStack")
105+
As you run your app to the next breakpoint or step into a function, the map adds new call stacks automatically.
106+
107+
![Update code map with next call stack](../debugger/media/debuggermap_addclearcallstack.png "DebuggerMap_AddClearCallStack")
108+
109+
To stop the map from adding new call stacks automatically, select ![Show call stack on code map automatically](../debugger/media/debuggermap_automaticupdateicon.gif "Show call stack on code map automatically") on the code map toolbar. The map continues to highlight existing call stacks. To manually add the current call stack to the map, press **Ctrl**+**Shift**+**`**.
89110

90111
## <a name="AddRelatedCode"></a> Add related code to the map
91-
Now you've got a map - what next? If you're working with Visual C# or Visual Basic, add items, such as fields, properties, and other methods, to track what's happening in the code.
92112

93-
Double-click a method to see its code definition, or use the shortcut menu for the method. (Keyboard: Select the method on the map and press **F12**)
113+
Now that you've got a map, in C# or Visual Basic, you can add items like fields, properties, and other methods, to track what's happening in the code.
94114

95-
![Go to code definition for a method on code map](../debugger/media/debuggermap_gotocodedefinition.png "DebuggerMap_GoToCodeDefinition")
115+
To go to the definition of a method in the code, double-click the method in the map, or select it and press **F12**, or right-click it and select **Go To Definition**.
96116

97-
Add the items that you want to track on the map.
117+
![Go to code definition for a method on code map](../debugger/media/debuggermap_gotocodedefinition.png "DebuggerMap_GoToCodeDefinition")
98118

99-
![Show fields in a method on call stack code map](../debugger/media/debuggermap_showfields.png "DebuggerMap_ShowFields")
119+
To add items that you want to track to the map, right-click a method and select the items you want to track. The most recently added items appear in green.
100120

101-
> [!NOTE]
102-
> By default, adding items to the map also adds the parent group nodes such as the class, namespace, and assembly. While this is useful, you can keep the map simple by turning off this feature using the **Include Parents** button on the map toolbar, or by pressing **CTRL** when you add items.
121+
![Fields related to a method on call stack code map](../debugger/media/debuggermap_showedfields.png "DebuggerMap_ShowedFields")
103122

104-
![Fields related to a method on call stack code map](../debugger/media/debuggermap_showedfields.png "DebuggerMap_ShowedFields")
123+
>[!NOTE]
124+
>By default, adding items to the map also adds the parent group nodes such as the class, namespace, and assembly. You can turn this feature off and on by selecting the **Include Parents** button on the code map toolbar, or by pressing **Ctrl** while you add items.
105125
106-
Here you can easily see which methods use the same fields. The most recently added items appear in green.
126+
![Show fields in a method on call stack code map](../debugger/media/debuggermap_showfields.png "DebuggerMap_ShowFields")
107127

108-
Continue building the map to see more code.
128+
Continue building the map to see more code.
109129

110130
![See methods that use a field: call stack code map](../debugger/media/debuggermap_findallreferences.png "DebuggerMap_FindAllReferences")
111131

112132
![Methods that use a field on call stack code map](../debugger/media/debuggermap_foundallreferences.png "DebuggerMap_FoundAllReferences")
113133

114134
## <a name="FindBugs"></a> Find bugs using the map
115-
Visualizing your code can help you find bugs faster. For example, suppose you're investigating a bug in a drawing program. When you draw a line and try to undo it, nothing happens until you draw another line.
135+
Visualizing your code can help you find bugs faster. For example, suppose you're investigating a bug in a drawing app. When you draw a line and try to undo it, nothing happens until you draw another line.
116136

117137
So you set breakpoints in the `clear`, `undo`, and `Repaint` methods, start debugging, and build a map like this one:
118138

119139
![Add another call stack to code map](../debugger/media/debuggermap_addpaintobjectcallstack.png "DebuggerMap_AddPaintObjectCallStack")
120140

121141
You notice that all the user gestures on the map call `Repaint`, except for `undo`. This might explain why `undo` doesn't work immediately.
122142

123-
After you fix the bug and continue running the program, the map adds the new call from `undo` to `Repaint`:
143+
After you fix the bug and continue running the app, the map adds the new call from `undo` to `Repaint`:
124144

125145
![Add new method call to call stack on code map](../debugger/media/debuggermap_addnewcallforrepaint.png "DebuggerMap_AddNewCallForRepaint")
126146

127-
## <a name="QA"></a> Q & A
128-
129-
- **Not all calls appear on the map. Why?**
130-
131-
By default, only your own code appears on the map. To see external code, turn it on in the **Call Stack** window:
132-
133-
![Display external code using the Call Stack window](../debugger/media/debuggermap_callstackmenu.png "DebuggerMap_CallStackMenu")
134-
135-
or turn off **Enable Just My Code** in the Visual Studio debugging options:
136-
137-
![Show external code using Options dialog](../debugger/media/debuggermap_debugoptions.png "DebuggerMap_DebugOptions")
138-
139-
- **Does changing the map affect the code?**
140-
141-
Changing the map doesn't affect the code in any way. Feel free to rename, move, or remove anything on the map.
142-
143-
- **What does this message mean: "The diagram may be based on an older version of the code"?**
144-
145-
The code might have changed after you last updated the map. For example, a call on the map might not exist in code anymore. Close the message, then try rebuilding the solution before updating the map again.
146-
147-
- **How do I control the map's layout?**
148-
149-
Open the **Layout** menu on the map toolbar:
150-
151-
- Change the default layout.
152-
153-
- To stop rearranging the map automatically, turn off **Automatically Layout when Debugging**.
154-
155-
- To rearrange the map as little as possible when you add items, turn off **Incremental Layout**.
156-
157-
- **Can I share the map with others?**
158-
159-
You can export the map, send it to others if you have Microsoft Outlook, or save it to your solution so you can check it into Team Foundation version control.
160-
161-
![Share call stack code map with others](../debugger/media/debuggermap_sharewithothers.png "DebuggerMap_ShareWithOthers")
162-
163-
- **How do I stop the map from adding new call stacks automatically?**
164-
165-
Choose ![Button &#45; Show call stack on code map automatically](../debugger/media/debuggermap_automaticupdateicon.gif "DebuggerMap_AutomaticUpdateIcon") on the map toolbar. To manually add the current call stack to the map, press **Ctrl** + **Shift** + **`**.
166-
167-
The map will continue highlighting existing call stacks on the map while you're debugging.
168-
169-
- **What do the item icons and arrows mean?**
170-
171-
To get more info about an item, move the mouse pointer over it and look at the item's tooltip. You can also look at the **Legend** to learn what each icon means.
172-
173-
![What do icons on the call stack code map mean?](../debugger/media/debuggermap_showlegend.png "DebuggerMap_ShowLegend")
147+
## Share the map with others
174148

175-
See:
149+
You can export a map, send it to others with Microsoft Outlook, save it to your solution, and check it into version control.
176150

177-
- [Map the call stack](#MapStack)
151+
To share or save the map, use **Share** in the code map toolbar.
178152

179-
- [Make notes about the code](#MakeNotes)
153+
![Share call stack code map with others](../debugger/media/debuggermap_sharewithothers.png "Share call stack code map with others")
180154

181-
- [Update the map with the next call stack](#UpdateMap)
155+
## See also
156+
[Map dependencies across your solutions](../modeling/map-dependencies-across-your-solutions.md)
182157

183-
- [Add related code to the map](#AddRelatedCode)
158+
[Use code maps to debug your applications](../modeling/use-code-maps-to-debug-your-applications.md)
184159

185-
- [Find bugs using the map](#FindBugs)
160+
[Find potential problems using code map analyzers](../modeling/find-potential-problems-using-code-map-analyzers.md)
186161

187-
## See Also
188-
[Map dependencies across your solutions](../modeling/map-dependencies-across-your-solutions.md)
189-
[Use code maps to debug your applications](../modeling/use-code-maps-to-debug-your-applications.md)
190-
[Find potential problems using code map analyzers](../modeling/find-potential-problems-using-code-map-analyzers.md)
191-
[Browse and rearrange code maps](../modeling/browse-and-rearrange-code-maps.md)
162+
[Browse and rearrange code maps](../modeling/browse-and-rearrange-code-maps.md)
-7.39 KB
Loading

0 commit comments

Comments
 (0)