* Re: Treatment of builtin that receives function pointer
[not found] ` <11b141711001280644j7e42ee6fib43a0c276f425e8@mail.gmail.com>
@ 2010-01-28 14:58 ` Andrew Haley
2010-01-28 16:03 ` Paulo J. Matos
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Haley @ 2010-01-28 14:58 UTC (permalink / raw)
To: gcc-help
On 01/28/2010 02:44 PM, Paulo J. Matos wrote:
> On Wed, Jan 27, 2010 at 12:25 PM, Paulo J. Matos <pocmatos@gmail.com> wrote:
>> Now, I wonder in this more general case, where can I obtain the
>> function decl (so I can get its assembler name) for the function the
>> pointer is pointing to?
>>
>
> Allow me to revive this question by asking if I can obtain the
> function assembler name given a direct function pointer to the
> function.
>
> For example:
> void foo1(void) {...}
>
> __get_name(foo1) ==> "foo1"
>
> int foo2(int *x) { ... }
>
> __get_name(foo2) ==> "foo2"
>
> This is all I need. Any tips?
dladdr()
Andrew.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Treatment of builtin that receives function pointer
2010-01-28 14:58 ` Treatment of builtin that receives function pointer Andrew Haley
@ 2010-01-28 16:03 ` Paulo J. Matos
0 siblings, 0 replies; 2+ messages in thread
From: Paulo J. Matos @ 2010-01-28 16:03 UTC (permalink / raw)
To: Andrew Haley; +Cc: gcc-help
On Thu, Jan 28, 2010 at 2:58 PM, Andrew Haley <aph@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.
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.
> Andrew.
>
--
Paulo Jorge Matos - pocmatos at gmail.com
http://www.pmatos.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-28 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <11b141711001270425j3f40d3a4p543806809ab41667@mail.gmail.com>
[not found] ` <11b141711001280644j7e42ee6fib43a0c276f425e8@mail.gmail.com>
2010-01-28 14:58 ` Treatment of builtin that receives function pointer Andrew Haley
2010-01-28 16:03 ` Paulo J. Matos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).