Skip to content

Commit a5dd952

Browse files
committed
geninfo: Add gcc 8 support
Fix errors and incorrect data when trying to collect coverage data for programs compiled with gcc 8. Covers the following gcov-related changes in gcc: .gcov-file format: - Line coverage data can appear multiple times for the same line - Line coverage count can be suffixed by '*' to indicated unexecuted basic blocks in that line .gcno-file format: - new header field 'support unexecuted blocks flag' - new function record fields 'column number', 'ending line number', and 'compiler-generated entity flag' Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent c30d88a commit a5dd952

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

bin/geninfo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
6868
our $gcov_tool = "gcov";
6969
our $tool_name = basename($0);
7070

71+
our $GCOV_VERSION_8_0_0 = 0x80000;
7172
our $GCOV_VERSION_4_7_0 = 0x40700;
7273
our $GCOV_VERSION_3_4_0 = 0x30400;
7374
our $GCOV_VERSION_3_3_0 = 0x30300;
@@ -1934,6 +1935,9 @@ sub read_gcov_file($)
19341935
{
19351936
my ($count, $line, $code) = ($1, $2, $3);
19361937

1938+
# Skip instance-specific counts
1939+
next if ($line == $last_line);
1940+
19371941
$last_line = $line;
19381942
$last_block = $UNNAMED_BLOCK;
19391943
# Check for exclusion markers
@@ -1963,6 +1967,9 @@ sub read_gcov_file($)
19631967
}
19641968
}
19651969

1970+
# Strip unexecuted basic block marker
1971+
$count =~ s/\*$//;
1972+
19661973
# <exec count>:<line number>:<source code>
19671974
if ($line eq "0")
19681975
{
@@ -3537,13 +3544,22 @@ sub read_gcno_function_record(*$$$$$)
35373544
graph_expect("function name");
35383545
$function = read_gcno_string($handle, $big_endian);
35393546
return undef if (!defined($function));
3547+
if ($version >= $GCOV_VERSION_8_0_0) {
3548+
graph_skip($handle, 4, "compiler-generated entity flag")
3549+
or return undef;
3550+
}
35403551
# Read filename
35413552
graph_expect("filename");
35423553
$filename = read_gcno_string($handle, $big_endian);
35433554
return undef if (!defined($filename));
35443555
# Read first line number
35453556
$lineno = read_gcno_value($handle, $big_endian, "initial line number");
35463557
return undef if (!defined($lineno));
3558+
# Skip column and ending line number
3559+
if ($version >= $GCOV_VERSION_8_0_0) {
3560+
graph_skip($handle, 4, "column number") or return undef;
3561+
graph_skip($handle, 4, "ending line number") or return undef;
3562+
}
35473563
# Add to list
35483564
push(@{$bb->{$function}->{$filename}}, $lineno);
35493565
graph_add_order($fileorder, $function, $filename);
@@ -3631,6 +3647,10 @@ sub read_gcno($)
36313647
debug(sprintf("found version 0x%08x\n", $version));
36323648
# Skip stamp
36333649
graph_skip(*HANDLE, 4, "file timestamp") or goto incomplete;
3650+
if ($version >= $GCOV_VERSION_8_0_0) {
3651+
graph_skip(*HANDLE, 4, "support unexecuted blocks flag")
3652+
or goto incomplete;
3653+
}
36343654
while (!eof(HANDLE)) {
36353655
my $next_pos;
36363656
my $curr_pos;

0 commit comments

Comments
 (0)