Dynamically loaded dll files

May 22, 2015 at 1:29 PM
I'm running a exe file which loads a dll file dynamically. Can I do code coverage on the loaded dll file using OpenCppCoverage? If not, is there any other way I can do it?
Coordinator
May 24, 2015 at 1:55 PM
Hello,

There is no known issue of using a dll with OpenCppCoverage. I have just tested with LoadLibrary function and it also works.
You just need to run OpenCppCoverage on your executable. Let me know, if it is not the case for you.

If you want to have the code coverage only for the loaded dll see --sources and --modules flags https://opencppcoverage.codeplex.com/wikipage?title=Command-Line%20Reference.

Hope that help,

OpenCppCoverage
May 25, 2015 at 4:14 AM
I'm running an exe file which takes a dll file a argument and loads the dll file. I tried what you suggested and I cannot find the coverage file for the dll file. It is not recognising the loaded dll file for coverage. What can be the problem?
One more question, suppose a program is already running(I know the pid), can I run OpenCppCoverage on the running process(using the pid)?

Thanks
Coordinator
May 26, 2015 at 9:32 PM
Hello,

How do you load your dll? With LoadLibrary/LoadLibraryEx?

The first thing to check is that flags --modules and --sources do not skip your dll.
In the log file, you can see skip modules.

Other potential issue is that OpenCppCoverage does not find the pdb file of your dll.
If Visual Studio cannot load the pdb file, it will be the same for OpenCppCoverage.
So, you can perform the following test:
  • Debug your executable inside Visual Studio
  • Wait that your dll is loaded by your program
  • Check in Visual Studio output pane that it loads correctly the pdb file of your dll.
If the previous steps do not help, you can try to run OpenCppCoverage with flag --verbose.
It will produce extended log. Perhaps you will notice something.

If it is also failed, can you post the log file with flag --verbose and tell me the name of your dynamic dll?

For your second question, you cannot attach OpenCppCoverage to a running process.
Do you have any use case for this feature?

Hope that help

OpenCppCoverage
Marked as answer by OpenCppCoverage on 11/15/2015 at 3:36 AM