Linux perf demangle D symbols
Alex Burton
ab at bab.com
Wed Feb 26 13:21:42 UTC 2020
On Wednesday, 26 February 2020 at 07:20:03 UTC, Arun
Chandrasekaran wrote:
> Does anyone use Linux perf here, with D symbols demangled?
>
> I'm on Ubuntu 19.10, but I can't get perf to demangle the D
> symbols.
This is my sh script for performance monitoring on debian buster
using Brendan Greggs flamegraph:
sudo perf record -F 99 -a --call-graph dwarf -- sleep 10
#sudo perf record -F 99 --call-graph dwarf -p 31984
sudo perf script > tree.perf
~/dev/FlameGraph/stackcollapse-perf.pl tree.perf > tree.folded
~/dev/FlameGraph/flamegraph.pl tree.folded > tree_.svg
cat tree_.svg | ./dfilt > tree.svg
firefox tree.svg
This is the source code in dfilt:
import std.ascii : isAlphaNum;
import std.algorithm;
import std.range;
import std.conv : to;
import std.demangle : demangle;
import std.functional : pipe;
import std.stdio;
string translateSymbol(string s)
{
if (s[0..2] == "_D")
{
auto result = demangle(s);
writefln("%s => %s",s,result);
}
return s;
}
string translateGroup(U)(U group)
{
if ((group[0]))
return demangle(group[1].to!string);
else
return group[1].to!string;
}
auto translateLine(string l)
{
return l.chunkBy!(a => isAlphaNum(a) || a ==
'_').map!translateGroup.joiner;
}
void main()
{
auto result = stdin.byLineCopy
.map!translateLine
.joiner("\n").array;
result.copy(stdout.lockingTextWriter);
}
Hope this helps
More information about the Digitalmars-d
mailing list