commit 517275bd2e3c3c3096dc61b20d08542e553da252
parent b3eac8fea4052e5d180637f8d82dec8221cbf8b8
Author: Brendan Gregg <brendan.d.gregg@gmail.com>
Date: Tue, 8 Dec 2015 01:44:41 -0800
Merge pull request #77 from ekacnet/misc
Fixes and minor improvements for flamegraph + stack collapse
Diffstat:
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/flamegraph.pl b/flamegraph.pl
@@ -120,7 +120,7 @@ USAGE: $0 [options] infile > outfile.svg\n
--countname # count type label (default "samples")
--nametype # name type label (default "Function:")
--colors # set color palette. choices are: hot (default), mem, io,
- # java, js, red, green, blue, yellow, purple, orange
+ # java, js, perl, red, green, blue, yellow, purple, orange
--hash # colors are keyed by function name hash
--cp # use consistent palette (palette.map)
--reverse # generate stack-reversed flame graph
@@ -335,6 +335,20 @@ sub color {
$type = "yellow";
} elsif ($name =~ m:/:) { # Java (match "/" in path)
$type = "green"
+ } elsif ($name =~ m: \[k\]:) { # kernel
+ $type = "purple"
+ } else { # system
+ $type = "red";
+ }
+ # fall-through to color palettes
+ }
+ if (defined $type and $type eq "perl") {
+ if ($name =~ /::/) { # C++
+ $type = "yellow";
+ } elsif ($name =~ m:Perl: or $name =~ m:\.pl:) { # Perl
+ $type = "green";
+ } elsif ($name =~ m: \[k\]:) { # kernel
+ $type = "purple"
} else { # system
$type = "red";
}
@@ -349,6 +363,8 @@ sub color {
$type = "aqua"
} elsif ($name =~ m/^ $/) { # Missing symbol
$type = "green"
+ } elsif ($name =~ m: \[k\]:) { # kernel
+ $type = "purple"
} else { # system
$type = "red";
}
@@ -413,7 +429,7 @@ sub color_map {
if (exists $palette_map{$func}) {
return $palette_map{$func};
} else {
- $palette_map{$func} = color($colors);
+ $palette_map{$func} = color($colors, $hash, $func);
return $palette_map{$func};
}
}
diff --git a/stackcollapse-perf.pl b/stackcollapse-perf.pl
@@ -72,7 +72,7 @@ sub remember_stack {
my ($stack, $count) = @_;
$collapsed{$stack} += $count;
}
-
+my $annotate_kernel = 0; # put an annotation on kernel function
my $include_pname = 1; # include process names in stacks
my $include_pid = 0; # include process ID with process name
my $include_tid = 0; # include process & thread ID with process name
@@ -85,12 +85,14 @@ my $show_context = 0;
GetOptions('inline' => \$show_inline,
'context' => \$show_context,
'pid' => \$include_pid,
+ 'kernel' => \$annotate_kernel,
'tid' => \$include_tid)
or die <<USAGE_END;
USAGE: $0 [options] infile > outfile\n
--pid # include PID with process names [1]
--tid # include TID and PID with process names [1]
--inline # un-inline using addr2line
+ --kernel # annotate kernel functions with a [k]
--context # include source context from addr2line\n
[1] perf script must emit both PID and TIDs for these to work; eg:
perf script -f comm,pid,tid,cpu,time,event,ip,sym,dso,trace
@@ -201,7 +203,7 @@ while (defined($_ = <>)) {
# 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) {
unshift @stack, inline($pc, $mod);
next;