On 01/28/2010 04:01 PM, Paulo J. Matos wrote: > On Thu, Jan 28, 2010 at 2:58 PM, Andrew Haley <a...@redhat.com> wrote: >> >> dladdr() >> > > Thanks Andrew but this answer seems to assume I am trying to obtain > this in a C program from a previously compiled function. > > However, I am inside GCC which access to the gimple tree of the function.
Ah, okay. Sorry. > I found out the problem I was having but not the solution yet. > My builtin function gets angry when given a function pointer which is > not (void) (*)(void). As a result, it casts the function. > So something like: > void foo(int) { } > .. > __mybuiltin(foo); > > becomes internally: > void foo(int) { } > .. > (void) (foo.0) (void) = ((void) (*)(void) foo); > __mybuiltin(foo.0); > > This is why I am not being able to get my function name from the tree > of the builtin function call. I guess I need to parse the tree of the > current function to find the value of foo.0. > > I am however open to suggestions. You have a tree node of type function pointer, and you want somehow to convert that into the function decl that the pointer points to. Obviously in the general case this is quite impossible, but you want to do enough copy propagation to get the original function decl. This should be easy enough as long as you don't need to do anything too complicated. Andrew.