0

I have been experimenting with understand how code coverage works for a project compiled using VC++ on Windows. The steps are:

  • build with /LINK PROFILE
  • vsinstr /coverage foobar.exe
  • vsperfcmd /start:coverage /output:run.coverage
  • foobar.exe
  • vsperfcmd /shutdown

This leaves me with a file run.coverage in a proprietary binary format. How can I convert this into cobertura format (or something equally useful)?


Things I have tried:

I could not get this to work. I managed to download the package but when I run it as suggested it just returns and does nothing.

C:\Users\SomeUser\AppData\Local\FineCodeCoverage\msCodeCoverage\17.1.0\build\netstandard1.0\CodeCoverage\amd64\CodeCoverage.exe" analyze /output:coverage.xml run.coverage

It may be assuming some familiarity with .NET, NUGET etc that I don't have.

Some old questions (linked below) pointed me at https://github.com/jsargiot/visual-coverage which is no longer maintained and I was unable to compile.

The following questions are somewhat out of date:


My main background is Linux where I just use -fcoverage -fprofile-arcs with gcc and govr This is partly about understanding the windows ecosystem. Related questions I have:

  • What is the binary coverage format (It starts with the magic number MIKE\0P)?

  • Is this really the best way to get coverage information on Windows? I get the feeling vsinstr + vsperfcmd is deprecated.

  • I tried using https://github.com/OpenCppCoverage/OpenCppCoverage It seems to work and generate line coverage information. It does not require the executable to be instrumented via vsinstr. It does not support branch coverage (I don't know of vsperfcmd does either) I will likely default to using this until I discover something better.

  • Is there an equivalent compile option to "-fprofile-arcs -fcoverage" Is there something beyond /LINK PROFILE that would render vsinstr redundant

  • Is this a waste of time compared to using clang-cl as the platform toolkit? I could then use llvm-cov, see https://marco-c.github.io/2018/01/09/code-coverage-with-clang-on-windows.html

Bruce Adams
  • 4,953
  • 4
  • 48
  • 111

0 Answers0