This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Calling dladdr() doesn't give symbols in the main executable...why?


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>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]