[fpc-pascal] Get all caller adresses of a procedure/function
RainerStratmann at t-online.de
Mon Aug 6 21:06:54 CEST 2012
Am Monday 06 August 2012 20:12:41 schrieb Sven Barth:
> The problem here is the following:
> Let's suppose the opcode for calling a function on x86 CPUs is 0xCA11.
> Now you scan through the code looking for 0xCA11 followed by 4 bit.
> problem now is that without knowing the context of a found location
> 0xCA11 you don't know whether it is really a call opcode or some
> immediate data that was passed to some previous opcode. This is also an
> obstacle experienced by VM developers for x86 instructions (or CISC
> instructions in general). For RISC instruction sets this is less
> complex, but the problem exists there as well.
If I have the opcode 0xCA11 and the adress of p1 (suppose) 0x6EF7CAB0 then I
have 6 bytes (0xCA116EF7CAB0). That reduces drastically the possibility of
some immediate random data. I have to search byte by byte then for the 6
sequential bytes (48 Bits). :-)
> Out of curiosity: why don't you use resourcestrings?
It seems that is has not the flexibility and simplicity (in its entirety) that
I want. Also it depends on a unit as I see. With resourestring a have to give
every snippet a name. With my solution it is not necessary. The names are
automatically registered in a table (if called once).
> And why do you need the count of calls (or usages)?
I need the count of p1's to see if every snipped was already called by the
program. This is important when adding a new language or if the original text
Thers is a table with all snippets and a flag (*) if a snippet was already
called by the program.
4,6 and 8 was not called yet by the program.
But this I can only implement if it is possible to get the whole amount
(memoryadresses and/or counts) of p1 in the whole program.
More information about the fpc-pascal