www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linux perf demangle D symbols

reply Arun Chandrasekaran <aruncxy gmail.com> writes:
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.
Feb 25
next sibling parent Sebastiaan Koppe <mail skoppe.eu> writes:
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.
I vaguely remember using ddemangle
Feb 26
prev sibling next sibling parent drug <drug2004 bk.ru> writes:
On 2/26/20 10:20 AM, 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.
If you use `perf report` then that currently is impossible I guess. But if you use flamegraph for example then ddemangle can help here: ``` git clone https://github.com/brendangregg/FlameGraph.git perf script | FlameGraph/stackcollapse-perf.pl | FlameGraph/flamegraph.pl | ddemangle > perf.svg ``` but some symbols remain mangled
Feb 26
prev sibling next sibling parent Mathias Lang <pro.mathias.lang gmail.com> writes:
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.
For the non interactive version, you can just use `perf report | ddemangle` As for the interactive version, I don't know. Other coreutils tools have a `--demangle=dlang` option (e.g. `nm`), but perf only have `--demangle` to prevent demangling of symbols: ``` --demangle Disable symbol demangling --demangle-kernel Enable kernel symbol demangling ``` There's also an `objdump` option which you can set to a shell script that does `objdump --demangle=dlang $*` so you get symbols demangled in the disassembled code, but for the main interface, there doesn't seem to be a way to do it interactively. Perhaps raise the issue upstream?
Feb 26
prev sibling parent reply Alex Burton <ab bab.com> writes:
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
Feb 26
parent Arun Chandrasekaran <aruncxy gmail.com> writes:
On Wednesday, 26 February 2020 at 13:21:42 UTC, Alex Burton wrote:
 On Wednesday, 26 February 2020 at 07:20:03 UTC, Arun 
 Chandrasekaran wrote:
 [...]
This is my sh script for performance monitoring on debian buster using Brendan Greggs flamegraph: [...]
These work-arounds work to some extent, but gets in the way too often as (I'm just lazy). I will see if I can check with upstream to include ddemangle. Thanks everyone.
Feb 29