Created attachment 32152 [details] test case to reproduce the bug Compile the test case with "-lbacktrace -g". Actual output: test.c:17 (null) Expected output: The backtrace should contain the function name ('a') instead of null. AFAICS the problem is in read_function_entry. There's a "abbrev->has_children" check that assumes all children of a function are inlined instances of the same function. This is not true, children can also be nested functions. libbacktrace should check the "DW_AT_inline" tag here.
I can reproduce this. But, I wonder if this an actual bug, given that the address of the nested function that is passed as argument to backtrace_pcinfo is either a trampoline on stack or some function descriptor ( https://gcc.gnu.org/onlinedocs/gccint/Trampolines.html ). Using a backtrace_print from a nested function works fine. I propose to mark this resolved-invalid.
I agree that this example cannot be expected to work. The docs for backtrace_pcinfo say that the function works when "Given PC, a program counter in the current program." The value (uintptr_t)&a is not a program counter in the current program.