[fpc-pascal] Get all caller adresses of a procedure/function
RainerStratmann at t-online.de
Mon Aug 6 19:56:52 CEST 2012
Am Monday 06 August 2012 19:34:23 schrieb Sven Barth:
> You know that scanning the binary code for calls is platform dependant?
[calling opcode] [calleradress]
calling opcode can differ and the byteorder of the adress can differ.
> So you'd need to write that code for every CPU you want to support. Also
> this is much harder to do for CISC CPUs like x86 than for RISC CPUs
> (ARM, MIPS, etc), because the former have variable length opcodes. So
> you'd basically need to write a full blown dissembler...
It seems hard. By now I support only 80x86 CPU's.
> Maybe it would be more interesting to know why you need this beforehand?
So you mean you can convince me to find another solution?
I need this for internationalisation.
p1( 'german snippet' );
is put in a table (caller adress and text) if calling the first time and
translated in other languages.
If I have a list of all p1's I know which language snippet was already called
and which snippet was not yet translated (called).
If there is a new snippet in the program and called at least one time it is
added to the "must be translated list".
Another method would be if it would be possible to inc a constant at compile
const counter = 0;
p1( [counter++](at compiletime!) , 'german snippet');
But this is an insurmountable obstacle for the compilerprogrammers I think.
More information about the fpc-pascal