How do you log function call counts in C++ with vsinstr.exe

yoyodyne01 61 Reputation points
2024-09-15T16:43:47.32+00:00

I'd like to get a call tree with counts for a C++ dll. This says only supported for .NET:
https://learn.microsoft.com/en-us/visualstudio/profiling/cpu-usage?view=vs-2022 but

Starting in Visual Studio 2022 version 17.6, the Instrumentation tool also supports C/C++, but uses static instrumentation (VSInstr):
https://learn.microsoft.com/en-us/visualstudio/profiling/instrumentation-overview?view=vs-2022#static-instrumentation-tool

Anyway,

  1. Link with /PROFILE
  2. "vsinstr myCppDll.dll" - the output indicates it completed successfully
  3. VSDiagnostics.exe start 1 /attach:xxxxx /loadConfig:AgentConfigs\CpuUsageWithCallCounts.json
  4. (run the scenario)
  5. VSDignostics.exe stop 1 /output:counts

Opening counts.diagsession chugs for a while then says "failed to analyze data". Doing the same but with "AgentConfigs\CpuUsageHigh.json" works fine. I'm running VS2022 with all current updates. The current version of vsinstr is unable to inject the code for this?

Developer technologies | Visual Studio | Debugging
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.