Find the answer to your Linux question:
Results 1 to 2 of 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    1

    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 have 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

    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.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,533
    See the --opject-directory option for gcov. You can tell it where your object and source files are with that. There is also the --preserve-paths argument so it will use the complete path information when creating the profiles. From the gcov man page:
    Code:
           --preserve-paths
               Preserve complete path information in the names of generated .gcov files.  Without this
               option, just the filename component is used.  With this option, all directories are used,
               with / characters translated to # characters, . directory components removed and ..
               components renamed to ^.  This is useful if sourcefiles are in several different
               directories.  It also affects the -l option.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •