valgrindtraceperfgprofflamegraph

C profiler/tracer with timeline view


I am trying to get into C language and looking for a profiler or tracer tool that supports timeline view representation with every function calls. Something like tracing via PHP xDebug. Where all function calls placed approximately at exact time they were called in the stack.

xdebug trace timeline

My research so far is:

So far I found that valgrind --tool=callgrind ./myscript is the closest one I can use.
However the visualization is a flamegraph that samples the C function calls.
In my case it is a good start for reverse engineering but I would like to have detailed timeline with actual calls timiestamps. valgrind flamegraph in speedscope

I also checked the gprofng however the textual visualization is not that easy to read and it seems to be same sampled flamegraph
gprofng

I also tried to do something via perf but it looks like perf recording only system/linux calls without timestamps, at least that what is visible in the speedscope.
Maybe I am not using perf correctly but that is what I got after trying different commands from https://www.brendangregg.com/perf.html perf in speedscope

I understand some basics that the app must be compiled with -g or that tracing adds some overhead and timings might be not 100% accurate but I found it difficult to get a tool that can visualize calltree as timeline in C language.


Solution

  • For now the best thing that solves my case is uftrace profiler https://github.com/namhyung/uftrace