This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Code coverage tool
- From: David Flynn <dav at chess dot plus dot com>
- To: bug-gcc at gnu dot org
- Date: Mon, 7 Jan 2002 17:14:22 +0000
- Subject: Code coverage tool
Are there any plans to add a code coverage tool to gcc?
Essentially it would be like profiling but at greater detail.
{} nests (including functions), each () on ifs, whiles, etc, both sides of
the : in () ? statment 1 : statement 2 expressions, each case in a switch,
etc would have a counter. Basically there is a counter for every possible
path of C code. When the code goes through there, the counter is incremented
(may have to be a 8 byte counter for certain apps). Then it should be
possible to dump the counts and for a separate tool (like gprof) to be able
to line up the counts with the source itself. That way you can determine if
all paths through your code have been executed for testing, or for statistics
if you test based upon likelyhood of code being used.
It should be also possible to combine two counter files, for multiple tests
when the program exits.
In doing so it makes it easy to prove that all code has been executed and
means there being fewer bugs where programmers have forgotten to test paths
of code (particularly in complicated if logic statements).
David