Test coverage user interface for C and C++
ggcov − a GNOME frontend for exploring gcov coverage data
ggcov [GNOME options] [[−r] directory|file] ...
Ggcov is a GTK+ GUI for exploring test coverage data produced by C and C++ programs compiled with gcc −fprofile-arcs −ftest-coverage. So it’s basically a GUI replacement for the gcov program that comes with gcc.
Ggcov
understands all the standard GTK+ and GNOME options, such as
−display. Most other options are used to
specify how to find and handle coverage data files. The
arguments can combinations of:
directory
The directory is scanned for source files, which are handled as if they had been specified on the commandline (except that missing coverage data files are silently ignored). If the −r flag is in effect, sub−directories are scanned recursively. Multiple directories can be specified and are scanned in the order given.
executable
The executable file is scanned for debugging records which contain source file names, and each source file which exists is handled as if it had been specified on the command line (except that missing coverage data files are silently ignored). Any shared libraries on which the executable depends are also scanned. Multiple executables can be specified and are scanned in the order given. This feature is only available on some platforms (for example, i386-linux).
source-file
Is any regular file ending in one of the file extensions .c, .cc, .cxx, .cpp, or .C. Source files are matched to their corresponding coverage data files (.gcno and .gcda files) and object files by searching for a file of the same basename and the appropriate extension first in the same directory as the source file and then in all the directories specified on the command line (in the order they were specified).
If no arguments are given, ggcov shows a file selection dialog so you can select one directory, executable, or source file.
Directories, executables, or source files can also be added after ggcov is started by dragging and dropping them from a GNOME Nautilus window onto any ggcov window.
−o dir, −−object−directory=dir
Add the directory dir to the search path for object files and coverage data files.
-p dir, −−gcda−prefix=dir
Look for runtime coverage data files (.gcda files) underneath the directory dir instead of next to the corresponding .c files. See the example in the ggcov-run(1) manpage.
−r, −−recursive
When a directory is specified on the command line, search for coverage data files recursively in all child directories.
−w windows, −−initial−windows=windows
Open the named windows when ggcov starts. One or more window names may be given, separated by commas or whitespace. Defined window names are summary, files, functions, calls, callbutterfly, callgraph, lego, source, and reports. The default window is summary.
−X symbols, −−suppress−ifdef=symbols
Suppress code inside C pre-processor directives which depend on any of the given symbols. Suppressed code is not included in statistics or summaries. One or more symbols may be given, separated by commas or whitespace. Ggcov understands the following subset of the C pre-processor command set:
• #if
SYMBOL
• #if defined(SYMBOL)
• #ifdef SYMBOL
• #ifndef SYMBOL
• #else
• #endif
For example, -X DEBUG will suppress the fprintf() call in this code:
unsigned int
my_function(unsigned int x)
{
x += 42;
#ifdef DEBUG
fprintf(stderr, "my_function: x=%u\n", x);
#endif
return x;
}
This option is useful for suppressing test infrastructure code, debugging code, or other code which is compiled into the coverage test executable but whose coverage is not significant.
−Y words, −−suppress−comment=words
Suppress code on lines which also contain a single-line comment comprising only one of the given words. Suppressed code is not included in statistics or summaries. One or more symbols may be given, separated by commas or whitespace. For example, specifying -Y IGNOREME will suppress the assert() in this code:
unsigned int
my_function(unsigned int x)
{
x += 42;
assert(x >= 42); /* IGNOREME */
return x;
}
This option is useful for suppressing test infrastructure code, debugging code, or other code which is compiled into the coverage test executable but whose coverage is not significant.
−Z
startword,endword,...
−−suppress−comment-between=startword,endword,...
Suppress code on lines between those containing a single-line comment comprising only startword and the next single-line comment comprising only endword. Suppressed code is not included in statistics or summaries. Two or more symbols may be given, in pairs, separated by commas or whitespace. For example, -Z STARTIGNORE,ENDIGNORE will suppress the entire function in this code:
/* STARTIGNORE
*/
unsigned int
my_function(unsigned int x)
{
x += 42;
return x;
}
// ENDIGNORE
This option is useful for suppressing test infrastructure code, debugging code, or other code which is compiled into the coverage test executable but whose coverage is not significant.
View coverage data for all the available source in an executable (on some platforms only):
ggcov a.out
View coverage data for all the C source in the current directory, suppressing code which depends on the symbols DEBUG or TEST:
ggcov -X DEBUG,TEST *.c
View coverage data for all the C source in one directory where the object files and test coverage data files are in different directories:
ggcov /foo/obj/ /foo/cov−data/ /foo/src/
Written by Greg Banks <gnb@fastmail.fm>.
ggcov is
Copyright © 2001−2020 Greg Banks
<gnb@fastmail.fm>.
This is free software; see the COPYING file for copying
conditions. There is NO warranty; not even for
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ggcov-run(1).