From Bugzilla Helper: User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.2-2 i686) Description of problem: In our software product the function backtrace_symbols() is used in signal handlers to find out where some error raised. In glibc 2.2.2 the output of backtrace_symbols() and backtrace_symbols_fd() seems to be broken. How reproducible: Always Steps to Reproduce: 1. compile the following coding and execute it #include <execinfo.h> void showStack() { void * array [1024]; backtrace_symbols_fd(array, backtrace(array, sizeof(array)/sizeof(array[0])), 1); } void b() { showStack(); } void a() { b(); } int main() { a(); return 0; } 2. The output looks like this: ./a.out(backtrace_symbols_fd+0x133)[0x80484df] ./a.out(backtrace_symbols_fd+0x157)[0x8048503] ./a.out(backtrace_symbols_fd+0x167)[0x8048513] ./a.out(backtrace_symbols_fd+0x177)[0x8048523] /lib/i686/libc.so.6(__libc_start_main+0x93)[0x40041177] ./a.out(backtrace_symbols_fd+0x35)[0x80483e1] 3. The output should look like this: ./a.out(showStack+0x??)[0x80484df] ./a.out(b+0x??)[0x8048503] ./a.out(a+0x??)[0x8048513] ./a.out(main+0x??)[0x8048523] /lib/i686/libc.so.6(__libc_start_main+0x93)[0x40041177] It's really a pity not to get the function names because it makes debugging of large programs much easier.
backtrace_symbols does not use debugging info nor symbol table, that's what debuggers are for. backtrace_symbols uses information from the dynamic symbol table, so if a function is not in dynamic symbol table, it cannot show up in the backtrace listing. Unless you play with symbol versioning or symbol visibility, all non-static functions make it into the dynamic symbol table for shared libraries, for binaries you have to request that explicitely. -Wl,--export-dynamic will do the job (tested on your example).