Using the Parallel Stacks Window

 

The Parallel Stacks window is useful when you are debugging multithreaded applications. Its Threads View shows call stack information for all the threads in your application. It lets you navigate between threads and stack frames on those threads. In managed code, the Tasks View shows call stacks of System.Threading.Tasks.Task objects. In native code, the Tasks View shows call stacks of task groups, parallel algorithms, asynchronous agents, and lightweight tasks.

The following illustration shows one thread that went from Main to A to B and then to some external code. Two other threads started from some external code and then went to A, but one of the threads continued to B and then to some external code, and the other thread continued to C and then to some AnonymousMethod.

Threads view in Parallel Stacks window

In the illustration, the call path of the current thread is highlighted in blue, and the active stack frame is signified by the yellow arrow. You can change the current stack frame by selecting a different method in the Parallel Stacks window. This might result in also switching the current thread, depending on whether the method you selected is part of the current thread already or of another thread. The following table describes the main features of the Parallel Stacks window as shown in the illustration.

Callout LetterElement NameDescription
ACall Stack Segment or NodeContains a series of method contexts for one or more threads. If the node has no arrow lines connected to it, then it represents the entire call path for the thread(s).
BBlue HighlightIndicates the call path of the current thread.
CArrow linesConnect nodes to make up the entire call path for the thread(s).
DTooltip on Node HeaderShows the ID and user-defined name of each thread whose call path shares this node.
EMethod ContextRepresents one or more stack frames in the same method.
FTooltip on method contextIn Threads view, it shows all the threads in a table similar to the Threads window. In Task view, it shows all the tasks in a table similar to the Parallel Tasks window.

In addition, the Parallel Stacks window shows a Bird's Eye View icon in the main pane when the graph is too large to fit into the window. You can click on the icon to see the entire graph in the window.

The following table describes the icons that provide information about the active and current stack frames:

IconDescription
Parallel Stacks Yellow ArrowIndicates that the method context contains the active stack frame of the current thread.
Parallel Stacks Threads IconIndicates that the method context contains the active stack frame of a non-current thread.
Parallel Stacks Green ArrowIndicates that the method context contains the current stack frame. That method name is bold in all nodes in which it appears.

The following illustration and table describe the controls that are available in the Parallel Stacks toolbar.

Toolbar in Parallel Stacks window

Callout LetterControlDescription
AThreads/Tasks combo boxSwitches the view between call stacks of threads and call stacks of tasks. For more information, see Tasks View and Threads View.
BShow Only FlaggedShows call stacks only for the threads that are flagged in other debug windows, such as the GPU Threads window and the Parallel Watch window.
CToggle Method ViewSwitches between Stack View and Method View. For more information, see Method View.
DAuto Scroll To Current Stack FrameAutoscrolls the diagram so that the current stack frame is in view. This feature is useful when you are changing the current stack frame from other windows or when you are hitting a new breakpoint in large diagrams.
EToggle Zoom ControlShows or hides the zoom control. You can also zoom by pressing CTRL and turning the mouse wheel, regardless of the visibility of the zoom control.

Context Menu Items

The following illustration and table describe the shortcut menu items that are available when you right-click a method context in either Threads View or Tasks View. The last six items are borrowed directly from the Call Stack window and introduce no new behavior.

Shortcut menu in Parallel Stacks window

Menu ItemDescription
FlagFlags the selected item.
UnflagUnflags the selected item.
FreezeFreezes the selected item.
ThawThaws the selected item.
Go to Task (Thread)Performs the same function as the combo box on the toolbar, but keeps the same stack frame highlighted.
Go To Source CodeNavigates to the location in source code that corresponds to the stack frame that the user right-clicked.
Switch To FrameSame as the corresponding menu command on the Call Stack window. However, with Parallel Stacks, multiple frames may correspond to one method context. Therefore, the menu item has submenus, each of which represents a specific stack frame. If one of the stack frames is on the current thread, then the menu that corresponds to that stack frame is selected.
Go To DisassemblyNavigates to the location in the disassembly window that corresponds to the stack frame that the user right-clicked.
Show External CodeShows or hides external code.
Hexadecimal DisplayToggles between decimal and hexadecimal display.
Symbol Load InformationDisplays the corresponding dialog box.
Symbol SettingsDisplays the corresponding dialog box.

If your application is using System.Threading.Tasks.Task objects (managed code) or task_handle objects (native code) to express parallelism, you can use the combo box in the Parallel Stacks window toolbar to switch to Tasks View. Tasks View shows call stacks of tasks instead of threads. Tasks View differs from Threads View as follows:

  • Call stacks of threads that are not running tasks are not shown.

  • Call stacks of threads that are running tasks are visually trimmed at the top and bottom to show the most relevant frames that pertain to tasks.

  • When multiple tasks are on one thread, the call stacks of those tasks are split out into separate nodes.

The following illustration shows the Parallel Stacks Tasks View on the right and the corresponding Threads View on the left.

Tasks view in Parallel Stacks window

To see the entire call stack, just switch back to Threads View by right-clicking a stack frame and then clicking Go to Thread.

As described in the earlier table, by hovering over a method context, you can see additional information. The following image shows the information in the tooltip for the Threads View and the Tasks View.

Tooltips in Parallel Stacks window

From either Threads View or Tasks View, you can pivot the graph on the current method by clicking the Method View icon on the toolbar. Method View shows at a glance all methods on all threads that either call or are called by the current method. The following illustration shows a Threads View, and also how the same information looks in Method View.

Method view in Parallel Stacks window

By switching to a new stack frame, you make that method the current method and cause the window to show all the callers and callees for the new method. This may cause some threads to appear or disappear from the view, depending on whether that method appears on their call stacks. To return to Stack View, click the Method View toolbar button again.

Walkthrough: Debugging a Parallel Application
Debugger Basics
Debugging Managed Code
Parallel Programming
Using the Tasks Window
Walkthrough: Debugging a Parallel Application
Task Class

Show: