Skip to content

Commit 29814f1

Browse files
committed
geninfo: Fix missing FN: entries in result files
geninfo sometimes fails to correctly collect function starting lines for some source files, resulting in output files with missing FN: lines. Also such functions are missing from the function list in HTML output. The problem occurs when a) multiple source files contribute to a function implementation (e.g. via including code), and b) the source file that contains the initial function definition is not the source file that contains the most function definitions The problem occurs due to a heuristic in function graph_find_base() that incorrectly determines the source file for a function in this situation. Fix this by using the first file that contributes to a function as the base source file for that function. Only apply this change to data collected using GCC versions 4 and above since earlier versions did not produce stable file orders in graph files. Signed-off-by: Peter Oberparleiter <[email protected]> Reported-by: Joshua Cranmer
1 parent 74bae96 commit 29814f1

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

bin/geninfo

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ sub sort_uniq(@);
184184
sub sort_uniq_lex(@);
185185
sub graph_cleanup($);
186186
sub graph_find_base($);
187-
sub graph_from_bb($$$);
187+
sub graph_from_bb($$$$);
188188
sub graph_add_order($$$);
189189
sub read_bb_word(*;$);
190190
sub read_bb_value(*;$);
@@ -2958,9 +2958,13 @@ sub graph_find_base($)
29582958
}
29592959

29602960
#
2961-
# graph_from_bb(bb, fileorder, bb_filename)
2961+
# graph_from_bb(bb, fileorder, bb_filename, fileorder_first)
29622962
#
29632963
# Convert data from bb to the graph format and list of instrumented lines.
2964+
#
2965+
# If FILEORDER_FIRST is set, use fileorder data to determine a functions
2966+
# base source file.
2967+
#
29642968
# Returns (instr, graph).
29652969
#
29662970
# bb : function name -> file data
@@ -2978,9 +2982,9 @@ sub graph_find_base($)
29782982
# line data : [ line1, line2, ... ]
29792983
#
29802984

2981-
sub graph_from_bb($$$)
2985+
sub graph_from_bb($$$$)
29822986
{
2983-
my ($bb, $fileorder, $bb_filename) = @_;
2987+
my ($bb, $fileorder, $bb_filename, $fileorder_first) = @_;
29842988
my $graph = {};
29852989
my $instr = {};
29862990
my $basefile;
@@ -2997,7 +3001,8 @@ sub graph_from_bb($$$)
29973001
$order = $fileorder->{$func};
29983002

29993003
# Account for lines in functions
3000-
if (defined($basefile) && defined($filedata->{$basefile})) {
3004+
if (defined($basefile) && defined($filedata->{$basefile}) &&
3005+
!$fileorder_first) {
30013006
# If the basefile contributes to this function,
30023007
# account this function to the basefile.
30033008
$graph->{$basefile}->{$func} = $filedata->{$basefile};
@@ -3159,7 +3164,8 @@ sub read_bb($)
31593164
}
31603165
}
31613166
close(HANDLE);
3162-
($instr, $graph) = graph_from_bb($bb, $fileorder, $bb_filename);
3167+
3168+
($instr, $graph) = graph_from_bb($bb, $fileorder, $bb_filename, 0);
31633169
graph_cleanup($graph);
31643170

31653171
return ($instr, $graph);
@@ -3347,7 +3353,8 @@ sub read_bbg($)
33473353
}
33483354
}
33493355
close(HANDLE);
3350-
($instr, $graph) = graph_from_bb($bb, $fileorder, $bbg_filename);
3356+
($instr, $graph) = graph_from_bb($bb, $fileorder, $bbg_filename, 0);
3357+
33513358
graph_cleanup($graph);
33523359

33533360
return ($instr, $graph);
@@ -3731,7 +3738,7 @@ sub read_gcno($)
37313738
remove_fn_from_hash($bb, \@artificial_fns);
37323739
remove_fn_from_hash($fileorder, \@artificial_fns);
37333740

3734-
($instr, $graph) = graph_from_bb($bb, $fileorder, $gcno_filename);
3741+
($instr, $graph) = graph_from_bb($bb, $fileorder, $gcno_filename, 1);
37353742
graph_cleanup($graph);
37363743

37373744
return ($instr, $graph);

0 commit comments

Comments
 (0)