koute / not-perf

A sampling CPU profiler for Linux
Apache License 2.0
868 stars 40 forks source link

Support compressed debug sections #35

Open thiagovice opened 1 year ago

thiagovice commented 1 year ago

I'm trying to profile an application that has compressed debug sections, but the resulting flamegraph does not show the function names. Decompressing the symbol file prior to analysis work, but it would be nice if we could support compressed debug sections. Here's the reproduction steps:

mkdir /demo
mkdir /usr/lib/debug/demo/
cd /demo
wget -O demo.c https://gist.githubusercontent.com/thiagovice/d0f65a8b5e8cc254e840e70477cff77e/raw/1eb029244b60b6d52b373a87eb8cb8dd7984539d/demo.c

gcc -ggdb -o demo -Wl,--compress-debug-sections=zlib demo.c
objcopy --only-keep-debug demo demo.sym
strip -s demo
mv demo.sym /usr/lib/debug/demo/demo
./demo &

timeout 10s ./nperf record -F 997 -p `pgrep -f 'demo'` -o datafileDemo
./nperf flamegraph datafileDemo -d /usr/lib/debug/ > flame.svg

The resulting flame.svg, won't show the function properly, only addressees. Removing the linking option "-Wl,--compress-debug-sections=zlib" and repeating the process gets a correct flamegraph