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 Visual Studio Other
{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.