Calling dladdr() doesn't give symbols in the main executable...why?
George T. Talbot
george@moberg.com
Wed Jun 7 17:04:00 GMT 2000
I've been using the following sequence to try to instrument some code I'm
writing:
void some_tracked_function()
{
void* rv = __builtin_return_address(0);
Dl_info info;
if (dladdr(rv, &info))
{
logfile << "some_tracked_function() called by " << info.dli_sname << endl;
}
else
logfile << "some_tracked_function() called by unknown caller." << endl;
...
}
If I call some_tracked_function() from a shared library (.so) that my program
is linked against, the first message, containing the function name, will be
printed. If I call it from the main program (the executeable with main() in
it), then it prints the second message without the function name.
I really really would like it to print the first message at all times.
I tried linking with -rdynamic and -Wl,--export-dynamic, but that didn't help.
I'm using gcc 2.95.2, and my ld.so is 1.9.5 on a Mandrake 7.0 distribution.
Any ideas?
--
George T. Talbot
<george at moberg dot com>
More information about the Gcc-help
mailing list