From 817c6ea3b92417349605e5715fe6a7cb8cbc9776 Mon Sep 17 00:00:00 2001 From: Brendan Gregg Date: Thu, 4 Dec 2014 17:40:36 -0800 Subject: [PATCH] tidy a horrid javascript frame --- stackcollapse-perf.pl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/stackcollapse-perf.pl b/stackcollapse-perf.pl index 92776469..77c56b6a 100755 --- a/stackcollapse-perf.pl +++ b/stackcollapse-perf.pl @@ -66,13 +66,20 @@ sub remember_stack { my $pname; my $include_pname = 1; # include process names in stacks my $tidy_java = 1; # condense Java signatures +my $tidy_generic = 1; # clean up function names a little foreach (<>) { next if m/^#/; chomp; if (m/^$/) { - if ($include_pname) { unshift @stack, $pname; } + if ($include_pname) { + if (defined $pname) { + unshift @stack, $pname; + } else { + unshift @stack, ""; + } + } remember_stack(join(";", @stack), 1) if @stack; undef @stack; undef $pname; @@ -84,8 +91,17 @@ sub remember_stack { } elsif (/^\s*\w+\s*(.+) (\S+)/) { my ($func, $mod) = ($1, $2); next if $func =~ /^\(/; # skip process names + if ($tidy_generic) { + $func =~ s/;/:/g; + $func =~ tr/<>//d; + $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") { - # eg, convert the following: + # 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;.(Ljava/lang/reflect/Method;)V @@ -93,9 +109,6 @@ sub remember_stack { # org/mozilla/javascript/ContextFactory:.call # org/mozilla/javascript/ContextFactory:.call # org/mozilla/javascript/MemberBox:.init - $func =~ s/;/:/g; - $func =~ tr/<>//d; - $func =~ s/\(.*//; $func =~ s/^L// if $func =~ m:/:; } unshift @stack, $func;