koute / not-perf

A sampling CPU profiler for Linux
Apache License 2.0
870 stars 41 forks source link

Always try to demangle #28

Open thiagovice opened 2 years ago

thiagovice commented 2 years ago

Fixes #24

If frame is not inline at adress_space line 385 and resolve_symbol returns None we won't try to demangle the symbol. This moves the demangle code so it always tries to demangled the symbol from name.

May not be the best way to do this so feel free to close!

Tests pass, and the resulting flamegraph is cleaner.

For reference here's how I've capture and generate the flamegraph:

./nperf record -F 997 -p 1234 -o datafile ./nperf flamegraph datafile -d /usr/lib/debug/ > flame.svg

Also the symbols are available at the correct path on /usr/lib/debug, so I'm not sure exactly why resolve_symbols would fail ?

nm /usr/lib/debug/tmp/mybin | wc -l 37587

But looks like, it reported it loaded only 69 symbols? [2022-08-31T17:18:03Z DEBUG nperf_core::data_reader] New binary: "/tmp/mybin" [2022-08-31T17:18:03Z DEBUG nwind::debug_info_index] Requested debug info for '/tmp/mybin'; debuglink = Some("mybin"), build_id = None [2022-08-31T17:18:03Z DEBUG nwind::debug_info_index] Debug info lookup result: bin = Some("/usr/lib/debug/tmp/mybin"), dbg = None [2022-08-31T17:18:03Z DEBUG nwind::symbols] Loaded 69 symbols for '/tmp/mybin' (0 normal, 69 dynamic) in 0ms

Curious to see why build_id is none there as well, as the file does have a build-id

file /tmp/mybin /tmp/mybin: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /tmp/.elf, for GNU/Linux 3.2.0, BuildID[sha1]=f5ba86caa2c7a6c8efed8efa44869bd268e740ec, stripped

koute commented 2 years ago

Can you share the source code for your test program and your exact compiler invocation that you use to compile it?