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

2012-08-07 Thread Martin
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. I

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

2012-08-07 Thread Rainer Stratmann
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

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

2012-08-07 Thread 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

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

2012-08-07 Thread Rainer Stratmann
Am Tuesday 07 August 2012 11:34:10 schrieb Martin: > > With all caller adresses OR all numbers (see down) I have the whole > > amount of snippets that I want to have. > > How? With the compiler keyword 'calleradresstable'; function s( str : pchar ) : pchar; calleradresstable; Then the compiler m

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

2012-08-07 Thread Martin
On 07/08/2012 08:22, Rainer Stratmann wrote: Am Tuesday 07 August 2012 00:02:02 schrieb Martin: I still do not understand what is so special about the caller address? Furthermore, you said yourself, you do not need it. You can also live withe a "number that the compiler generates at compilation

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

2012-08-07 Thread Rainer Stratmann
Am Tuesday 07 August 2012 00:02:02 schrieb Martin: > I still do not understand what is so special about the caller address? > Furthermore, you said yourself, you do not need it. You can also live > withe a "number that the compiler generates at compilation time". With all caller adresses OR all nu

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

2012-08-06 Thread Mark Morgan Lloyd
Rainer Stratmann wrote: All I need is all caller adresses of p1 in the program. You might be able to do that sort of thing by running the program with a profiler and analyzing all captured stacks. But it would be a vast amount of effort, and unless you could guarantee 100% coverage (i.e. fe

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

2012-08-06 Thread Martin
On 06/08/2012 22:46, Rainer Stratmann wrote: If the are: use the address of the first char in the snippet ? But then I do not have a list of all caller adresses of s() which I try to get. I still do not understand what is so special about the caller address? Furthermore, you said yourself, y

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

2012-08-06 Thread Sven Barth
On 06.08.2012 22:22, Marco van de Voort wrote: In our previous episode, Sven Barth said: The function returns the right language. Somehow this sounds like the GNU GetText function _() works. With the exception that the text which has to be translated is simply searched by looking through the s

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 23:36:10 schrieb Martin: > On 06/08/2012 21:57, Martin wrote: > > I am still trying to understand what exactly you try to archive. > > Ok, I read one of the other posts: Do you need to ensure to handle each > snippet only once? > > > Are *ALL* snippets constants? yes, but t

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 22:57:42 schrieb Martin: > On 06/08/2012 21:39, Rainer Stratmann wrote > > > Can you explain it more? > > I want not search through the sourcecode, because it makes it less easy. > > How does an address like $040012a help you find the source? If I have a list with all call

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

2012-08-06 Thread Martin
On 06/08/2012 21:57, Martin wrote: I am still trying to understand what exactly you try to archive. Ok, I read one of the other posts: Do you need to ensure to handle each snippet only once? Are *ALL* snippets constants? either const t1 = 'abc'; or foo('text') and NEVER result of - a

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 22:37:08 schrieb Aleksa Todorovic: > program test_str_36; > > uses > sysutils; > > function s(str: pchar): pchar; > var > str2: pchar; > begin > if str[0] = '~' then > begin > // string is not localized > str2 := strnew('numero'); // localized version >

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

2012-08-06 Thread Martin
On 06/08/2012 21:39, Rainer Stratmann wrote Can you explain it more? I want not search through the sourcecode, because it makes it less easy. How does an address like $040012a help you find the source? All I need is all caller adresses of p1 in the program. Or an incremented counter at compile

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 22:17:11 schrieb Martin: > But let me say: I am with everyone else. Using stack/caller info is the > wrong(est) way. I fully agree. > And if you need to ask "What is the content of the stack?" Then you > should not use it. > All this functions are very low level. Usinc this

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

2012-08-06 Thread Aleksa Todorovic
On Mon, Aug 6, 2012 at 9:48 PM, Rainer Stratmann wrote: > Am Monday 06 August 2012 21:26:24 schrieb Jonas Maebe: >> It doesn't work like that. Regular calls use relative offsets on most (if >> not all) architectures we support. And in some cases we generate >> position-independent code, so then yo

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

2012-08-06 Thread Marco van de Voort
In our previous episode, Sven Barth said: > > The function returns the right language. > > Somehow this sounds like the GNU GetText function _() works. With the > exception that the text which has to be translated is simply searched by > looking through the source code for _("some text")... Not

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

2012-08-06 Thread Martin
On 06/08/2012 20:18, Rainer Stratmann wrote: I do not understand this ... What is the content of the stack? Which file 'f'? Is it read from or write to file 'f'? f is just the STDOUT or logfile where the list of addresses is written to. You would likely use an array instead... But let me sa

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

2012-08-06 Thread Sven Barth
On 06.08.2012 21:48, Rainer Stratmann wrote: 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. I would not call your method "simple" It may is in the beginning more difficult to implement, but if it run

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 21:26:24 schrieb Jonas Maebe: > It doesn't work like that. Regular calls use relative offsets on most (if > not all) architectures we support. And in some cases we generate > position-independent code, so then you'll have look at GOT entries to > figure out the address. The

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

2012-08-06 Thread Jonas Maebe
On 06 Aug 2012, at 21:06, Rainer Stratmann wrote: > Am Monday 06 August 2012 20:12:41 schrieb Sven Barth: >> The >> 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 pr

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 21:18:20 schrieb Rainer Stratmann: > Am Monday 06 August 2012 20:15:53 schrieb Martin: > > I do not understand this ... > What is the content of the stack? > Which file 'f'? > Is it read from or write to file 'f'? Ok write to file 'f'. :-) But I still do not understand. __

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 20:15:53 schrieb Martin: > > You can probably reuse sone code from the system unit. > > below is a copy of dump_stack from fpc. It gets all the addresses > > > {$ifdef FPC_HAS_FEATURE_CONSOLEIO} > Procedure dump_stack(var f : text;bp : Pointer); > var >i : Longint; >

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

2012-08-06 Thread Rainer Stratmann
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. Byte :-) > The > problem now is that without knowing the cont

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

2012-08-06 Thread Martin
On 06/08/2012 18:28, Rainer Stratmann wrote: Am Monday 06 August 2012 18:43:04 schrieb Martin: How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. At run time, or design tim

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

2012-08-06 Thread Sven Barth
On 06.08.2012 19:56, Rainer Stratmann wrote: Am Monday 06 August 2012 19:34:23 schrieb Sven Barth: You know that scanning the binary code for calls is platform dependant? Yes. [calling opcode] [calleradress] calling opcode can differ and the byteorder of the adress can differ. The problem h

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 19:34:23 schrieb Sven Barth: > > You know that scanning the binary code for calls is platform dependant? Yes. [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

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

2012-08-06 Thread Sven Barth
On 06.08.2012 19:28, Rainer Stratmann wrote: Am Monday 06 August 2012 18:43:04 schrieb Martin: How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. At run time, or design ti

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

2012-08-06 Thread Rainer Stratmann
Am Monday 06 August 2012 18:43:04 schrieb Martin: > > How to get all caller adresses of p1 in a program before p1 is executed? > > > > For example p1 is called from 20 different places in a program. > > Then I need the 20 caller adresses. > > At run time, or design time? At runtime. I ment the (me

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

2012-08-06 Thread Martin
On 06/08/2012 15:26, Rainer Stratmann wrote: procedure p1; begin ... end; How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. At run time, or design time? at design t

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

2012-08-06 Thread Howard Page-Clark
On 06/8/12 3:26, Rainer Stratmann wrote: procedure p1; begin ... end; How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. if by address you mean line number, then use t

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

2012-08-06 Thread Rainer Stratmann
procedure p1; begin ... end; How to get all caller adresses of p1 in a program before p1 is executed? For example p1 is called from 20 different places in a program. Then I need the 20 caller adresses. ___ fpc-pascal maillist - fpc-pascal@lists.fre