Anyone know some reasonably portable way to determine the return address of a function?
George T. Talbot
george@moberg.com
Tue Jun 6 15:47:00 GMT 2000
I'm working on some library code in Linux, and, for debugging purposes, I'd
like to be able to call dlinfo() on the return address of a function in my
library so that I can track usage of the function:
#define magic() ...woudln't I like to know...
void some_library_function(void)
{
void* return_address = magic();
Dl_info info;
if (dlinfo(return_address, &info))
fprintf(some_log_file, "some_library_function() called from %s in executable
%s.\n",
info.dli_sname, info.dli_fname);
else
fprintf(some_log_file, "some_library_function() called from unknown
caller.\n");
...do the actual work...
}
-----
void some_code(void)
{
...
some_library_function();
...
}
In other words, I want magic() above to return the address in some_code()
where some_library_function() was called.
Please cc: me if you post a reply to the list, in case I miss your reply.
--
George T. Talbot
<george at moberg dot com>
More information about the Gdb
mailing list