commit 9d7c1b1233839de1f842135be84e54f2470adb42
parent 18c3dea3b2c55ae66768936f1039e36a12b627f6
Author: Brendan Gregg <brendan.d.gregg@gmail.com>
Date: Tue, 16 Oct 2018 15:33:22 -0700
Merge pull request #186 from psanford/stackcollapse-bpftrace
Stackcollapse for bpftrace
Diffstat:
8 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/dev/hcstackcollapse.pl b/dev/hcstackcollapse.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# hcstackcolllapse.pl collapse hot/cold multiline stacks into single lines.
+# hcstackcollapse.pl collapse hot/cold multiline stacks into single lines.
#
# EXPERIMENTAL: This is a work in progress, and may not work properly.
#
diff --git a/stackcollapse-bpftrace.pl b/stackcollapse-bpftrace.pl
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -w
+#
+# stackcollapse-bpftrace.pl collapse bpftrace samples into single lines.
+#
+# USAGE ./stackcollapse-bpftrace.pl infile > outfile
+#
+# Example input:
+#
+# @[
+# _raw_spin_lock_bh+0
+# tcp_recvmsg+808
+# inet_recvmsg+81
+# sock_recvmsg+67
+# sock_read_iter+144
+# new_sync_read+228
+# __vfs_read+41
+# vfs_read+142
+# sys_read+85
+# do_syscall_64+115
+# entry_SYSCALL_64_after_hwframe+61
+# ]: 3
+#
+# Example output:
+#
+# entry_SYSCALL_64_after_hwframe+61;do_syscall_64+115;sys_read+85;vfs_read+142;__vfs_read+41;new_sync_read+228;sock_read_iter+144;sock_recvmsg+67;inet_recvmsg+81;tcp_recvmsg+808;_raw_spin_lock_bh+0 3
+#
+# Copyright 2018 Peter Sanford. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# (http://www.gnu.org/copyleft/gpl.html)
+#
+
+use strict;
+
+my @stack;
+my $in_stack = 0;
+
+foreach (<>) {
+ chomp;
+ if (!$in_stack) {
+ if (/^@\[/) {
+ $in_stack = 1;
+ }
+ } else {
+ if (m/^\]: (\d+)/) {
+ print join(';', reverse(@stack)) . " $1\n";
+ $in_stack = 0;
+ @stack = ();
+ } else {
+ push(@stack, $_);
+ }
+ }
+}
diff --git a/stackcollapse-go.pl b/stackcollapse-go.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# stackcolllapse-go.pl collapse golang samples into single lines.
+# stackcollapse-go.pl collapse golang samples into single lines.
#
# Parses golang smaples generated by "go tool pprof" and outputs stacks as
# single lines, with methods separated by semicolons, and then a space and an
diff --git a/stackcollapse-jstack.pl b/stackcollapse-jstack.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# stackcolllapse-jstack.pl collapse jstack samples into single lines.
+# stackcollapse-jstack.pl collapse jstack samples into single lines.
#
# Parses Java stacks generated by jstack(1) and outputs RUNNABLE stacks as
# single lines, with methods separated by semicolons, and then a space and an
diff --git a/stackcollapse-ljp.awk b/stackcollapse-ljp.awk
@@ -1,6 +1,6 @@
#!/usr/bin/awk -f
#
-# stackcolllapse-ljp.awk collapse lightweight java profile reports
+# stackcollapse-ljp.awk collapse lightweight java profile reports
# into single lines stacks.
#
# Parses a list of multiline stacks generated by:
diff --git a/stackcollapse-perf.pl b/stackcollapse-perf.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# stackcolllapse-perf.pl collapse perf samples into single lines.
+# stackcollapse-perf.pl collapse perf samples into single lines.
#
# Parses a list of multiline stacks generated by "perf script", and
# outputs a semicolon separated stack followed by a space and a count.
diff --git a/stackcollapse-stap.pl b/stackcollapse-stap.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# stackcolllapse-stap.pl collapse multiline SystemTap stacks
+# stackcollapse-stap.pl collapse multiline SystemTap stacks
# into single lines.
#
# Parses a multiline stack followed by a number on a separate line, and
diff --git a/stackcollapse.pl b/stackcollapse.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# stackcolllapse.pl collapse multiline stacks into single lines.
+# stackcollapse.pl collapse multiline stacks into single lines.
#
# Parses a multiline stack followed by a number on a separate line, and
# outputs a semicolon separated stack followed by a space and the number.