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?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,123 questions
C++
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.
3,732 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
999 questions
{count} votes

Your answer

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