From af366593a4cd5bc6f111dd6e6492594d7cd1e6cb Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Wed, 7 Apr 2010 19:52:15 -0700 Subject: [PATCH] Improve ExtractSymbols (pprof). Iterated downward through both libraries and PCs. This allows PCs to resolve even when library address ranges overlap. --- jemalloc/bin/pprof | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/jemalloc/bin/pprof b/jemalloc/bin/pprof index 73d35dda..e42d3b22 100755 --- a/jemalloc/bin/pprof +++ b/jemalloc/bin/pprof @@ -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; }