Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to merge two gcov files into one

I am using gcov for coverage test in macosx platform. I finish the configuration for xcode by set:

1. Build Settings ==> Generate Test Coverage Files == Yes
2. Build Settings ==> Instrument Progaram Flow == Yes
3. Build Phases ==> Link Binary with library ==> add "libprofile_rt.dylib"

Then generate the files "Test.d, Test.dia, Test.gcno, Test.gcda, Test.o" Then i use gcov-4.2 -b Test.gcno command to generate the Test.m.gcov file (this is what i want), but next time when i run test cases again, the files "Test.d, Test.dia, Test.gcno, Test.gcda, Test.o" will be generated again, and the data will be reset.

So I have two questions:

  1. Is there any way for me to make the data in these coverage files accumulated so that i can run so many times of my project and then generate files at the end.
  2. If the #1 is hopeless, could you tell me how to merge two Test.gcno files (generated by two times' running) into one. I try gcov in terminal, below are the options for gcov command:

    gcov-4.2 -help
    Usage: gcov [OPTION]... SOURCEFILE
    
    Print code coverage information.
    
      -h, --help                      Print this help, then exit
      -v, --version                   Print version number, then exit
      -a, --all-blocks                Show information for every basic block
      -b, --branch-probabilities      Include branch probabilities in output
      -c, --branch-counts             Given counts of branches taken
                                        rather than percentages
      -n, --no-output                 Do not create an output file
      -l, --long-file-names           Use long output file names for included
                                        source files
      -f, --function-summaries        Output summaries for each function
      -o, --object-directory DIR|FILE Search for object files in DIR or called FILE
      -p, --preserve-paths            Preserve all pathname components
      -u, --unconditional-branches    Show unconditional branch counts too
    
    For bug reporting instructions, please see:
    <URL:http://developer.apple.com/bugreporter>.
    

Thanks for all your help in advance

like image 567
jimwan Avatar asked Mar 25 '13 09:03

jimwan


People also ask

What can I do with gcov files?

gcov creates a logfile called sourcefile. gcov which indicates how many times each line of a source file sourcefile. c has executed. You can use these logfiles along with gprof to aid in fine-tuning the performance of your programs.

Does gcov come GCC?

Gcov comes as a standard utility with the GNU Compiler Collection (GCC) suite. The gcov utility gives information on how often a program executes segments of code. It produces a copy of the source file, annotated with execution frequencies.

What is gcov tool?

gcov-tool is an offline tool to process gcc's gcda profile files. Current gcov-tool supports the following functionalities: merge two sets of profiles with weights. read a stream of profiles with associated filenames and merge it with a set of profiles with weights.


1 Answers

The usual workflow for gcov is

  1. Compile and link with coverage support (-fprofile-arcs -ftest-coverage)
  2. Run your executables, possibly multiple times, possibly with different parameters / settings. This will create accumulative usage information in the .gcda files
  3. Invoke gcov to get coverage statistics in a human-readable format (.gcov)

So basically, successive runs of the application will result in accumulated coverage statistics. It's just that these accumulations will take place in the .gcda files, not the .gcov files, so you have to re-run gcov each time you want to see updated statistics.

like image 85
hberndt Avatar answered Oct 19 '22 01:10

hberndt