Report decl_lineno with MOREDATA in libbacktrace.
Improved stack unwinding to include declaration line numbers for inlined functions.
The libbacktrace library now reports the declaration line number for inlined functions, enhancing debugging information. This change adds a new field backtrace_decl_lineno to the backtrace_moredata structure and updates DWARF parsing logic to extract and provide this information. The corresponding test cases in mdtest.c are adjusted to verify the correctness of this new data, making it easier to pinpoint the source of inlined code.
In Details
This change enhances libbacktrace's DWARF parsing capabilities to capture and report decl_lineno (declaration line number) for function entries, particularly relevant for inlined functions. The BACKTRACE_MOREDATA_VERSION is incremented to 4 to accommodate the new backtrace_decl_lineno field in struct backtrace_moredata. The DWARF reading functions (dwarf.c) are modified to set this field when reading function entries and to correctly propagate it across inlined call sites. The mdtest infrastructure is updated to support testing this new piece of data.
- libbacktrace
- A library used for generating stack traces at runtime. It helps in debugging by providing information about the call stack when an error occurs.
- DWARF
- A standard debugging data format used by compilers like GCC and Clang. It contains information about variables, types, functions, and source code locations, enabling debuggers to present code in a human-readable form.
- decl_lineno
- Stands for 'declaration line number'. In debugging information, it refers to the line number in the source file where a variable, function, or other entity was declared.
- MOREDATA
- An extension to the standard libbacktrace callback mechanism that allows for passing additional debugging information beyond the basic frame data. This commit introduces a new version of MOREDATA to include declaration line numbers.
- inlined functions
- Functions whose code is directly inserted into the calling function's code by the compiler, rather than being called as a separate function. This can improve performance by reducing function call overhead but can complicate debugging.