Commit fc8a650e by Sharad Singhai Committed by Sharad Singhai

gcov.c (print_usage): Handle new option.

2013-06-19    <singhai@google.com>

	* gcov.c (print_usage): Handle new option.
	(process_args): Ditto.
	(get_gcov_intermediate_filename): New function.
	(output_intermediate_file): New function.
	(output_gcov_file): New function
	(generate_results): Handle new option.
	(release_function): Relase demangled name.
	(read_graph_file): Handle demangled name.
	(output_lines): Ditto.
	* doc/gcov.texi: Document gcov intermediate format.

testsuite/ChangeLog:

	* g++.dg/gcov/gcov-8.C: New testcase.
	* lib/gcov.exp: Handle intermediate format.

From-SVN: r200232
parent 39c31476
2013-06-19 <singhai@google.com>
* gcov.c (print_usage): Handle new option.
(process_args): Ditto.
(get_gcov_intermediate_filename): New function.
(output_intermediate_file): New function.
(output_gcov_file): New function
(generate_results): Handle new option.
(release_function): Relase demangled name.
(read_graph_file): Handle demangled name.
(output_lines): Ditto.
* doc/gcov.texi: Document gcov intermediate format.
2013-06-19 Vladimir Makarov <vmakarov@redhat.com>
PR bootstrap/57604
......
......@@ -122,15 +122,17 @@ gcov [@option{-v}|@option{--version}] [@option{-h}|@option{--help}]
[@option{-a}|@option{--all-blocks}]
[@option{-b}|@option{--branch-probabilities}]
[@option{-c}|@option{--branch-counts}]
[@option{-u}|@option{--unconditional-branches}]
[@option{-n}|@option{--no-output}]
[@option{-d}|@option{--display-progress}]
[@option{-f}|@option{--function-summaries}]
[@option{-i}|@option{--intermediate-format}]
[@option{-l}|@option{--long-file-names}]
[@option{-m}|@option{--demangled-names}]
[@option{-n}|@option{--no-output}]
[@option{-o}|@option{--object-directory} @var{directory|file}]
[@option{-p}|@option{--preserve-paths}]
[@option{-r}|@option{--relative-only}]
[@option{-f}|@option{--function-summaries}]
[@option{-o}|@option{--object-directory} @var{directory|file}]
[@option{-s}|@option{--source-prefix} @var{directory}]
[@option{-d}|@option{--display-progress}]
[@option{-u}|@option{--unconditional-branches}]
@var{files}
@c man end
@c man begin SEEALSO
......@@ -232,6 +234,50 @@ Unconditional branches are normally not interesting.
@itemx --display-progress
Display the progress on the standard output.
@item -i
@itemx --intermediate-format
Output gcov file in an easy-to-parse intermediate text format that can
be used by @command{lcov} or other tools. The output is a single
@file{.gcov} file per @file{.gcda} file. No source code is required.
The format of the intermediate @file{.gcov} file is plain text with
one entry per line
@smallexample
file:@var{source_file_name}
function:@var{line_number},@var{execution_count},@var{function_name}
lcount:@var{line number},@var{execution_count}
branch:@var{line_number},@var{branch_coverage_type}
Where the @var{branch_coverage_type} is
notexec (Branch not executed)
taken (Branch executed and taken)
nottaken (Branch executed, but not taken)
There can be multiple @var{file} entries in an intermediate gcov
file. All entries following a @var{file} pertain to that source file
until the next @var{file} entry.
@end smallexample
Here is a sample when @option{-i} is used in conjuction with @option{-b} option:
@smallexample
file:array.cc
function:11,1,_Z3sumRKSt6vectorIPiSaIS0_EE
function:22,1,main
lcount:11,1
lcount:12,1
lcount:14,1
branch:14,taken
lcount:26,1
branch:28,nottaken
@end smallexample
@item -m
@itemx --demangled-names
Display demangled function names in output. The default is to show
mangled function names.
@end table
@command{gcov} should be run with the current directory the same as that
......
2013-06-19 <singhai@google.com>
* g++.dg/gcov/gcov-8.C: New testcase.
* lib/gcov.exp: Handle intermediate format.
2013-06-19 Wei Mi <wmi@google.com>
PR rtl-optimization/57518
......
/* Verify that intermediate coverage format can be generated for simple code. */
/* { dg-options "-fprofile-arcs -ftest-coverage" } */
/* { dg-do run { target native } } */
class C {
public:
C()
{
i = 0;
}
~C() {}
void seti (int j)
{
if (j > 0)
i = j;
else
i = 0;
}
private:
int i;
};
void foo()
{
C c;
c.seti (1);
}
int main()
{
foo();
}
/* { dg-final { run-gcov intermediate { -i -b gcov-8.C } } } */
......@@ -70,6 +70,61 @@ proc verify-lines { testname testcase file } {
return $failed
}
#
# verify-intermediate -- check that intermediate file has certain lines
#
# TESTNAME is the name of the test, including unique flags.
# TESTCASE is the name of the test.
# FILE is the name of the gcov output file.
#
# Checks are very loose, they are based on certain tags being present
# in the output. They do not check for exact expected execution
# counts. For that the regular gcov format should be checked.
#
proc verify-intermediate { testname testcase file } {
set failed 0
set srcfile 0
set function 0
set lcount 0
set branch 0
set fd [open $file r]
while { [gets $fd line] >= 0 } {
if [regexp "^file:" $line] {
incr srcfile
}
if [regexp "^function:(\[0-9\]+),(\[0-9\]+),.*" $line] {
incr function
}
if [regexp "^lcount:(\[0-9\]+),(\[0-9\]+)" $line] {
incr lcount
}
if [regexp "^branch:(\[0-9\]+),(taken|nottaken|notexec)" $line] {
incr branch
}
}
# We should see at least one tag of each type
if {$srcfile == 0} {
fail "$testname expected 'file:' tag not found"
incr failed
}
if {$function == 0} {
fail "$testname expected 'function:' tag not found"
incr failed
}
if {$lcount == 0} {
fail "$testname expected 'lcount:' tag not found"
incr failed
}
if {$branch == 0} {
fail "$testname expected 'branch:' tag not found"
incr failed
}
return $failed
}
#
# verify-branches -- check that branch percentages are as expected
#
......@@ -248,6 +303,8 @@ proc run-gcov { args } {
set gcov_args ""
set gcov_verify_calls 0
set gcov_verify_branches 0
set gcov_verify_lines 1
set gcov_verify_intermediate 0
set xfailed 0
foreach a $args {
......@@ -255,6 +312,11 @@ proc run-gcov { args } {
set gcov_verify_calls 1
} elseif { $a == "branches" } {
set gcov_verify_branches 1
} elseif { $a == "intermediate" } {
set gcov_verify_intermediate 1
set gcov_verify_calls 0
set gcov_verify_branches 0
set gcov_verify_lines 0
} elseif { $gcov_args == "" } {
set gcov_args $a
} else {
......@@ -295,7 +357,12 @@ proc run-gcov { args } {
remote_upload host $testcase.gcov $testcase.gcov
# Check that line execution counts are as expected.
set lfailed [verify-lines $testname $testcase $testcase.gcov]
if { $gcov_verify_lines } {
# Check that line execution counts are as expected.
set lfailed [verify-lines $testname $testcase $testcase.gcov]
} else {
set lfailed 0
}
# If requested via the .x file, check that branch and call information
# is correct.
......@@ -309,15 +376,21 @@ proc run-gcov { args } {
} else {
set cfailed 0
}
if { $gcov_verify_intermediate } {
# Check that intermediate format has the expected format
set ifailed [verify-intermediate $testname $testcase $testcase.gcov]
} else {
set ifailed 0
}
# Report whether the gcov test passed or failed. If there were
# multiple failures then the message is a summary.
set tfailed [expr $lfailed + $bfailed + $cfailed]
set tfailed [expr $lfailed + $bfailed + $cfailed + $ifailed]
if { $xfailed } {
setup_xfail "*-*-*"
}
if { $tfailed > 0 } {
fail "$testname gcov: $lfailed failures in line counts, $bfailed in branch percentages, $cfailed in return percentages"
fail "$testname gcov: $lfailed failures in line counts, $bfailed in branch percentages, $cfailed in return percentages, $ifailed in intermediate format"
} else {
pass "$testname gcov"
clean-gcov $testcase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment