Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-15 Thread Jonas Maebe

On 15 Mar 2010, at 14:13, Flávio Etrusco wrote:

> On Mon, Mar 15, 2010 at 7:31 AM, Jonas Maebe  
> wrote:
>> 
>> On 15 Mar 2010, at 11:12, Paul Ishenin wrote:
>> 
>>> 15.03.2010 17:01, Jonas Maebe wrote:
>>> 
 the only problem in that respect is that without the hacky
 patch mentioned earlier, GDB's Pascal parser does not support expressing
 method calls.
>>> 
>>> The remaining question for me is whether you will implement that hacky
>>> patch :) ?
>> 
>> It has to be fixed first so it is no longer hacky. I don't know when I will
>> have time for that.
> 
> Is it available somewhere?

I've attached pascalmethodcall.patch. It's against gdb cvs head from June last 
year, so it may no longer cleanly apply (but it's pretty small, so I don't 
expect many problems).

However, unless you declare your methods as cdecl, you're not going to be able 
to call them successfully.


Jonas


pascalmethodcall.patch
Description: Binary data
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-15 Thread Flávio Etrusco
On Mon, Mar 15, 2010 at 7:31 AM, Jonas Maebe  wrote:
>
> On 15 Mar 2010, at 11:12, Paul Ishenin wrote:
>
>> 15.03.2010 17:01, Jonas Maebe wrote:
>>
>>> the only problem in that respect is that without the hacky
>>> patch mentioned earlier, GDB's Pascal parser does not support expressing
>>> method calls.
>>
>> The remaining question for me is whether you will implement that hacky
>> patch :) ?
>
> It has to be fixed first so it is no longer hacky. I don't know when I will
> have time for that.
>
>
> Jonas

Is it available somewhere?

Best regards,
Flávio
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-15 Thread Jonas Maebe


On 15 Mar 2010, at 11:12, Paul Ishenin wrote:


15.03.2010 17:01, Jonas Maebe wrote:


the only problem in that respect is that without the hacky
patch mentioned earlier, GDB's Pascal parser does not support  
expressing

method calls.


The remaining question for me is whether you will implement that  
hacky patch :) ?


It has to be fixed first so it is no longer hacky. I don't know when I  
will have time for that.



Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-15 Thread Graeme Geldenhuys
Jonas Maebe het geskryf:
> 
> This explains http://bugs.freepascal.org/view.php?id=15691

I added that url as a note to the above bug report - so information is not
forgotten.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-15 Thread Paul Ishenin

15.03.2010 17:01, Jonas Maebe wrote:


the only problem in that respect is that without the hacky
patch mentioned earlier, GDB's Pascal parser does not support expressing
method calls.


The remaining question for me is whether you will implement that hacky 
patch :) ?


Best regards,
Paul Ishenin.


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-15 Thread Jonas Maebe


On 15 Mar 2010, at 07:49, Graeme Geldenhuys wrote:


And here is more information.

 http://docwiki.embarcadero.com/RADStudio/en/Program_Control


Thank you, that is the information that was needed:

"For a string, dynamic array, method pointer, or variant result, the  
effects are the same as if the function result were declared as an  
additional var parameter following the declared parameters. In other  
words, the caller passes an additional 32-bit pointer that points to a  
variable in which to return the function result."


This explains http://bugs.freepascal.org/view.php?id=15691


Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-15 Thread Jonas Maebe


On 15 Mar 2010, at 04:01, Paul Ishenin wrote:


12.03.2010 21:49, Jonas Maebe wrote:

The default calling convention could be used. This would only work  
for
routines with "simple" return types though (types that are not  
returned

via a hidden first parameter).


I don't think any/default calling convention have result return in  
EAX as fpc do.


All calling conventions on i386 (except for safecall) return "simple"  
results in eax.



Also for methods self needs to be passed.


That's true, but GDB already does that when calling a method,  
including for Pascal (the only problem in that respect is that without  
the hacky patch mentioned earlier, GDB's Pascal parser does not  
support expressing method calls).



Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-14 Thread Graeme Geldenhuys
Paul Ishenin het geskryf:
> 12.03.2010 23:51, Paul Ishenin wrote:
>>
>> If something more is required please let me know and I will search.
> Also found the next document with more info:
> http://www.agner.org/optimize/calling_conventions.pdf

And here is more information.


  http://docwiki.embarcadero.com/RADStudio/en/Program_Control



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-14 Thread Paul Ishenin

12.03.2010 21:49, Jonas Maebe wrote:


The default calling convention could be used. This would only work for
routines with "simple" return types though (types that are not returned
via a hidden first parameter).


I don't think any/default calling convention have result return in EAX 
as fpc do. Also for methods self needs to be passed.


But I believe you know this better than me.

Best regards,
Paul Ishenin.

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread dmitry boyarintsev
On Fri, Mar 12, 2010 at 10:04 PM, Jonas Maebe  wrote:
> Yes, but it is not the full documentation.

yep. I guess is the source for the the information give at wikipedia :)

Anyway, following Flávio's suggestion:
https://forums.embarcadero.com/thread.jspa?threadID=34211&stqc=true

thanks,
dmitry
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Jonas Maebe

On 12 Mar 2010, at 19:50, dmitry boyarintsev wrote:

> Quite official, i guess:
> http://docwiki.embarcadero.com/RADStudio/en/Fastcall,_fastcall

Yes, but it is not the full documentation.


Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread dmitry boyarintsev
On Fri, Mar 12, 2010 at 9:43 PM, Jonas Maebe  wrote:
>> Are they that cheap to
>> hold back such kind of information?
>
> I'm not aware of them being cheap in this or in other ways.


Quite official, i guess:
http://docwiki.embarcadero.com/RADStudio/en/Fastcall,_fastcall

thanks,
dmitry
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Jonas Maebe

On 12 Mar 2010, at 18:25, Flávio Etrusco wrote:

> Can't we ask someone from Borland/Embarcadero?

That's indeed a good idea, I don't think anyone has already done that.

> Are they that cheap to
> hold back such kind of information?

I'm not aware of them being cheap in this or in other ways.


Jonas___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Flávio Etrusco
On Fri, Mar 12, 2010 at 2:11 PM, Jonas Maebe  wrote:
>
> On 12 Mar 2010, at 17:59, Paul Ishenin wrote:
>
>> 12.03.2010 23:51, Paul Ishenin wrote:
>>>
>>> If something more is required please let me know and I will search.
>> Also found the next document with more info: 
>> http://www.agner.org/optimize/calling_conventions.pdf
>
> It describes what we implement currently ("In Borland and Gnu compilers and 
> in 64 bit Linux and BSD, the return pointer is the first parameter"), but 
> that does not seem to be correct according to the bug report mentioned 
> earlier in this thread (there the function result for function test2 is in 
> ecx instead of in eax for some reason).
>

Can't we ask someone from Borland/Embarcadero? Are they that cheap to
hold back such kind of information?

Best regards,
Flávio
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Jonas Maebe

On 12 Mar 2010, at 17:59, Paul Ishenin wrote:

> 12.03.2010 23:51, Paul Ishenin wrote:
>> 
>> If something more is required please let me know and I will search.
> Also found the next document with more info: 
> http://www.agner.org/optimize/calling_conventions.pdf

It describes what we implement currently ("In Borland and Gnu compilers and in 
64 bit Linux and BSD, the return pointer is the first parameter"), but that 
does not seem to be correct according to the bug report mentioned earlier in 
this thread (there the function result for function test2 is in ecx instead of 
in eax for some reason).


Jonas___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Paul Ishenin

12.03.2010 23:51, Paul Ishenin wrote:


If something more is required please let me know and I will search.
Also found the next document with more info: 
http://www.agner.org/optimize/calling_conventions.pdf


Best regards,
Paul Ishenin.


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Jonas Maebe

On 12 Mar 2010, at 17:51, Paul Ishenin wrote:

> 12.03.2010 21:55, Jonas Maebe wrote:
>> 
>> PS: one reason that this is not advancing is because FPC does not support it 
>> correctly either, and I don't want to add support for a broken 
>> implementation to GDB since then it has to be changed again later anyway. I 
>> also don't know of any description of the Borland fastcall calling 
>> convention, so it is currently not possible to properly fix this (not 
>> without guessing and probably breaking it again in yet some other case). See 
>> http://bugs.freepascal.org/view.php?id=15691
> What exactly needs to be known?

The exact rules. Partial descriptions are not useful, because we already have 
those and that's how the current implementation was done. For example, rules 
that explain where the hidden function result parameter goes (like in the bug 
report above), what the relative order of self parameter, vmt parameter and 
hidden function result are, ...

But as far as I know, there is no real description anywhere. Furthermore, 
unless someone creates an extensive test full of assembler routines that check 
whether the correct parameters are in the correct registers or stack locations, 
this functionality cannot be tested and every change can easily break something 
else without anyone noticing immediately (since the compiler itself will get 
the values from whichever register it passes them in).


Jonas___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Paul Ishenin

12.03.2010 21:55, Jonas Maebe wrote:


PS: one reason that this is not advancing is because FPC does not 
support it correctly either, and I don't want to add support for a 
broken implementation to GDB since then it has to be changed again 
later anyway. I also don't know of any description of the Borland 
fastcall calling convention, so it is currently not possible to 
properly fix this (not without guessing and probably breaking it again 
in yet some other case). See http://bugs.freepascal.org/view.php?id=15691

What exactly needs to be known?

I found the next description in the net:

Few first arguments of fastcall that fit into a processor's register 
(i.e. with a size up to 32 bits for x86 architecture) will be passed via 
registers instead of being put onto the stack. The remaining arguments 
are passed right-to-left on the stack (like in cdecl). Return values are 
passed through the AL, AX, or EAX register. The stack is usually 
callee-cleared unless the function takes a variable number of 
parameters. Most RTL functions, however, 
take a small number of parameters, so they don't have to clear the stack 
at all. *Borland* fastcall *convention* passes first THREE arguments via 
EAX, EDX, ECX;


If something more is required please let me know and I will search.

Best regards,
Paul Ishenin.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Fwd: [fpc-pascal] Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Jonas Maebe
Sorry, sent to the wrong list (Flavio: please reply to the list  
instead of to me personally)


Begin forwarded message:

From: Jonas Maebe 
Date: Fri 12 Mar 2010 16:44:30 GMT+01:00
To: FPC-Pascal users discussions 
Subject: [fpc-pascal] Re: [fpc-devel] properties with getter  
evaluation in gdb

Reply-To: FPC-Pascal users discussions 


On 12 Mar 2010, at 16:23, Flávio Etrusco wrote:

I only have a hack for b) currently, because it makes accessing  
fields
case-sensitive in GDB's Pascal mode (which means you have to type  
all fields

names in uppercase).


I don't get it, do you mean it's a hack because "set case-sensitive
off" doesn't work on it, is that it?


After that patch any field anywhere in GDB's Pascal mode becomes case  
sensitive (and because FPC stores all identifiers in uppercase, that  
means you have to use uppercase for all field names after that patch).



Jonas___
fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Jonas Maebe


On 12 Mar 2010, at 02:44, Paul Ishenin wrote:

1. gdb does not supports borland fastcall calling convention (delphi  
calls it register though)


PS: one reason that this is not advancing is because FPC does not  
support it correctly either, and I don't want to add support for a  
broken implementation to GDB since then it has to be changed again  
later anyway. I also don't know of any description of the Borland  
fastcall calling convention, so it is currently not possible to  
properly fix this (not without guessing and probably breaking it again  
in yet some other case). See http://bugs.freepascal.org/view.php?id=15691



Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Jonas Maebe


On 12 Mar 2010, at 02:44, Paul Ishenin wrote:

I know at the moment we have the next problems which cause subj  
don't work:


1. gdb does not supports borland fastcall calling convention (delphi  
calls it register though)
2. fpc does not write debug info for properties with getters because  
of point 1.


There's more:
a) DWARF debug information does not know the concept of properties  
(and I have not seen a proposal for adding it yet on the DWARF mailing  
list or website), only of fields and of methods (so you'd have to add  
these properties as methods -- in which case probably only getters can  
be supported)
b) there is no support yet in the GDB Pascal parser to call methods  
(at least not via instance.methodname; there may be other ways to call  
them, but I don't know how)


I only have a hack for b) currently, because it makes accessing fields  
case-sensitive in GDB's Pascal mode (which means you have to type all  
fields names in uppercase).



Let's see what properties getters we can have:
1. Majority of them are
 function GetSomething: SomeType;
2. Others are:
 function GetSomethingWithIndex(const Index1, ..., IndexN:  
SomeType): SomeType;


Looking at first type of functions I see that there are no arguments  
passed to the function. So maybe these functions could be marked  
with some other calling convention which is similar to fastcall  
regards result return? Maybe 'pascal' or 'stdcall' could be used for  
such functions?


The default calling convention could be used. This would only work for  
routines with "simple" return types though (types that are not  
returned via a hidden first parameter).



Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Paul Ishenin

12.03.2010 15:11, Michael Van Canneyt wrote:


You mean in the gdb info only, I hope ?

dwarf debug info.

Best regards,
Paul Ishenin.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] properties with getter evaluation in gdb

2010-03-12 Thread Michael Van Canneyt



On Fri, 12 Mar 2010, Paul Ishenin wrote:


Hello, FPC developers' list.

I know at the moment we have the next problems which cause subj don't work:

1. gdb does not supports borland fastcall calling convention (delphi calls it 
register though)
2. fpc does not write debug info for properties with getters because of point 
1.


Let's see what properties getters we can have:
1. Majority of them are
 function GetSomething: SomeType;
2. Others are:
 function GetSomethingWithIndex(const Index1, ..., IndexN: SomeType): 
SomeType;


Looking at first type of functions I see that there are no arguments passed 
to the function. So maybe these functions could be marked with some other 
calling convention which is similar to fastcall regards result return? Maybe 
'pascal' or 'stdcall' could be used for such functions?


You mean in the gdb info only, I hope ?

Michael.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel