Skip to content

Commit 1d44b2a

Browse files
committed
geninfo: Fix error when using --demangle-cpp
Using genhtml's --demangle-cpp option on data produced with recent GCC versions (at least 4.8 and 4.9) can result in an error message similar to the following: genhtml: ERROR: Demangled function name _ZN3subD2Ev maps to different lines (5 vs 4) The reason for this error is an unexpected sequence of lines records in a .gcno file. These records mention line numbers as belonging to a function which occur before the initial line number of that function as reported by the corresponding function record. Fix this problem by retaining the order of lines belonging to a function as found in the .gcno file. This way geninfo will consistently use the initial line number as reported by the function record when merging function data during the demangling process. Reported-by: Alexandre Duret-Lutz <[email protected]> Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent 566e5ec commit 1d44b2a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

bin/geninfo

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ sub graph_error($$);
176176
sub graph_expect($);
177177
sub graph_read(*$;$$);
178178
sub graph_skip(*$;$);
179+
sub uniq(@);
179180
sub sort_uniq(@);
180181
sub sort_uniq_lex(@);
181182
sub graph_cleanup($);
@@ -2527,6 +2528,27 @@ sub graph_skip(*$;$)
25272528
return 0;
25282529
}
25292530

2531+
#
2532+
# uniq(list)
2533+
#
2534+
# Return list without duplicate entries.
2535+
#
2536+
2537+
sub uniq(@)
2538+
{
2539+
my (@list) = @_;
2540+
my @new_list;
2541+
my %known;
2542+
2543+
foreach my $item (@list) {
2544+
next if ($known{$item});
2545+
$known{$item} = 1;
2546+
push(@new_list, $item);
2547+
}
2548+
2549+
return @new_list;
2550+
}
2551+
25302552
#
25312553
# sort_uniq(list)
25322554
#
@@ -2713,7 +2735,7 @@ sub graph_cleanup($)
27132735
next;
27142736
}
27152737
# Normalize list
2716-
$per_file->{$function} = [ sort_uniq(@$lines) ];
2738+
$per_file->{$function} = [ uniq(@$lines) ];
27172739
}
27182740
if (scalar(keys(%{$per_file})) == 0) {
27192741
# Remove empty file

0 commit comments

Comments
 (0)