Visual Studio 2015 -- CPU Usage Profiling Not Working? - c++

I recently upgraded from Visual Studio 2013 Community to Visual Studio 2015 Community.
I've heavily relied on the "CPU Usage" Tool that can be found by doing the following:
Click "Debug"
Click "Start Diagnostic Tools without Debugging"
Click "CPU Usage" Check box
Click "Start" button
When the program is complete, it is supposed to show you the functions and the time spent in each. What I get instead is just the name of my executable that I can keep expanding instead of seeing the function names -- It doesn't know the names of the functions.
This worked fine on Visual Studio 2013... I would be able to see the function names and everything worked. I tried creating a new "test" solution/project to see whether this works and I get the same results: No function names.
Does this work for anybody? I also installed VS2015 on a fresh development box and still have no results. This seems like Microsoft shipped with a Visual Studio bug.
Note: I'm writing a C++ console application. I've tried this on debug and release builds and ensured that I'm building with debug information.

It's in the Visual Studio 2015 Update 1 release notes, so I suspect it was broken in the initial release:
Profile your CPU Usage while debugging
Now, you can get a detailed per-function profile of your CPU Usage while you are debugging. You can turn CPU Profiling on and off while debugging and view the results when you are in a break state, which allows you to view a per-function breakdown of CPU Usage of code that executed between breakpoints and during steps. (To use this functionality, open the Diagnostic Tools window (Debug -> Diagnostic Tools), switch to the CPU tab, and then click the "CPU Profiling" button.)

I have also noticed this, but if you use that little search box (top right corner of the results area) and try typing in either the name of the function you're looking for or part of the name and it will expand everything (there's usually a lot to expand) and highlight the function you're looking for. Its the only way I've been able to profile specific functions.

Related

Visual Studio 2022 Profiler not properly expanding stack traces

I am migrating a Visual Studio C++ project from VS 2017 to 2022. Everything went fine, until I tried to use the Performance Profiler. It hit a frustrating issue where it's collapsing pretty obvious call graphs into single report lines, despite all attempts to fix. This worked fine with 2017.
For example there is this call:
This is a thin wrapper around another call that does the "real work", and you can see this in the profiling results:
But that inner Read() call does not show up in the profile, nor any of the stuff it calls.
I have "Enable Just My Code" turned off. This code is actually "my code", it's linked through a DLL. Debug information is turned on in the DLL build (/Zi) and link.
How can I get VS 2022 to expand stack traces properly? Again this all works flawlessly in VS 2017.

How do I debug an application crash (unhandled win32 exception) in vscode?

I have a running application that crashes with "An unhandled win32 exception occurred in ..." dialog. This only contains full-fledged Visual Studio in the available debuggers list even though Visual Studio Code is installed.
I would rather use vscode as it is my main dev environment.
How can I add it to the "Choose Just-In-Time Debugger" window's "Available Debuggers" list?
Update:
I found where the setting exists in the registry, with an example of how to set WinDbg as the debugger instead of Visual Studio.
https://www.codeproject.com/articles/6084/windows-debuggers-part-1-a-windbg-tutorial#_Toc64133667
and
https://learn.microsoft.com/en-us/windows/win32/debug/configuring-automatic-debugging
Remaining step is to determine how VS Code's debugger likes to be invoked.
(I'm still open to cleaner ways to do this, however.)
Update 2:
Nearest I can tell, this last step is the big deal breaker.
According to this feature request:
https://github.com/Microsoft/vscode/issues/10979
It doesn't look like the team at Microsoft is interested in making that an option. :_(

Is it possible to edit code while running in Visual Studio 2017, even with 'Edit and Continue' enabled?

Frequently I want to change code when the project is running, but am disallowed from doing this because Edit and Continue is enabled.
I assume this is some kind of protective measure, because the changes I make won't apply to the current execution, but I am fine with that. I would like to make them, and then click 'apply' somewhere to make the build update. Is this possible? (It used to be in previous versions of Visual Studio)
Opening a second instance of Visual Studio, and opening the code file there will allow this to be done.

Visual Studio 2013: native C++ single-step debugging (F10) slow

I am using Visual Studio Premium 2013 Update 2 on a freshly installed (fast) machine with Windows 8.1 Update. Everything is running smoothly, only one thing bugs me:
Problem
When I debug a native C++ project (debug build) by going from line to line with F10 ("step over") it takes 1-2 seconds to go to the next line when I press the F10 key.
What I tried
I looked at several other questions related to slow debugging and made sure that neither of the following is not the reason in my case:
Everything is local (app and all data), no network shares involved
Disabling the Microsoft symbol server did not help
I only have a single breakpoint
Using the menu/toolbar instead of the keyboard does not make any difference
In the default configuration "edit and continue" is enabled, but apparently not for native code:
When I disabled "edit and continue" completely, F10 stepping became much faster (0.5-1 s). The speed is tolerable now. I had to restart Visual Studio after I changed the configuration to this:

How to profile unit tests in Visual Studio 2012?

Is it possible to profile MSTest unit tests in Visual Studio 2012 Ultimate without using any external profiling tools?
This feature was added back in the upcoming Visual Studio 2012 Quarterly Update 1. Right-click the test you want to profile in the Test Explorer and select "Profile Test" from the context menu.
In Visual Studio it was a really powerful feature !
As you, I can not find it in VS2012 (no references in MSDN or in blogs, ...)
Now, the only solution I have found for profiling Unit Test is to Attach the Profiler to a Process called vstest.executionengine.x86.exe (x86 for me but this could be different for 64 bits)
You can do this in the Tab "Performance Explorer" after a right click.
Once the profiler is starting, you can run as many tests as you want. Then stop profiling and you will see all details of this session.
There are 2 caveats with this technique :
for some reasons, the process is missing in the list. Maybe it stops when idle. Start just one test te see it.
You have to Attach the Profiler for every sessions. I don't find yet a way to script it.
Hope this will help you.
In Visual Studio 2015, follow the instructions Cybermaxs gives, but select TE.ProcessHost.Managed. Unfortunately, there appear to be two of them, so you must select the one with higher CPU usage.
With VS 2019/2022 you attach to the testhost process while running your tests. Just run your tests in debug, and stop execution on breakpoint, then you can find that process to attach.