Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch process in Visual Studio Diagnostic Tools Window?

Tags:

In Visual Studio 2017 I would like to use the Diagnostic Tools window to analyze my unit tests (x64), written in C#. However it always displays the message

Multiple processes have been debugged. This window only shows data for testhost.exe (PID: xxxxx).

VS Diagnostic Tools Window Screenshot

testhost.exe doesn't help me much, I would need QTAgent.exe. I can see in the Processes window that the debugger is attached to both processes, QTAgent.exe and testhost.exe. But I can't find a way how to switch to QTAgent.exe in the Diagnostic Tools window. How can you do that?

Detaching from testhost.exe does not help.

like image 377
Tobias Avatar asked Feb 15 '18 15:02

Tobias


2 Answers

Only one process is active in the debugger at any given time. You can set the active or current process in the Debug Location toolbar or in the Processes window. To switch between processes, both processes must be in break mode.

On the Debug Location toolbar, choose Process to view the Process list box. Select the process that you want to designate as current process. enter image description here

If the Debug Location toolbar is not visible, choose Tools, Customize. On the Toolbars tab, choose Debug Location.

Open the Processes window (shortcut Ctrl+Alt+Z), find the process that you want to set as the current process, and double-click it.

enter image description here

The current process is marked by a yellow arrow.

Switching to a project sets it the current process for debugging purposes. Any debugger window that you view will show the state for the current process, and all stepping commands affect only the current process.

like image 82
Anita George Avatar answered Nov 27 '22 05:11

Anita George


Not a 100% solution, but usable if you are only interested in CPU usage profiling:

  1. Disable Diagnostic Tools while debugging (Options -> Debugging or simply search for "diagn")
  2. Set a breakpoint in the first line of code of your unit test.
  3. Open "Performance Profiler" (ALT+F2) and attach to "QTAgent32.exe"
  4. Continue debugging (F5)
  5. Inspect where CPU time is going:

enter image description here

like image 42
Jack Miller Avatar answered Nov 27 '22 06:11

Jack Miller