|
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,160 +32,131 @@ 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: |
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 |
51 | 52 |
|
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**+**`**. |
53 | 56 |
|
54 |
| -- [Make notes about the code](#MakeNotes) |
| 57 | + The current call stack appears in orange on a new code map: |
55 | 58 |
|
56 |
| -- [Update the map with the next call stack](#UpdateMap) |
| 59 | +  |
57 | 60 |
|
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. |
59 | 62 |
|
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. |
61 | 64 |
|
62 |
| -- [Q & A](#QA) |
| 65 | + |
63 | 66 |
|
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. |
65 | 69 |
|
66 |
| -## <a name="MapStack"></a> Map the call stack |
| 70 | +## Map external code |
67 | 71 |
|
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 | +  |
| 77 | +- Or, deselect **Enable Just My Code** in Visual Studio **Tools** (or **Debug**) > **Options** > **Debugging**: |
| 78 | + |
| 79 | +  |
69 | 80 |
|
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 |
71 | 82 |
|
72 |
| -  |
| 83 | +Changing the map's layout doesn't affect the code in any way. |
73 | 84 |
|
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. |
75 | 86 |
|
76 |
| -  |
| 87 | +In the **Layout** menu, you can: |
77 | 88 |
|
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**. |
79 | 92 |
|
80 | 93 | ## <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**. |
82 | 100 |
|
83 | 101 | 
|
84 | 102 |
|
85 | 103 | ## <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 | 104 |
|
88 |
| -  |
| 105 | +As you run your app to the next breakpoint or step into a function, the map adds new call stacks automatically. |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +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 | 110 |
|
90 | 111 | ## <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 | 112 |
|
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. |
94 | 114 |
|
95 |
| -  |
| 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**. |
96 | 116 |
|
97 |
| - Add the items that you want to track on the map. |
| 117 | + |
98 | 118 |
|
99 |
| -  |
| 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. |
100 | 120 |
|
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 | + |
103 | 122 |
|
104 |
| -  |
| 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. |
105 | 125 |
|
106 |
| - Here you can easily see which methods use the same fields. The most recently added items appear in green. |
| 126 | + |
107 | 127 |
|
108 |
| - Continue building the map to see more code. |
| 128 | +Continue building the map to see more code. |
109 | 129 |
|
110 | 130 | 
|
111 | 131 |
|
112 | 132 | 
|
113 | 133 |
|
114 | 134 | ## <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. |
116 | 136 |
|
117 | 137 | So you set breakpoints in the `clear`, `undo`, and `Repaint` methods, start debugging, and build a map like this one:
|
118 | 138 |
|
119 | 139 | 
|
120 | 140 |
|
121 | 141 | 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 | 142 |
|
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`: |
124 | 144 |
|
125 | 145 | 
|
126 | 146 |
|
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 |
| -  |
| 147 | +## Share the map with others |
174 | 148 |
|
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. |
176 | 150 |
|
177 |
| -- [Map the call stack](#MapStack) |
| 151 | +To share or save the map, use **Share** in the code map toolbar. |
178 | 152 |
|
179 |
| -- [Make notes about the code](#MakeNotes) |
| 153 | + |
180 | 154 |
|
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) |
182 | 157 |
|
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) |
184 | 159 |
|
185 |
| -- [Find bugs using the map](#FindBugs) |
| 160 | +[Find potential problems using code map analyzers](../modeling/find-potential-problems-using-code-map-analyzers.md) |
186 | 161 |
|
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) |
0 commit comments