
On 03/03/13 10:54, Artyom Beilis wrote:
You can also utilize function like backtrace_symbols. AFAIR not every platform has dladdr (Solaris if I recall correctly)
backtrace_symbols uses dladdr, and dladdr requires to link with -ldl, and is very limited in terms of what it sees. Also no debugging information is available. The best way to get a list of symbols on Linux is unfortunately to extract the information from the executable and shared library binaries, as libbfd does. I think the right approach is to separate the backtrace proper (list of addresses) from the mapping to names. Therefore 'backtrace' should be used, but not 'backtrace_symbols'. 'backtrace_symbols' is pretty bad anyway, you can do something better by calling dladdr manually. (Solaris, and any other operating system with ELF shared object support, supports dladdr)
Generally it is very interesting topic and very useful stuff (from my experience in deploy with CppCMS).
While it is interesting, I have not found it to be that useful in practice. The debugger already does all of this better that you could ever do yourself. It is probably a better idea to integrate your app with a debugger than to rewrite a debugger inside your app.