Alon
Alon

Reputation: 1804

c++ symbols received from backtrace_symbols does not show function in g++

I'm trying to print a backtrace in code progrematically, compiling all my source with -g, as well as linking with it, and I also added fvisibility=internal.

but when I call the symbol list, all my code looks like:

module() [0x424b69]

why does the function name does not appear in the braces, what other possible flag should I add?

Thanks.

Upvotes: 2

Views: 2439

Answers (1)

user184968
user184968

Reputation:

You should use

-rdynamic

Something like:

g++ -g -rdynamic main.cpp

From http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html:

-rdynamic
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.

Upvotes: 6

Related Questions