gprof: Fix disappearing inlined functions
gprof now includes function names from line/debug symbols, correctly attributing CPU cycles to inlined functions.
This patch modifies gprof to load function names from line/debug symbols, ensuring that inlined functions are properly accounted for in profiling results. Previously, CPU cycles spent in inlined functions might be attributed to the calling function (e.g., main), leading to inaccurate profiling data. This change provides more precise performance insights by correctly attributing time to inlined functions.
- proposer
Proposes a patch to load function names from line/debug symbols to fix the issue of gprof not showing inlined functions.
“Load the function names from line/debug-symbols if available. The following test spends most of its CPU cycles mathing the long way around in xorshift_reverse(), but prior to this patch gprof would show 100% CPU spent in main().”
- reviewer
States that the full patch was not included in the email.
Technical Tradeoffs
- May increase the size of the gprof's symbol table.
- Requires access to line/debug symbol information.
In Details
gprof samples the program counter to determine where time is spent. Inlined functions can be difficult to attribute correctly without line/debug symbol information. This patch modifies corefile.c and gprof.c to load this information, improving the accuracy of profiling for inlined functions.
For Context
gprof is a profiling tool that helps developers understand where their programs are spending the most time. It works by periodically sampling the program's execution and recording the function that is currently being executed. Inlined functions, which are inserted directly into the calling function, can be difficult for profilers to track accurately, leading to skewed results. This patch aims to improve gprof's handling of inlined functions, providing more accurate profiling data.