Improve ExtractSymbols (pprof).

Iterated downward through both libraries and PCs.  This allows PCs
to resolve even when library address ranges overlap.
This commit is contained in:
Jason Evans 2010-04-07 19:52:15 -07:00
parent 7cb5b5ea21
commit af366593a4

View File

@ -3682,16 +3682,9 @@ sub ExtractSymbols {
# Map each PC value to the containing library
my @pcs = (sort { $a cmp $b } keys(%{$pcset}));
my @slibs = (sort {$a->[1] cmp $b->[1]} @{$libs});
my $bin = shift(@slibs);
if ($bin->[1] == 0) {
# Move binary to end (starts at address 0).
push(@slibs, $bin);
} else {
unshift(@slibs, $bin);
}
my $pc = shift(@pcs);
foreach my $lib (@slibs) {
my $pc = pop(@pcs);
foreach my $lib (reverse sort {$a->[1] cmp $b->[1]} @{$libs}) {
my $libname = $lib->[0];
my $start = $lib->[1];
my $finish = $lib->[2];
@ -3701,7 +3694,7 @@ sub ExtractSymbols {
my $contained = [];
while (($pc ge $start) && ($pc le $finish)) {
push(@{$contained}, $pc);
$pc = shift(@pcs);
$pc = pop(@pcs);
if (!defined $pc) {
last;
}