LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Using gcov (http://www.linuxquestions.org/questions/programming-9/using-gcov-832062/)

niranjanvg 09-14-2010 07:16 AM

Using gcov
 
Hi,

I am using gcov to get code coverage for my program written in C++, I am able to do it without any problem when i don't have a directory structure, for my program I am a directory structure as below

Code:


./src/ -- containing all my source files

./obj/ -- containing all my object files

./header/ -- containing all my header files

../../lib/  -- containing a static library, which will be used by
                my program

there is a makefile in the current directory which creates my executable

Quote:

do i need to compile the static library also with the options of gcov i.e. -fprofile-arcs -ftest-coverage, because it is the library that i need to check for coverage.

Kindly help on how use gcov in this situation.

14moose 09-15-2010 01:07 AM

Hi -

Yes, if you want to profile an object file, then you need to compile that object with " -fprofile-arcs -ftest-coverage", regardless of whether you link directly to that object, or put it in a static library and then link to the library.

You should keep your .da files. And you should probably run "gcov" with -p and -l.

'Hope that helps


All times are GMT -5. The time now is 09:31 AM.