Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Using Code Coverage with Programs that Fork Processes

Christopher_Ullman
408 Views
Hello. I'm trying to determine if the code coverage tool with the C++ Compiler on Linux (Version 9) is able to follow forks. I've got a forked process in which I want to track the code coverage, but it appears that the code coverage output only shows me the code accessed by the parent and not the child. Is there something special that you need to do to track a child process? I've compiled the files I want to track with the -proj-genx option, put that option in the main link, and gathered the pgopti.dpi file. I get output for all the files I want, but it appears to only track where the parent goes.

Thanks!
0 Kudos
3 Replies
Om_S_Intel
Employee
408 Views

Code coverage should work here. It will help us investigate if you could provide a sample code.
0 Kudos
Christopher_Ullman
408 Views
The code I have is quite large, so samples are a little difficult to pull together.

What I've got is a program running an environment with a mix of FORTRAN, C and C++ code. Ithen fork to emulate functions run on a separate processor. The call to these functionsthat are run on thefork, a semaphorecheck is performedwith a passed argument of what torun on the forked process. It is thecode run on this forked process that I am interested in.

Would themix of programming languages cause any issues? Would the way we run the fork cause issues? I'm considering trying to pull out the fork and run everything out of the parent to see if that might do the trick.

One other thing...when building the code I use makefiles. I build the code that will be run in the fork in a separate directory through a makefile called from another makefile. I think the PROF_DIR directory I am setting is not getting forwarded along, as the pgopti.dpi file I create is not showing up in the PROF_DIR but in the local directory where the compilation happened. When I compile the main and link using the -proj-genx option (including the object code made in the separate directory), I get the pgopti.dpi file in the PROF_DIR, but it only has references to my main. I manually merge the two pgopti.dpi files before I run. Could that bepart of the problem?

Sorry for the lack of any code. I'm pretty sure what the problem here is going to be something that we are doing when we build the application, so I'm using your answers to help me eliminate possiblities.

Thanks!
0 Kudos
Christopher_Ullman
408 Views
One other thing of note. When I look at the output of the code coverage, it will list the functions thatI'm expecting tobe run in a given file as "uncovered". Does that mean that the run never entered that function or that the code coverage was not tracking that function? I'm guessing that it just means that code coverage never saw that routine entered.
0 Kudos
Reply