Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Two fixes for handling of demangled C++ symbols #4

Merged
merged 2 commits into from

2 participants

@rysto32

Here a two small fixes that make FlameGraph handle demangled symbols better. The first uses semicolons instead of commas to separate frames in the flamegraph.pl input, so avoid an ambiguity with a frame like foo(int, int). The second escapes <> in the output after the string is truncated. Currently it truncates after escaping, and I have seen cases where the string is truncated half-way through an escape sequence, causing malformed output.

Ryan Stone added some commits
Ryan Stone Use a semicolon to separate frames
Use a semicolon instead of a comma to separate frames in the
flamegraph input.  Commas can appear in demangled C++ function
names (e.g. foo(int, int) ) so using commas to separate frames
can confuse the parser.
02b07ad
Ryan Stone Escape strings after they have been truncated.
Don't truncate strings after they have been escaped.  If you do,
there is a chance you will happen to truncate half-way through
an escape sequence, causing malformed output.
93f5b19
@brendangregg brendangregg merged commit fc4a545 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 14, 2012
  1. Use a semicolon to separate frames

    Ryan Stone authored
    Use a semicolon instead of a comma to separate frames in the
    flamegraph input.  Commas can appear in demangled C++ function
    names (e.g. foo(int, int) ) so using commas to separate frames
    can confuse the parser.
  2. Escape strings after they have been truncated.

    Ryan Stone authored
    Don't truncate strings after they have been escaped.  If you do,
    there is a chance you will happen to truncate half-way through
    an escape sequence, causing malformed output.
This page is out of date. Refresh to see the latest.
View
16 flamegraph.pl
@@ -135,8 +135,8 @@ sub color {
sub flow {
my ($a, $b, $v) = @_;
- my @A = split ",", $a;
- my @B = split ",", $b;
+ my @A = split ";", $a;
+ my @B = split ";", $b;
my $len_a = $#A;
my $len_b = $#B;
@@ -240,10 +240,11 @@ sub flow {
$info = "all samples ($samples samples, 100%)";
} else {
my $pct = sprintf "%.2f", ((100 * $samples) / $timemax);
- $func =~ s/&/&amp;/g;
- $func =~ s/</&lt;/g;
- $func =~ s/>/&gt;/g;
- $info = "$func ($samples samples, $pct%)";
+ my $escaped_func = $func;
+ $escaped_func =~ s/&/&amp;/g;
+ $escaped_func =~ s/</&lt;/g;
+ $escaped_func =~ s/>/&gt;/g;
+ $info = "$escaped_func ($samples samples, $pct%)";
}
$im->filledRectangle($x1, $y1, $x2, $y2, color("hot"), 'rx="2" ry="2" onmouseover="s(' . "'$info'" . ')" onmouseout="c()"');
@@ -251,6 +252,9 @@ sub flow {
my $chars = int($width / (0.7 * $fontsize));
my $text = substr $func, 0, $chars;
$text .= ".." if $chars < length $func;
+ $text =~ s/&/&amp;/g;
+ $text =~ s/</&lt;/g;
+ $text =~ s/>/&gt;/g;
$im->stringTTF($black, $fonttype, $fontsize, 0.0, $x1 + 3, 3 + ($y1 + $y2) / 2, $text, "",
'onmouseover="s(' . "'$info'" . ')" onmouseout="c()"');
}
View
2  stackcollapse-perf.pl
@@ -68,7 +68,7 @@ sub remember_stack {
chomp;
if (m/^$/) {
- remember_stack(join(",", @stack), 1) if @stack;
+ remember_stack(join(";", @stack), 1) if @stack;
undef @stack;
next;
}
View
2  stackcollapse-stap.pl
@@ -64,7 +64,7 @@ sub remember_stack {
chomp;
if (m/^\s*(\d+)+$/) {
- remember_stack(join(",", @stack), $1);
+ remember_stack(join(";", @stack), $1);
@stack = ();
next;
}
View
2  stackcollapse.pl
@@ -66,7 +66,7 @@ sub remember_stack {
chomp;
if (m/^\s*(\d+)+$/) {
- remember_stack(join(",", @stack), $1);
+ remember_stack(join(";", @stack), $1);
@stack = ();
next;
}
Something went wrong with that request. Please try again.