Some kind of useful information does exist in the binary, because GDB is able to show more useful names for lambda functions e.g.
(gdb) bt
#0 <lambda()>::operator()(void) const (__closure=0x7fffffffd5ef) at ll.cc:3
#1 0x00000000004005e7 in main () at ll.cc:3
(ALthough maybe the debug info just says it's a closure type, as GDB shows all such functions as <lambda()>::operator()
)
The mangled name of a template instantiated with a closure type includes a unique name e.g.
#3 0x0000000000400712 in func<main()::<lambda()> >(<lambda()>) (t=...) at l.cc:4
but maybe the name is only used when it's needed in other mangled names.
With GCC you can also print out the name of the closure's operator()
by printing the pre-defined variable __PRETTY_FUNCTION__
, which shows something like main()::<lambda()>
Using GDB's Python API I can get yet another name for the same closure, e.g.
(gdb) python import gdb; print gdb.block_for_pc(0x8048591).function.name
__lambda0::operator()() const
So that's at least three different names! So I think it's maybe a limitation of backtrace_symbols_fd
that it can't find names for the lambda functions.