Macros giving problems with dladdr()
Posted
by Veger
on Stack Overflow
See other posts from Stack Overflow
or by Veger
Published on 2010-04-08T15:40:35Z
Indexed on
2010/04/08
15:43 UTC
Read the original article
Hit count: 136
I have implemented tracing behavior using the -finstrument-functions option of gcc and this (simplified) code:
void __cyg_profile_func_enter(void *this_fn, void *call_site)
{
Dl_info di;
if(dladdr(this_fn, &di))
printf("entered %s\n", (di.dli_sname?di_dli_sname:"<unknown>"));
}
This works great, except for one thing: macros are processed as well, but the function prints the information of the function which contains the macro.
So functions containing macros have their information printed multiple times (which is of course undesired).
Is there anything to detect that a macro is being processed? Or is is possible to turn off instrumenting macros at all?
PS Same problems occur with sizeof()
© Stack Overflow or respective owner