Skip to content

Commit

Permalink
Update stackcollapse-bpftrace to work with book examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jfernandez committed Aug 21, 2021
1 parent a258e78 commit ecc931c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions stackcollapse-bpftrace.pl
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@
foreach (<>) {
chomp;
if (!$in_stack) {
if (/^@\[/) {
if (/^@\[$/) {
$in_stack = 1;
} elsif (/^@\[,\s(.*)\]: (\d+)/) {
print $1 . " $2\n";
}
} else {
if (m/^\]: (\d+)/) {
print join(';', reverse(@stack)) . " $1\n";
if (m/^,?\s?(.*)\]: (\d+)/) {
if (length $1) {
push(@stack, $1);
}
print join(';', reverse(@stack)) . " $2\n";
$in_stack = 0;
@stack = ();
} else {
$_ =~ s/^\s+//;
push(@stack, $_);
}
}
Expand Down

0 comments on commit ecc931c

Please sign in to comment.