commit eaed26b950d3f46173cdcc9a92190b68952c0d39
parent 4bf9ce0b82e126d37d1b6d2591b865224a9df8e4
Author: Brendan Gregg <brendan.d.gregg@gmail.com>
Date: Fri, 13 May 2016 12:24:13 -0700
Merge pull request #89 from tjake/unfoldall-support
Unfoldall support
Diffstat:
2 files changed, 56 insertions(+), 47 deletions(-)
diff --git a/flamegraph.pl b/flamegraph.pl
@@ -341,8 +341,9 @@ sub color {
# multi palettes
if (defined $type and $type eq "java") {
- if ($name =~ m:/:) { # Java (match "/" in path)
- $type = "green"
+ if ($name =~ m:(/|\.):) { # Java (match "/" in path)
+ $type = "green";
+ $type = "aqua" if $name =~ m/_\[i\]/; #inline
} elsif ($name =~ /::/) { # C++
$type = "yellow";
} elsif ($name =~ m:_\[k\]:) { # kernel
@@ -651,8 +652,8 @@ my $inc = <<INC;
<script type="text/ecmascript">
<![CDATA[
var details, searchbtn, matchedtxt, svg;
- function init(evt) {
- details = document.getElementById("details").firstChild;
+ function init(evt) {
+ details = document.getElementById("details").firstChild;
searchbtn = document.getElementById("search");
matchedtxt = document.getElementById("matched");
svg = document.getElementsByTagName("svg")[0];
@@ -712,20 +713,20 @@ my $inc = <<INC;
var w = parseFloat(r.attributes["width"].value) -3;
var txt = find_child(e, "title").textContent.replace(/\\([^(]*\\)\$/,"");
t.attributes["x"].value = parseFloat(r.attributes["x"].value) +3;
-
+
// Smaller than this size won't fit anything
if (w < 2*$fontsize*$fontwidth) {
t.textContent = "";
return;
}
-
+
t.textContent = txt;
// Fit in full text width
if (/^ *\$/.test(txt) || t.getSubStringLength(0, txt.length) < w)
return;
-
+
for (var x=txt.length-2; x>0; x--) {
- if (t.getSubStringLength(0, x+2) <= w) {
+ if (t.getSubStringLength(0, x+2) <= w) {
t.textContent = txt.substring(0,x) + "..";
return;
}
@@ -756,7 +757,7 @@ my $inc = <<INC;
e.attributes["width"].value = parseFloat(e.attributes["width"].value) * ratio;
}
}
-
+
if (e.childNodes == undefined) return;
for(var i=0, c=e.childNodes; i<c.length; i++) {
zoom_child(c[i], x-$xpad, ratio);
@@ -778,20 +779,20 @@ my $inc = <<INC;
zoom_parent(c[i]);
}
}
- function zoom(node) {
+ function zoom(node) {
var attr = find_child(node, "rect").attributes;
var width = parseFloat(attr["width"].value);
var xmin = parseFloat(attr["x"].value);
var xmax = parseFloat(xmin + width);
var ymin = parseFloat(attr["y"].value);
var ratio = (svg.width.baseVal.value - 2*$xpad) / width;
-
+
// XXX: Workaround for JavaScript float issues (fix me)
var fudge = 0.0001;
-
+
var unzoombtn = document.getElementById("unzoom");
unzoombtn.style["opacity"] = "1.0";
-
+
var el = document.getElementsByTagName("g");
for(var i=0;i<el.length;i++){
var e = el[i];
@@ -833,7 +834,7 @@ my $inc = <<INC;
function unzoom() {
var unzoombtn = document.getElementById("unzoom");
unzoombtn.style["opacity"] = "0.0";
-
+
var el = document.getElementsByTagName("g");
for(i=0;i<el.length;i++) {
el[i].style["display"] = "block";
@@ -841,7 +842,7 @@ my $inc = <<INC;
zoom_reset(el[i]);
update_text(el[i]);
}
- }
+ }
// search
function reset_search() {
@@ -1021,7 +1022,7 @@ while (my ($id, $node) = each %Node) {
$escaped_func =~ s/</</g;
$escaped_func =~ s/>/>/g;
$escaped_func =~ s/"/"/g;
- $escaped_func =~ s/_\[[kw]\]$//; # strip any annotation
+ $escaped_func =~ s/_\[[kwi]\]$//; # strip any annotation
unless (defined $delta) {
$info = "$escaped_func ($samples_txt $countname, $pct%)";
} else {
@@ -1055,7 +1056,7 @@ while (my ($id, $node) = each %Node) {
my $chars = int( ($x2 - $x1) / ($fontsize * $fontwidth));
my $text = "";
if ($chars >= 3) { # room for one char plus two dots
- $func =~ s/_\[[kw]\]$//; # strip any annotation
+ $func =~ s/_\[[kwi]\]$//; # strip any annotation
$text = substr $func, 0, $chars;
substr($text, -2, 2) = ".." if $chars < length $func;
$text =~ s/&/&/g;
diff --git a/stackcollapse-perf.pl b/stackcollapse-perf.pl
@@ -13,7 +13,7 @@
#
# Example input:
#
-# swapper 0 [000] 158665.570607: cpu-clock:
+# swapper 0 [000] 158665.570607: cpu-clock:
# ffffffff8103ce3b native_safe_halt ([kernel.kallsyms])
# ffffffff8101c6a3 default_idle ([kernel.kallsyms])
# ffffffff81013236 cpu_idle ([kernel.kallsyms])
@@ -200,45 +200,53 @@ while (defined($_ = <>)) {
}
$pname =~ tr/ /_/;
- # stack line
+ # stack line
} elsif (/^\s*(\w+)\s*(.+) \((\S*)\)/) {
- my ($pc, $func, $mod) = ($1, $2, $3);
- $func.="_[k]" if ($annotate_kernel == 1 && $mod =~ m/kernel.kall/);
- if ($show_inline == 1 && index($mod, $target_pname) != -1) {
+ my ($pc, $rawfunc, $mod) = ($1, $2, $3);
+ $rawfunc.="_[k]" if ($annotate_kernel == 1 && $mod =~ m/kernel\./);
+ if ($show_inline == 1 && $mod !~ m/(perf-\d+.map|kernel\.|\[[^\]]+\])/) {
unshift @stack, inline($pc, $mod);
next;
}
- next if $func =~ /^\(/; # skip process names
+ next if $rawfunc =~ /^\(/; # skip process names
- if ($tidy_generic) {
- $func =~ s/;/:/g;
- $func =~ tr/<>//d;
- if ($func !~ m/\.\(.*\)\./) {
- # This doesn't look like a Go method name (such as
- # "net/http.(*Client).Do"), so everything after the first open
- # paren is just noise.
- $func =~ s/\(.*//;
+ my @inline;
+ for (split /\->/, $rawfunc) {
+ my $func = $_;
+
+ if ($tidy_generic) {
+ $func =~ s/;/:/g;
+ $func =~ tr/<>//d;
+ if ($func !~ m/\.\(.*\)\./) {
+ # This doesn't look like a Go method name (such as
+ # "net/http.(*Client).Do"), so everything after the first open
+ # paren is just noise.
+ $func =~ s/\(.*//;
+ }
+ # now tidy this horrible thing:
+ # 13a80b608e0a RegExp:[&<>\"\'] (/tmp/perf-7539.map)
+ $func =~ tr/"\'//d;
+ # fall through to $tidy_java
+ }
+
+ if ($tidy_java and $pname eq "java") {
+ # along with $tidy_generic, converts the following:
+ # Lorg/mozilla/javascript/ContextFactory;.call(Lorg/mozilla/javascript/ContextAction;)Ljava/lang/Object;
+ # Lorg/mozilla/javascript/ContextFactory;.call(Lorg/mozilla/javascript/C
+ # Lorg/mozilla/javascript/MemberBox;.<init>(Ljava/lang/reflect/Method;)V
+ # into:
+ # org/mozilla/javascript/ContextFactory:.call
+ # org/mozilla/javascript/ContextFactory:.call
+ # org/mozilla/javascript/MemberBox:.init
+ $func =~ s/^L// if $func =~ m:/:;
}
- # now tidy this horrible thing:
- # 13a80b608e0a RegExp:[&<>\"\'] (/tmp/perf-7539.map)
- $func =~ tr/"\'//d;
- # fall through to $tidy_java
- }
- if ($tidy_java and $pname eq "java") {
- # along with $tidy_generic, converts the following:
- # Lorg/mozilla/javascript/ContextFactory;.call(Lorg/mozilla/javascript/ContextAction;)Ljava/lang/Object;
- # Lorg/mozilla/javascript/ContextFactory;.call(Lorg/mozilla/javascript/C
- # Lorg/mozilla/javascript/MemberBox;.<init>(Ljava/lang/reflect/Method;)V
- # into:
- # org/mozilla/javascript/ContextFactory:.call
- # org/mozilla/javascript/ContextFactory:.call
- # org/mozilla/javascript/MemberBox:.init
- $func =~ s/^L// if $func =~ m:/:;
+ $func .= "_[i]" if scalar(@inline) > 0; #inlined
+ push @inline, $func;
}
- unshift @stack, $func;
+ unshift @stack, @inline;
} else {
warn "Unrecognized line: $_";
}