diff options
author | Jason Evans <je@fb.com> | 2015-12-14 19:42:08 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2015-12-14 19:42:08 (GMT) |
commit | 43de1b3ebc928fa0884422ccd0a2e9cd233d1059 (patch) | |
tree | 3adf3a6927c9def341af08dde63ed8f8dd52386b | |
parent | 3a92319ddc5610b755f755cbbbd12791ca9d0c3d (diff) | |
download | jemalloc-43de1b3ebc928fa0884422ccd0a2e9cd233d1059.zip jemalloc-43de1b3ebc928fa0884422ccd0a2e9cd233d1059.tar.gz jemalloc-43de1b3ebc928fa0884422ccd0a2e9cd233d1059.tar.bz2 |
Implement --retain and --exclude in jeprof.
These options make it possible to filter symbolized backtrace frames
using regular expressions.
-rw-r--r-- | bin/jeprof.in | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/bin/jeprof.in b/bin/jeprof.in index d00ef5d..444041e 100644 --- a/bin/jeprof.in +++ b/bin/jeprof.in @@ -223,12 +223,14 @@ Call-graph Options: --nodefraction=<f> Hide nodes below <f>*total [default=.005] --edgefraction=<f> Hide edges below <f>*total [default=.001] --maxdegree=<n> Max incoming/outgoing edges per node [default=8] - --focus=<regexp> Focus on nodes matching <regexp> + --focus=<regexp> Focus on backtraces with nodes matching <regexp> --thread=<n> Show profile for thread <n> - --ignore=<regexp> Ignore nodes matching <regexp> + --ignore=<regexp> Ignore backtraces with nodes matching <regexp> --scale=<n> Set GV scaling [default=0] --heapcheck Make nodes with non-0 object counts (i.e. direct leak generators) more visible + --retain=<regexp> Retain only nodes that match <regexp> + --exclude=<regexp> Exclude all nodes that match <regexp> Miscellaneous: --tools=<prefix or binary:fullpath>[,...] \$PATH for object tool pathnames @@ -339,6 +341,8 @@ sub Init() { $main::opt_ignore = ''; $main::opt_scale = 0; $main::opt_heapcheck = 0; + $main::opt_retain = ''; + $main::opt_exclude = ''; $main::opt_seconds = 30; $main::opt_lib = ""; @@ -410,6 +414,8 @@ sub Init() { "ignore=s" => \$main::opt_ignore, "scale=i" => \$main::opt_scale, "heapcheck" => \$main::opt_heapcheck, + "retain=s" => \$main::opt_retain, + "exclude=s" => \$main::opt_exclude, "inuse_space!" => \$main::opt_inuse_space, "inuse_objects!" => \$main::opt_inuse_objects, "alloc_space!" => \$main::opt_alloc_space, @@ -2840,6 +2846,43 @@ sub ExtractCalls { return $calls; } +sub FilterFrames { + my $symbols = shift; + my $profile = shift; + + if ($main::opt_retain eq '' && $main::opt_exclude eq '') { + return $profile; + } + + my $result = {}; + foreach my $k (keys(%{$profile})) { + my $count = $profile->{$k}; + my @addrs = split(/\n/, $k); + my @path = (); + foreach my $a (@addrs) { + my $sym; + if (exists($symbols->{$a})) { + $sym = $symbols->{$a}->[0]; + } else { + $sym = $a; + } + if ($main::opt_retain ne '' && $sym !~ m/$main::opt_retain/) { + next; + } + if ($main::opt_exclude ne '' && $sym =~ m/$main::opt_exclude/) { + next; + } + push(@path, $a); + } + if (scalar(@path) > 0) { + my $reduced_path = join("\n", @path); + AddEntry($result, $reduced_path, $count); + } + } + + return $result; +} + sub RemoveUninterestingFrames { my $symbols = shift; my $profile = shift; @@ -2984,6 +3027,9 @@ sub RemoveUninterestingFrames { my $reduced_path = join("\n", @path); AddEntry($result, $reduced_path, $count); } + + $result = FilterFrames($symbols, $result); + return $result; } |