[fpc-pascal] Get all caller adresses of a procedure/function
lazarus at mfriebe.de
Tue Aug 7 19:13:29 CEST 2012
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.
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);
>> calleraddr := get_caller_addr(); //needs to be implemented
> It exists already:
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. 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