Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    backtrace_symbols() with no symbols!


    I am using backtrace(...) and backtrace_symbols(...) (defined in <execinfo.h>) in a C++ program for diagnostics purposes. I compile with -g passed to G++ and link with the --rdynamic option, but backtrace_symbols(...) just gives me this sort of output:

    ./app [0x804c6c6]
    ./app [0x8049405]
    ./app [0x8049413]
    ./app [0x8049437]
    /lib/tls/ [0xbdbe33]
    ./app(__gxx_personality_v0+0x61) [0x8048ff1]

    I know g++ is likely to give me mangled symbols, but that is better than nothing! What do I need to do to compile symbol information backtrace_symbols(...) can use into the program?



  2. #2


    I had this problem, and I believe if you add "-rdynamic" during linkage, then backtrace_symbols() will get the function names. From the gcc manual:

    Pass the flag -export-dynamic to the ELF linker, on targets that support it. This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. This option is needed for some uses of "dlopen" or to allow obtaining backtraces from within a program.

  3. #3

    Remove static qualifiers on function declarations

    Also, static functions are anonymized during compilation, so it's necessary to remove or comment out any static qualifiers for their names to be available. From the backtrace_symbols(3) man page:
    The symbol names may be unavailable without the use of special linker
    options. For systems using the GNU linker, it is necessary to use the
    -rdynamic linker option. Note that names of "static" functions are not
    exposed, and won’t be available in the backtrace.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts