[fpc-devel] alignment warnings

2011-09-30 Thread Henry Vermaak

Hi list

Thinking more about the alignment problems on arm and elsewhere, I was 
wondering how hard it would be to implement something like gcc's 
-Wcast-align.  Here's a description from the man page:


Warn whenever a pointer is cast such that the required alignment of the 
target is increased.  For example, warn if a "char *" is cast to an "int 
*" on machines where integers can only be accessed at two- or four-byte 
boundaries.


This would really help to catch problematic code before things get out 
of hand and you have to wait for segfault/sigbus before you know where 
the problems are.


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


Re: [fpc-devel] alignment warnings

2011-09-30 Thread Martin

On 30/09/2011 10:44, Henry Vermaak wrote:

Hi list

Thinking more about the alignment problems on arm and elsewhere, I was 
wondering how hard it would be to implement something like gcc's 
-Wcast-align.  Here's a description from the man page:


Warn whenever a pointer is cast such that the required alignment of 
the target is increased.  For example, warn if a "char *" is cast to 
an "int *" on machines where integers can only be accessed at two- or 
four-byte boundaries.


Why limit it to "on machines where ... can only be accessed at ... 
boundaries".
If code is written for multiply platforms, then the implementor may be 
on a machine where the cast is allowed, and needs no warning, but soon 
as the code is compiled on a different architecture, the warnings come up.
It would be good, if one could also enable warnings for code, that may 
have issues on other platforms

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


Re: [fpc-devel] alignment warnings

2011-09-30 Thread Henry Vermaak

On 30/09/11 10:52, Martin wrote:

On 30/09/2011 10:44, Henry Vermaak wrote:

Hi list

Thinking more about the alignment problems on arm and elsewhere, I was
wondering how hard it would be to implement something like gcc's
-Wcast-align. Here's a description from the man page:

Warn whenever a pointer is cast such that the required alignment of
the target is increased. For example, warn if a "char *" is cast to an
"int *" on machines where integers can only be accessed at two- or
four-byte boundaries.


Why limit it to "on machines where ... can only be accessed at ...
boundaries".
If code is written for multiply platforms, then the implementor may be
on a machine where the cast is allowed, and needs no warning, but soon
as the code is compiled on a different architecture, the warnings come up.
It would be good, if one could also enable warnings for code, that may
have issues on other platforms


Because you may be writing code that's specific to a platform?  I guess 
you can have another option that will warn on all machines.


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


Re: [fpc-devel] alignment warnings

2011-09-30 Thread Mark Morgan Lloyd

Henry Vermaak wrote:

On 30/09/11 10:52, Martin wrote:

On 30/09/2011 10:44, Henry Vermaak wrote:

Hi list

Thinking more about the alignment problems on arm and elsewhere, I was
wondering how hard it would be to implement something like gcc's
-Wcast-align. Here's a description from the man page:

Warn whenever a pointer is cast such that the required alignment of
the target is increased. For example, warn if a "char *" is cast to an
"int *" on machines where integers can only be accessed at two- or
four-byte boundaries.


Why limit it to "on machines where ... can only be accessed at ...
boundaries".
If code is written for multiply platforms, then the implementor may be
on a machine where the cast is allowed, and needs no warning, but soon
as the code is compiled on a different architecture, the warnings come 
up.

It would be good, if one could also enable warnings for code, that may
have issues on other platforms


Because you may be writing code that's specific to a platform?  I guess 
you can have another option that will warn on all machines.


I think we need to take into account the particular case of ARM, where 
some implementations are stricter than others but there's no 
indication/test in the ABI or loader.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] New Windows gdb-binary

2011-09-30 Thread Joost van der Sluis
Hi all,

For all those who are interested in new debug-features of fpc and gdb, I
have cross-compiled a gdb-executable for Windows.

It's based on the Fedora-16 branch from the Archer project. But I added
a few patches of my own, namely the patch to recognize methods, setting
case-sensitivity off by default and a patch to allow evaluating
method-values (without actually calling them.)

With this gdb-version you can:
- Print strings properly, this means that indexes are evaluated properly
and strings can contain #0 characters (when compiled with -gw3)
- Dynamic array are evaluated properly (when compiled with -gw3)
- Case of identifiers are preserved (when compiled with -gw3)
- It is possible to identify class-methods (fpc 2.7.1 only)
- It is possible to call simple class-methods (fpc 2.7.1 only. Some
problems on i386 regarding the calling conventions remain, and there
seems to be some problems still with overridden functions)

Please test this gdb-version, and tell me about your experiences.
Especially Martin. ;)

Oh, you can download it here:
http://www.lazarussupport.com/gdb_lazarssupport_20110930.zip

Joost
-- 
My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog

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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Leonardo M . Ramé
>
>From: Joost van der Sluis 
>To: fpc-devel@lists.freepascal.org
>Sent: Friday, September 30, 2011 10:02 AM
>Subject: [fpc-devel] New Windows gdb-binary
>
>Hi all,
>
>For all those who are interested in new debug-features of fpc and gdb, I
>have cross-compiled a gdb-executable for Windows.
>
>It's based on the Fedora-16 branch from the Archer project. But I added
>a few patches of my own, namely the patch to recognize methods, setting
>case-sensitivity off by default and a patch to allow evaluating
>method-values (without actually calling them.)
>
>With this gdb-version you can:
>- Print strings properly, this means that indexes are evaluated properly
>and strings can contain #0 characters (when compiled with -gw3)
>- Dynamic array are evaluated properly (when compiled with -gw3)
>- Case of identifiers are preserved (when compiled with -gw3)
>- It is possible to identify class-methods (fpc 2.7.1 only)
>- It is possible to call simple class-methods (fpc 2.7.1 only. Some
>problems on i386 regarding the calling conventions remain, and there
>seems to be some problems still with overridden functions)
>
>Please test this gdb-version, and tell me about your experiences.
>Especially Martin. ;)
>
>Oh, you can download it here:
>http://www.lazarussupport.com/gdb_lazarssupport_20110930.zip
>
>Joost
>-- 
>My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog
>
>___
>fpc-devel maillist  -  fpc-devel@lists.freepascal.org
>http://lists.freepascal.org/mailman/listinfo/fpc-devel
>
>
>

Looks impressive. I'll start testing right now.


Leonardo M. Ramé
http://leonardorame.blogspot.com

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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Martin

On 30/09/2011 14:02, Joost van der Sluis wrote:

Hi all,

For all those who are interested in new debug-features of fpc and gdb, I
have cross-compiled a gdb-executable for Windows.

It's based on the Fedora-16 branch from the Archer project. But I added
a few patches of my own, namely the patch to recognize methods, setting
case-sensitivity off by default and a patch to allow evaluating
method-values (without actually calling them.)

Ah, how does that work?



With this gdb-version you can:
- Print strings properly, this means that indexes are evaluated properly
and strings can contain #0 characters (when compiled with -gw3)
- Dynamic array are evaluated properly (when compiled with -gw3)
- Case of identifiers are preserved (when compiled with -gw3)
- It is possible to identify class-methods (fpc 2.7.1 only)
- It is possible to call simple class-methods (fpc 2.7.1 only. Some
problems on i386 regarding the calling conventions remain, and there
seems to be some problems still with overridden functions)

Please test this gdb-version, and tell me about your experiences.
Especially Martin. ;)


Will do (weekend just ahead, what a coincidence... :) )


Oh, you can download it here:
http://www.lazarussupport.com/gdb_lazarssupport_20110930.zip

Joost


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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Paul Ishenin

30.09.2011 21:02, Joost van der Sluis wrote:

Hi all,

For all those who are interested in new debug-features of fpc and gdb, I
have cross-compiled a gdb-executable for Windows.

It's based on the Fedora-16 branch from the Archer project. But I added
a few patches of my own, namely the patch to recognize methods, setting
case-sensitivity off by default and a patch to allow evaluating
method-values (without actually calling them.)

How can this be possible? Some internal virtual machine?

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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Joost van der Sluis
On Fri, 2011-09-30 at 21:47 +0800, Paul Ishenin wrote:
> 30.09.2011 21:02, Joost van der Sluis wrote:
> > Hi all,
> >
> > For all those who are interested in new debug-features of fpc and gdb, I
> > have cross-compiled a gdb-executable for Windows.
> >
> > It's based on the Fedora-16 branch from the Archer project. But I added
> > a few patches of my own, namely the patch to recognize methods, setting
> > case-sensitivity off by default and a patch to allow evaluating
> > method-values (without actually calling them.)
> How can this be possible? Some internal virtual machine?

Huh? The compilation of the Fedora-gdb-sources for Windows? Fedora comes
with an out-of-the-box mingw cross-compiler. (Not really a vm)

yum install mingw32-gcc mingw32-binutils mingw32-w32api
get gdb sources through git (Archer)
./configure --host=i686-pc-mingw32 --disable-werror
make

Wait and copy gdb/gdb.exe to a Windows machine to test. For this to work
you need to have all other gdb build-dependencies installed on your
machine, ofcourse.

Joost

-- 
My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog


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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Tomas Hajny
On Fri, September 30, 2011 16:45, Joost van der Sluis wrote:
> On Fri, 2011-09-30 at 21:47 +0800, Paul Ishenin wrote:
>> 30.09.2011 21:02, Joost van der Sluis wrote:
 .
 .
>> > case-sensitivity off by default and a patch to allow evaluating
>> > method-values (without actually calling them.)
>> How can this be possible? Some internal virtual machine?
>
> Huh? The compilation of the Fedora-gdb-sources for Windows? Fedora comes
> with an out-of-the-box mingw cross-compiler. (Not really a vm)
 .
 .

I suppose that Paul wondered about "evaluating method values without
actually calling them"...

Tomas


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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Martin

On 30/09/2011 15:45, Joost van der Sluis wrote:

On Fri, 2011-09-30 at 21:47 +0800, Paul Ishenin wrote:

30.09.2011 21:02, Joost van der Sluis wrote:

Hi all,

For all those who are interested in new debug-features of fpc and gdb, I
have cross-compiled a gdb-executable for Windows.

It's based on the Fedora-16 branch from the Archer project. But I added
a few patches of my own, namely the patch to recognize methods, setting
case-sensitivity off by default and a patch to allow evaluating
method-values (without actually calling them.)

How can this be possible? Some internal virtual machine?

Huh? The compilation of the Fedora-gdb-sources for Windows? Fedora comes
with an out-of-the-box mingw cross-compiler. (Not really a vm)



I think this was about:

evaluating
method-values (without actually calling them.)


which got me curious too.

Now reading it again, does it mean:
1) gdb can (magically?) get the return value of a function/method, but 
WITHOUT calling/invoking the function (e.g. for properties)
2) gdb can "evaluate" the type of a method. e.g return "ptype 
Tfoo.Method" = "function(a:int): boolean"



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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Joost van der Sluis
On Fri, 2011-09-30 at 15:54 +0100, Martin wrote:
> On 30/09/2011 15:45, Joost van der Sluis wrote:
> > On Fri, 2011-09-30 at 21:47 +0800, Paul Ishenin wrote:
> >> 30.09.2011 21:02, Joost van der Sluis wrote:
> >>> Hi all,
> >>>
> >>> For all those who are interested in new debug-features of fpc and gdb, I
> >>> have cross-compiled a gdb-executable for Windows.
> >>>
> >>> It's based on the Fedora-16 branch from the Archer project. But I added
> >>> a few patches of my own, namely the patch to recognize methods, setting
> >>> case-sensitivity off by default and a patch to allow evaluating
> >>> method-values (without actually calling them.)
> >> How can this be possible? Some internal virtual machine?
> > Huh? The compilation of the Fedora-gdb-sources for Windows? Fedora comes
> > with an out-of-the-box mingw cross-compiler. (Not really a vm)
> >
> 
> I think this was about:
> > evaluating
> > method-values (without actually calling them.)
> 
> which got me curious too.

It's nothing important. It's just a very small bug in gdb that got
fixed.

> Now reading it again, does it mean:
> 1) gdb can (magically?) get the return value of a function/method, but 
> WITHOUT calling/invoking the function (e.g. for properties)
> 2) gdb can "evaluate" the type of a method. e.g return "ptype 
> Tfoo.Method" = "function(a:int): boolean"

The second. When you do 'p functionname' you get some background
information about the function. When you do 'p functionname()' it will
call the function.
This didn't work for methods, so 'p class.methodname()' did work while
'p class.methodname' didn't. That's what's fixed.

The (simple) patch is attached.

But what we could do now is write debuginfo for properties with getters
as if it is a function. The answer of 'p class.propertyname' will tell
you it's a function, which yould be called if you want to.


Joost
-- 
My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index d98b3a4..9d14a9e 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -391,6 +391,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
   break;
 
 case TYPE_CODE_FUNC:
+case TYPE_CODE_METHOD:
   if (options->format)
 	{
 	  val_print_scalar_formatted (type, valaddr, embedded_offset,
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Martin

On 30/09/2011 16:22, Joost van der Sluis wrote:

On Fri, 2011-09-30 at 15:54 +0100, Martin wrote:

Now reading it again, does it mean:
1) gdb can (magically?) get the return value of a function/method, but
WITHOUT calling/invoking the function (e.g. for properties)
2) gdb can "evaluate" the type of a method. e.g return "ptype
Tfoo.Method" = "function(a:int): boolean"

The second. When you do 'p functionname' you get some background
information about the function. When you do 'p functionname()' it will
call the function.


Yep, that's what I figured. Initially I though 1 (and I thought, how?)


This didn't work for methods, so 'p class.methodname()' did work while
'p class.methodname' didn't. That's what's fixed.

The (simple) patch is attached.

But what we could do now is write debuginfo for properties with getters
as if it is a function. The answer of 'p class.propertyname' will tell
you it's a function, which yould be called if you want to.




Yep, I need to improve the IDE to detect functions in expressions, and 
enable/disable execution, depend on user settings (rather than letting 
the user type the ()



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


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Martin

On 30/09/2011 14:02, Joost van der Sluis wrote:

Please test this gdb-version, and tell me about your experiences.
Especially Martin. ;)

Oh, you can download it here:
http://www.lazarussupport.com/gdb_lazarssupport_20110930.zip




It crashes when -Xe (external linker) was used. Also crashes with stabs...

I am not 100% sure, but it appears to choke on
-data-evaluate-expression FPC_THREADVAR_RELOCATE_PROC
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] New Windows gdb-binary

2011-09-30 Thread Martin

On 30/09/2011 23:23, Martin wrote:

On 30/09/2011 14:02, Joost van der Sluis wrote:

Please test this gdb-version, and tell me about your experiences.
Especially Martin. ;)

Oh, you can download it here:
http://www.lazarussupport.com/gdb_lazarssupport_20110930.zip




It crashes when -Xe (external linker) was used. Also crashes with 
stabs...


I am not 100% sure, but it appears to choke on
-data-evaluate-expression FPC_THREADVAR_RELOCATE_PROC


Ok, seems to have big issues with strings in fields.

Run the ExceptionPrg from  debugger\test\Gdbmi\TestApps\ExceptPrg.lpr in 
lazarus.

On hitting the breakpoint in fpc_raise_exception:

>> TCmdLineDebugger.SendCmdLn "x/s Exception($eax).FMessage"
<< TCmdLineDebugger.ReadLn "&"x/s Exception($eax).FMessage\n""
<< TCmdLineDebugger.ReadLn "&"Cannot resolve DW_OP_push_object_address 
for a missing object\n""


if you keep the session running, and set the stackframe to 
fpc_raise_exception (the IDE will have lowered it), then you can send 
the following commands:



&"p Exception($eax)\n"
~"$2 = (^Exception = class ) 0x78660\n"
^done
(gdb)

&"p Exception($eax)^\n"
~"$3 = { = {_vptr$TOBJECT = 0x415018}, fmessage = 'abc'"
~", fhelpcontext = 0"
~", HelpContext = 0"
~", Message = 'abc'"
~"}"
~"\n"
^done
(gdb)

&"p Exception($eax).Message\n"
&"Cannot access memory at address 0x636260ff\n"
^error,msg="Cannot access memory at address 0x636260ff"
(gdb)

&"p Exception($eax).FMessage\n"
&"Cannot access memory at address 0x636260ff\n"
^error,msg="Cannot access memory at address 0x636260ff"
(gdb)

&"p Exception($eax)^.FMessage\n"
&"Cannot access memory at address 0x636260ff\n"
^error,msg="Cannot access memory at address 0x636260ff"
(gdb)



--

In an other attempt, using this program:

program Project1;

{$mode objfpc}{$H+}
type
  TFoo=class
  private
FText:string;
  end;

var
  a: TFoo;

begin
  a := TFoo.Create;
  a.FText := 'abcde';
  writeln(1);
  readln;
end.

sending to the debugger (without the <>)


&"p a\n"
~"$1 = 0x107488\n"
^done
(gdb)

&"p a^\n"
~"$2 = { = {_vptr$TOBJECT = 0x40e018}, FText = 'abcde'"
~"}"
~"\n"
^done
(gdb)

&"p a.FText\n"
~"$3 = 'abcde'"
~"\n"

the text is correct => but gdb crashes at this point.

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