Skip to content

Commit 9aa0d14

Browse files
committed
geninfo: Ignore artificial functions during --initial
Graph files generated by gcc 8 may contain "artifical" functions that do not exist in a source file. geninfo incorrectly generates coverage data for these functions when run with option --initial. Fix this by filtering out artifical functions when generating initial coverage data. Signed-off-by: Peter Oberparleiter <[email protected]> Reported-by: Marcin Konarski <[email protected]>
1 parent 1e0df57 commit 9aa0d14

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

bin/geninfo

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ sub read_bbg($);
197197
sub read_gcno_word(*;$$);
198198
sub read_gcno_value(*$;$$);
199199
sub read_gcno_string(*$);
200-
sub read_gcno_lines_record(*$$$$$$);
200+
sub read_gcno_lines_record(*$$$$$$$);
201201
sub determine_gcno_split_crc($$$$);
202202
sub read_gcno_function_record(*$$$$$);
203203
sub read_gcno($);
@@ -3421,16 +3421,16 @@ sub read_gcno_string(*$)
34213421

34223422
#
34233423
# read_gcno_lines_record(handle, gcno_filename, bb, fileorder, filename,
3424-
# function, big_endian)
3424+
# function, big_endian, artificial)
34253425
#
34263426
# Read a gcno format lines record from handle and add the relevant data to
34273427
# bb and fileorder. Return filename on success, undef on error.
34283428
#
34293429

3430-
sub read_gcno_lines_record(*$$$$$$)
3430+
sub read_gcno_lines_record(*$$$$$$$)
34313431
{
34323432
my ($handle, $gcno_filename, $bb, $fileorder, $filename, $function,
3433-
$big_endian) = @_;
3433+
$big_endian, $artificial) = @_;
34343434
my $string;
34353435
my $lineno;
34363436

@@ -3462,9 +3462,12 @@ sub read_gcno_lines_record(*$$$$$$)
34623462
"$gcno_filename\n");
34633463
next;
34643464
}
3465-
# Add to list
3466-
push(@{$bb->{$function}->{$filename}}, $lineno);
3467-
graph_add_order($fileorder, $function, $filename);
3465+
3466+
if (!$artificial) {
3467+
# Add to list
3468+
push(@{$bb->{$function}->{$filename}}, $lineno);
3469+
graph_add_order($fileorder, $function, $filename);
3470+
}
34683471
}
34693472
}
34703473

@@ -3517,7 +3520,7 @@ sub determine_gcno_split_crc($$$$)
35173520
# read_gcno_function_record(handle, graph, big_endian, rec_length, version)
35183521
#
35193522
# Read a gcno format function record from handle and add the relevant data
3520-
# to graph. Return (filename, function) on success, undef on error.
3523+
# to graph. Return (filename, function, artificial) on success, undef on error.
35213524
#
35223525

35233526
sub read_gcno_function_record(*$$$$$)
@@ -3527,6 +3530,7 @@ sub read_gcno_function_record(*$$$$$)
35273530
my $function;
35283531
my $lineno;
35293532
my $lines;
3533+
my $artificial;
35303534

35313535
graph_expect("function record");
35323536
# Skip ident and checksum
@@ -3545,8 +3549,9 @@ sub read_gcno_function_record(*$$$$$)
35453549
$function = read_gcno_string($handle, $big_endian);
35463550
return undef if (!defined($function));
35473551
if ($version >= $GCOV_VERSION_8_0_0) {
3548-
graph_skip($handle, 4, "compiler-generated entity flag")
3549-
or return undef;
3552+
$artificial = read_gcno_value($handle, $big_endian,
3553+
"compiler-generated entity flag");
3554+
return undef if (!defined($artificial));
35503555
}
35513556
# Read filename
35523557
graph_expect("filename");
@@ -3560,11 +3565,13 @@ sub read_gcno_function_record(*$$$$$)
35603565
graph_skip($handle, 4, "column number") or return undef;
35613566
graph_skip($handle, 4, "ending line number") or return undef;
35623567
}
3563-
# Add to list
3564-
push(@{$bb->{$function}->{$filename}}, $lineno);
3565-
graph_add_order($fileorder, $function, $filename);
3568+
if (!$artificial) {
3569+
# Add to list
3570+
push(@{$bb->{$function}->{$filename}}, $lineno);
3571+
graph_add_order($fileorder, $function, $filename);
3572+
}
35663573

3567-
return ($filename, $function);
3574+
return ($filename, $function, $artificial);
35683575
}
35693576

35703577
#
@@ -3625,6 +3632,7 @@ sub read_gcno($)
36253632
my $graph;
36263633
my $filelength;
36273634
my $version;
3635+
my $artificial;
36283636
local *HANDLE;
36293637

36303638
open(HANDLE, "<", $gcno_filename) or goto open_error;
@@ -3678,7 +3686,8 @@ sub read_gcno($)
36783686
}
36793687
# Process record
36803688
if ($tag == $tag_function) {
3681-
($filename, $function) = read_gcno_function_record(
3689+
($filename, $function, $artificial) =
3690+
read_gcno_function_record(
36823691
*HANDLE, $bb, $fileorder, $big_endian,
36833692
$length, $version);
36843693
goto incomplete if (!defined($function));
@@ -3687,7 +3696,7 @@ sub read_gcno($)
36873696
$filename = read_gcno_lines_record(*HANDLE,
36883697
$gcno_filename, $bb, $fileorder,
36893698
$filename, $function,
3690-
$big_endian);
3699+
$big_endian, $artificial);
36913700
goto incomplete if (!defined($filename));
36923701
} else {
36933702
# Skip record contents

0 commit comments

Comments
 (0)