Skip to content

Commit 78d8e13

Browse files
committed
code map article
1 parent b5ffd79 commit 78d8e13

File tree

2 files changed

+59
-95
lines changed

2 files changed

+59
-95
lines changed

docs/debugger/map-methods-on-the-call-stack-while-debugging-in-visual-studio.md

Lines changed: 59 additions & 95 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,159 +32,123 @@ 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:
51+
## <a name="MapStack"></a> Map the call stack
4952

50-
- [Video: Debug visually with Code Map debugger integration (Channel 9)](http://go.microsoft.com/fwlink/?LinkId=293418)
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**+**`**.
5156

52-
- [Map the call stack](#MapStack)
57+
The current call stack appears in orange on a new code map:
5358

54-
- [Make notes about the code](#MakeNotes)
59+
![See call stack on code map](../debugger/media/debuggermap_seeundocallstack.png "DebuggerMap_SeeUndoCallStack")
5560

56-
- [Update the map with the next call stack](#UpdateMap)
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.
5762

58-
- [Add related code to the map](#AddRelatedCode)
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.
5964

60-
- [Find bugs using the map](#FindBugs)
65+
![Code Map Legend](../debugger/media/debuggermap_showlegend.png "Code Map Legend")
6166

62-
- [Q & A](#QA)
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.
6369
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).
70+
## Map external code
6571

66-
## <a name="MapStack"></a> Map the call stack
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")
6780

68-
1. Start debugging. (Keyboard: **F5**)
81+
## Control the map's layout
6982

70-
2. After your app enters break mode or you step into a function, choose **Code Map**. (Keyboard: **Ctrl** + **Shift** + **`**)
83+
Changing the map's layout doesn't affect the code in any way.
7184

72-
![Choose Code Map to start mapping call stack](../debugger/media/debuggermap_choosecodemap.png "DebuggerMap_ChooseCodeMap")
85+
To control the map's layout, select the **Layout** menu on the map toolbar. In the **Layout** menu, you can:
7386

74-
The current call stack appears in orange on a new code map:
87+
- Change the default layout.
88+
- Stop rearranging the map automatically, by deselecting **Automatically Layout when Debugging**.
89+
- Rearrange the map as little as possible when you add items, by deselecting **Incremental Layout**.
7590

76-
![See call stack on code map](../debugger/media/debuggermap_seeundocallstack.png "DebuggerMap_SeeUndoCallStack")
91+
## <a name="MakeNotes"></a> Make notes about the code
7792

78-
The map will update automatically while you continue debugging. See [Update the map with the next call stack](#UpdateMap).
93+
You can add comments to track what's happening in the code.
7994

80-
## <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**.
95+
To add a comment, right-click in the code map and select **Edit** > **New Comment**, then type the comment. To add a new line in a comment, press **Shift**+**Enter**.
8296

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

8599
## <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.
87100

88-
![Update code map with next call stack](../debugger/media/debuggermap_addclearcallstack.png "DebuggerMap_AddClearCallStack")
101+
As you run your app to the next breakpoint or step into a function, the map adds new call stacks automatically.
102+
103+
![Update code map with next call stack](../debugger/media/debuggermap_addclearcallstack.png "DebuggerMap_AddClearCallStack")
104+
105+
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**+**`**.
89106

90107
## <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.
92108

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**)
109+
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.
94110

95-
![Go to code definition for a method on code map](../debugger/media/debuggermap_gotocodedefinition.png "DebuggerMap_GoToCodeDefinition")
111+
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**.
96112

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

99-
![Show fields in a method on call stack code map](../debugger/media/debuggermap_showfields.png "DebuggerMap_ShowFields")
115+
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.
100116

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.
117+
![Show fields in a method on call stack code map](../debugger/media/debuggermap_showfields.png "DebuggerMap_ShowFields")
103118

104-
![Fields related to a method on call stack code map](../debugger/media/debuggermap_showedfields.png "DebuggerMap_ShowedFields")
119+
>[!NOTE]
120+
>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.
105121
106-
Here you can easily see which methods use the same fields. The most recently added items appear in green.
122+
![Fields related to a method on call stack code map](../debugger/media/debuggermap_showedfields.png "DebuggerMap_ShowedFields")
107123

108-
Continue building the map to see more code.
124+
Continue building the map to see more code.
109125

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

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

114130
## <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.
131+
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.
116132

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

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

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

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

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

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")
174-
175-
See:
176-
177-
- [Map the call stack](#MapStack)
178-
179-
- [Make notes about the code](#MakeNotes)
143+
## Share the map with others
180144

181-
- [Update the map with the next call stack](#UpdateMap)
145+
You can export the map, send it to others with Microsoft Outlook, save it to your solution, and check it into version control.
182146

183-
- [Add related code to the map](#AddRelatedCode)
147+
To share or save the map, use **Share** in the code map toolbar.
184148

185-
- [Find bugs using the map](#FindBugs)
149+
![Share call stack code map with others](../debugger/media/debuggermap_sharewithothers.png "Share call stack code map with others")
186150

187-
## See Also
151+
## See also
188152
[Map dependencies across your solutions](../modeling/map-dependencies-across-your-solutions.md)
189153
[Use code maps to debug your applications](../modeling/use-code-maps-to-debug-your-applications.md)
190154
[Find potential problems using code map analyzers](../modeling/find-potential-problems-using-code-map-analyzers.md)
-7.39 KB
Loading

0 commit comments

Comments
 (0)