|
1 | 1 | ---
|
2 | 2 | title: "Create a visual map of the call stack | Microsoft Docs"
|
3 | 3 | ms.custom: ""
|
4 |
| -ms.date: "05/18/2017" |
| 4 | +ms.date: "11/26/2018" |
5 | 5 | ms.technology: "vs-ide-debug"
|
6 | 6 | ms.topic: "conceptual"
|
7 | 7 | f1_keywords:
|
@@ -32,159 +32,123 @@ manager: douge
|
32 | 32 | ms.workload:
|
33 | 33 | - "multiple"
|
34 | 34 | ---
|
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 |
37 | 36 |
|
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. |
39 | 38 |
|
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) |
41 | 41 |
|
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). |
43 | 46 |
|
44 | 47 | Here's a quick look at a code map:
|
45 | 48 |
|
46 | 49 | 
|
47 | 50 |
|
48 |
| - See: |
| 51 | +## <a name="MapStack"></a> Map the call stack |
49 | 52 |
|
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**+**`**. |
51 | 56 |
|
52 |
| -- [Map the call stack](#MapStack) |
| 57 | + The current call stack appears in orange on a new code map: |
53 | 58 |
|
54 |
| -- [Make notes about the code](#MakeNotes) |
| 59 | +  |
55 | 60 |
|
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. |
57 | 62 |
|
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. |
59 | 64 |
|
60 |
| -- [Find bugs using the map](#FindBugs) |
| 65 | + |
61 | 66 |
|
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. |
63 | 69 |
|
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 |
65 | 71 |
|
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 | +  |
| 77 | +- Or, deselect **Enable Just My Code** in Visual Studio **Tools** (or **Debug**) > **Options** > **Debugging**: |
| 78 | + |
| 79 | +  |
67 | 80 |
|
68 |
| -1. Start debugging. (Keyboard: **F5**) |
| 81 | +## Control the map's layout |
69 | 82 |
|
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. |
71 | 84 |
|
72 |
| -  |
| 85 | +To control the map's layout, select the **Layout** menu on the map toolbar. In the **Layout** menu, you can: |
73 | 86 |
|
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**. |
75 | 90 |
|
76 |
| -  |
| 91 | +## <a name="MakeNotes"></a> Make notes about the code |
77 | 92 |
|
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. |
79 | 94 |
|
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**. |
82 | 96 |
|
83 | 97 | 
|
84 | 98 |
|
85 | 99 | ## <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. |
87 | 100 |
|
88 |
| -  |
| 101 | +As you run your app to the next breakpoint or step into a function, the map adds new call stacks automatically. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +To stop the map from adding new call stacks automatically, select  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**+**`**. |
89 | 106 |
|
90 | 107 | ## <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. |
92 | 108 |
|
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. |
94 | 110 |
|
95 |
| -  |
| 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**. |
96 | 112 |
|
97 |
| - Add the items that you want to track on the map. |
| 113 | + |
98 | 114 |
|
99 |
| -  |
| 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. |
100 | 116 |
|
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 | + |
103 | 118 |
|
104 |
| -  |
| 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. |
105 | 121 |
|
106 |
| - Here you can easily see which methods use the same fields. The most recently added items appear in green. |
| 122 | + |
107 | 123 |
|
108 |
| - Continue building the map to see more code. |
| 124 | +Continue building the map to see more code. |
109 | 125 |
|
110 | 126 | 
|
111 | 127 |
|
112 | 128 | 
|
113 | 129 |
|
114 | 130 | ## <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. |
116 | 132 |
|
117 | 133 | So you set breakpoints in the `clear`, `undo`, and `Repaint` methods, start debugging, and build a map like this one:
|
118 | 134 |
|
119 | 135 | 
|
120 | 136 |
|
121 | 137 | You notice that all the user gestures on the map call `Repaint`, except for `undo`. This might explain why `undo` doesn't work immediately.
|
122 | 138 |
|
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`: |
124 | 140 |
|
125 | 141 | 
|
126 | 142 |
|
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 |
| -  |
134 |
| - |
135 |
| - or turn off **Enable Just My Code** in the Visual Studio debugging options: |
136 |
| - |
137 |
| -  |
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 |
| -  |
162 |
| - |
163 |
| -- **How do I stop the map from adding new call stacks automatically?** |
164 |
| - |
165 |
| - Choose  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 |
| -  |
174 |
| - |
175 |
| - See: |
176 |
| - |
177 |
| -- [Map the call stack](#MapStack) |
178 |
| - |
179 |
| -- [Make notes about the code](#MakeNotes) |
| 143 | +## Share the map with others |
180 | 144 |
|
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. |
182 | 146 |
|
183 |
| -- [Add related code to the map](#AddRelatedCode) |
| 147 | +To share or save the map, use **Share** in the code map toolbar. |
184 | 148 |
|
185 |
| -- [Find bugs using the map](#FindBugs) |
| 149 | + |
186 | 150 |
|
187 |
| -## See Also |
| 151 | +## See also |
188 | 152 | [Map dependencies across your solutions](../modeling/map-dependencies-across-your-solutions.md)
|
189 | 153 | [Use code maps to debug your applications](../modeling/use-code-maps-to-debug-your-applications.md)
|
190 | 154 | [Find potential problems using code map analyzers](../modeling/find-potential-problems-using-code-map-analyzers.md)
|
|
0 commit comments