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

Martin lazarus at mfriebe.de
Tue Aug 7 19:46:20 CEST 2012

On 07/08/2012 18:25, Rainer Stratmann wrote:
> Am Tuesday 07 August 2012 19:13:29 schrieb Martin:
>> On 07/08/2012 17:58, Rainer Stratmann wrote:
>>> function s( str : pchar ) : pchar; calleradresstable;
>>> Then the compiler makes a table of all calleradresses and also the amount
>>> of s() in the program.
>> 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?

>> 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.

You seem to throw to issues together again. the unique handle issue is 
solvable without this. This is only needed to get a complete list of 

I got the feeling, that this feature may not happen (but I have no 
knowledge). I do not eve know if it can be done, since the compiler does 
not even know the entire list of all callers. That is the linker. and 
the linker is platform dependent, and at least on some platforms not 
part of fpc  (At least as far as I know).

Anyway: lets get pack to your problem.

You need a list of all snippets (or a list of IDs that can be mapped 1 
to 1 to the snippets).

I haven't got the solution....

But I can suggest 2 topics for investigations

1) Resourcestrings.

You do not need to use the po attempt. BUt I would EXPECT that it is 
possible (and you can write your own code for that) to get a list of all 
resource strings in the app. So there would be the table you need.

The IDE can help you to create resourestrings from the constants in the 
code (though it is a bit of work)

2) The new extended RTTI? I have no idea. I do not even know how ready 
it is. It may not apply at all.... BUt you could ask around

3) Write your own pre-processor

More information about the fpc-pascal mailing list