Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

Last modified 13 years ago

#72 closed enhancement (fixed)

"gcov" Recipe Command for C/C++ Coverage Metrics Gathering

Reported by: Chandler Carruth <chandlerc@…> Owned by: cmlenz
Priority: minor Milestone: 0.6
Component: Recipe commands Version: dev
Keywords: gcov coverage metric recipe command Cc:
Operating System:

Description

Provide a RecipeCommand for C/C++ coverage measuring. The "gcov" command, part of the GCC project, provides the following coverage metrics:

  • Line coverage.
  • Branch coverage.
  • Call coverage.

At least the line coverage should be provided using the existing framework in Bitten. Other metrics would also be useful.

Attachments (5)

gcov-command.ctools.py.patch (4.1 KB) - added by Chandler Carruth <chandlerc@…> 19 years ago.
Initial patch to add a gcov command.
gcov-command.ctools.py.2.patch (4.9 KB) - added by Chandler Carruth <chandlerc@…> 19 years ago.
New patch w/ tabs replaced…
gcov-command.ctools.py.3.patch (4.8 KB) - added by Chandler Carruth <chandlerc@…> 19 years ago.
New patch... bugs fixed... one still left…
gcov-command.ctools.py.4.patch (5.1 KB) - added by Chandler Carruth <chandlerc@…> 19 years ago.
Working version of patch. Tested it on my system, got correct statistics back.
gcov.patch (10.1 KB) - added by cmlenz 19 years ago.
Cleaned up patch with unit tests

Download all attachments as: .zip

Change History (11)

comment:1 Changed 19 years ago by Chandler Carruth <chandlerc@…>

Output from a run of "gcov" looks something like the below:

chandlerc@vulcan ~/code/string $ gcov -b -c -n -o src/test_stringUnitTests-rangeBase.o src/rangeBase.cpp
File `/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/include/g++-v3/bits/locale_facets.tcc'
Lines executed:0.00% of 11
Branches executed:0.00% of 10
Taken at least once:0.00% of 10
Calls executed:0.00% of 5

File `src/rangeBase.cpp'
Lines executed:45.81% of 884
Branches executed:54.27% of 398
Taken at least once:36.68% of 398
Calls executed:48.19% of 249

File `./include/strand.hpp'
Lines executed:50.00% of 4
No branches
Calls executed:100.00% of 1

File `./include/srange.hpp'
Lines executed:100.00% of 3
No branches
Calls executed:100.00% of 1

File `./include/sdata.hpp'
Lines executed:100.00% of 2
No branches
No calls

File `/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/include/g++-v3/bits/stl_algobase.h'
Lines executed:0.00% of 4
Branches executed:0.00% of 2
Taken at least once:0.00% of 2
No calls

File `/usr/lib/gcc/i686-pc-linux-gnu/3.4.4/include/g++-v3/iostream'
Lines executed:100.00% of 1
Branches executed:100.00% of 4
Taken at least once:50.00% of 4
Calls executed:100.00% of 3

I would recommend counting all blocks not belonging to a system file. The pattern of simply looking for absolute paths should work to eliminate these.

Changed 19 years ago by Chandler Carruth <chandlerc@…>

Initial patch to add a gcov command.

Changed 19 years ago by Chandler Carruth <chandlerc@…>

New patch w/ tabs replaced...

Changed 19 years ago by Chandler Carruth <chandlerc@…>

New patch... bugs fixed... one still left...

Changed 19 years ago by Chandler Carruth <chandlerc@…>

Working version of patch. Tested it on my system, got correct statistics back.

comment:2 Changed 19 years ago by cmlenz

  • Milestone set to 0.6

That last patch looks pretty nice. Thanks!

comment:3 Changed 19 years ago by cmlenz

  • Status changed from new to assigned

So gcov doesn't provide information about exactly which lines were executed, or does it?

Also, I think I'm going to remove the branch parsing from the patch before applying it. Currently it's just unused code.

comment:4 Changed 19 years ago by Chandler Carruth <chandlerc@…>

It can. you can have it generate a file describing the execution of each line, as well as the branches and calls for each line. =] I am not currently generating these files, but it would not be terribly difficult to restructure the calls to gcov in order to generate the files.

My question is: what does it gain you? and at what cost? I'm not sure i want to parse the 10s of 1000s of lines of code in my fairly small projects... Let me know however if this is a priority. I'll whip something together to generate and parse the files.

Changed 19 years ago by cmlenz

Cleaned up patch with unit tests

comment:5 Changed 19 years ago by cmlenz

I've just attached a cleaned up version of your patch (it removes the branch coverage stuff, which isn't being reported yet anyway). This also has a few unit tests. Can you please test the patch and let me know if it works for you?

On the topic of recording the exact lines covered in each file… the idea is that in the future, Bitten would provide an annotator for the Trac browser that would display the coverage in the file view. Obviously that feature isn't there yet, so the question was more out of curiosity, rather than implying that it would be needed for the <c:gcov> command now.

comment:6 Changed 19 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from assigned to closed

Patch applied in [314].

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.