[fpc-pascal] Get all caller adresses of a procedure/function

Rainer Stratmann RainerStratmann at t-online.de
Tue Aug 7 19:25:40 CEST 2012


Am Tuesday 07 August 2012 19:13:29 schrieb Martin:
> On 07/08/2012 17:58, Rainer Stratmann wrote:
> > With the compiler keyword 'calleradresstable';
> >
> > function s( str : pchar ) : pchar; calleradresstable;
> >
> > Then the compiler makes a table of all calleradresses and also the amount
> > of s() in the program.
> > With the rtl function getcalleradresstable() then I get a pointer and the
> > amount of the array.
>
> Interesting. I couldn't find any documentation on them, and fpc 2.6.0
> does give an error.

That is my wish to a compiler programmer.
Can one hear me?
Who programs the compiler?

> But yes, with this added info, I can at least see what you try todo.
>
> >> I can see 2 ways you get that address
> >>
> >> procedure p (snip:string);
> >> begin
> >>     calleraddr := get_caller_addr(); //needs to be implemented
> >>     ......
> >> end
> >
> > It exists already:
> > http://www.freepascal.org/docs-html/rtl/system/get_caller_addr.html
>
> I knew there was something like it. But didnt have the name. So I gave a
> dummy name, and commented it.
>
> But now, I have another question:
>
> Despite calleradresstable not working for me, if it does for you, then
> what is the problem?
>
> Sure get_caller_addr() returns the "return address" so it will differ.
It returns a _unique_ handle. That is what I need.
Perhaps there will be some offset.
May be a compiler programmer can get the exact adresses and table for this 
wish.
> I do 
> not know haw big the offset can be at max. But unless you include a
> disassembler, or debug-line info, you can not get exact details. But likely
> you can assume a maximum offset (depending if calleradresstable is the asm
> or pascal statement address).



More information about the fpc-pascal mailing list