libbacktrace supports DWARF discriminator field
libbacktrace now provides the DWARF 'discriminator' field for more precise inlined function call information.
The libbacktrace library has been enhanced to support the DWARF ‘discriminator’ field, which helps distinguish between multiple calls to the same function at the same source location, particularly in inlined code. This change introduces a new struct backtrace_moredata and updates DWARF parsing to capture and report this discriminator value. This provides more accurate and detailed stack traces, especially in complex codebases with extensive inlining.
In Details
This patch extends libbacktrace's DWARF unwinding capabilities to support the DW_AT_GNU_discriminator attribute. It introduces a disc field in the struct line and caller_disc in struct function, along with a new backtrace_state field moredata. The dwarf.c parser tracks and stores this discriminator, enabling call_callback to report it, improving accuracy for inlined functions. This change also refactors backtrace_create_state's threaded parameter to flags and adds a corresponding BACKTRACE_SUPPORTS_MOREDATA macro.
- libbacktrace
- A library that provides functions for obtaining stack traces in C and C++ programs, typically used for debugging and error reporting.
- DWARF
- A standardized debugging data format used by compilers to store symbolic information about source code, enabling debuggers to map executable code back to the original source.
- Discriminator
- In DWARF debugging information, a value that helps uniquely identify a specific call site, especially for inlined functions, when multiple instances of the same function exist at the same source location.
- Inlined function
- A function whose code is expanded directly at the call site by the compiler, rather than being called as a separate function. This can improve performance but complicates stack traces.
- Stack trace
- A report of the active functions called up to a certain point in program execution, typically used to diagnose crashes or performance issues.