Arrays in debugger; No range errors on arrays

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Arrays in debugger; No range errors on arrays

Lance Boyle
Hi list,

I'm playing with FPC 2.0.0 on OS X 10.3.9 using Xcode 1.5. I run the
following little program...


program dumpmePascal;
    uses
      EmptyPlaceHolderUnit;

    var
       i : integer;
       topArray : array[10..13] of real;
       {debugger doesn't show this array at all--discussed previously
       on this list}

begin
    for i := 10 to 13 do     {OK}
       topArray[i] := sqr(i);
    for i := 10 to 13 do     {OK}
       writeln(topArray[i]);

    for i := 20 to 23 do     {OK too! No range error reported.}
       topArray[i] := sqr(i);
    for i := 20 to 23 do     {prints correct squares}
       writeln(topArray[i]);

    printstuff;
end.



unit EmptyPlaceHolderUnit;
interface
     procedure printstuff;

implementation

     procedure printstuff;
         var
         j : longint;
         anArray      : array[1..4] of real;
         {debuger shows anArray as 0..3, with incorrect value for
"anArray[0]"}
         anotherArray : array[21..24] of real;
         {debuger shows anotherArray as 0..3, with incorrect value for
all}
     begin
         for j := 1 to 4 do
             anArray[j] := 3 * j;
         for j := 1 to 4 do
             writeln(anArray[j]);

         anArray[205] := 12345.6789;     {No range error reported}
         writeln(anArray[205]);          {No range error reported}
         {Trying to write to anArray[206 and higher causes}
         {runtime error 216.}

         for j := 21 to 24 do            {OK}
             anotherArray[j] := 2 * j;
         for j := 21 to 24 do            {OK}
             writeln(anotherArray[j]);

         for j := 31 to 34 do
             anotherArray[j] := 2 * j;   {No range error reported}

         for j := 41 to 44 do
             writeln(anotherArray[j]);   {No range error reported}
     end;

end.


...and  get the following output:

[Session started at 2005-05-24 04:55:42 -0700.]
  1.00000000000000E+002
  1.21000000000000E+002
  1.44000000000000E+002
  1.69000000000000E+002
  4.00000000000000E+002
  4.41000000000000E+002
  4.84000000000000E+002
  5.29000000000000E+002
  3.00000000000000E+000
  6.00000000000000E+000
  9.00000000000000E+000
  1.20000000000000E+001
  1.23456789000000E+004
  4.20000000000000E+001
  4.40000000000000E+001
  4.60000000000000E+001
  4.80000000000000E+001
  0.00000000000000E+000
  4.94065645841247E-324
-4.28882459806687E-232
-3.51094486606932E-232

Executable “dumpmePascal” has exited with status 0.


As I've indicated in some of the comments, there appears to be some
range checking issues--is range checking off by default?

A second issue is that arrays that begin with any index other than 0
seem to be displayed incorrectly in the debugger window of Xcode.

Jerry

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

Jonas Maebe

On 24 mei 2005, at 13:58, Lance Boyle wrote:

> As I've indicated in some of the comments, there appears to be some
> range checking issues--is range checking off by default?

Yes, it is. Add {$r+} at the top of your source to turn it on, or add
"-Cr" to the command line options of the compiler.

> A second issue is that arrays that begin with any index other than 0
> seem to be displayed incorrectly in the debugger window of Xcode.

That's a problem of gdb not properly supporting Pascal arrays, which
indeed can start at an index <> 0. There is a set of patches to create
gdbpas, which may have this fixed, but I haven't built it for Mac OS X
yet (also, you'd probably have to overwrite the system's gdb with this
gdbpas for XCode to use it).


Jonas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

L505
In reply to this post by Lance Boyle
>From the mailing list:
http://www.nl.freepascal.org/lists/fpc-pascal/2003-October/006123.html

I read a bit about range checking there.

----- Original Message -----
From: "Lance Boyle"
As I've indicated in some of the comments, there appears to be some
range checking issues--is range checking off by default?

A second issue is that arrays that begin with any index other than 0
seem to be displayed incorrectly in the debugger window of Xcode.

Jerry

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

Lance Boyle
In reply to this post by Jonas Maebe

On May 24, 2005, at 5:31 AM, Jonas Maebe wrote:

>
> On 24 mei 2005, at 13:58, Lance Boyle wrote:
>
>> As I've indicated in some of the comments, there appears to be some
>> range checking issues--is range checking off by default?
>
> Yes, it is. Add {$r+} at the top of your source to turn it on, or add
> "-Cr" to the command line options of the compiler.

Thanks, Jonas.

Well--that's just lovely. How about getting this fixed? What other
surprises should I know about before using FPC?

Side comment--It's partly the Pascal-dialect problem that is driving me
to do most of my new programming in Ada (Ada = no dialects). For the
interested:
(Mac users: go to www.macada.org for GNAT, a free, gcc-based,
absolutely stunning Ada compiler that works with Xcode.)
(All: go to http://www.cs.nyu.edu/cs/faculty/schonber/gnat.html)
(To convert Pascal to Ada: Google p2ada)
(For a complete THINK Pascal library emulation in Ada, go to
http://www.chez.com/blady/creations.html#ada_thp).

>
>> A second issue is that arrays that begin with any index other than 0
>> seem to be displayed incorrectly in the debugger window of Xcode.
>
> That's a problem of gdb not properly supporting Pascal arrays, which
> indeed can start at an index <> 0. There is a set of patches to create
> gdbpas, which may have this fixed, but I haven't built it for Mac OS X
> yet (also, you'd probably have to overwrite the system's gdb with this
> gdbpas for XCode to use it).

I wonder if I would be able to specify gdbpas only when using FPC and
the regular gdb otherwise? (And the Ada-patched gdb for Ada 8^) ?

>
>
> Jonas
>


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

Lance Boyle
In reply to this post by L505

On May 24, 2005, at 1:00 PM, L505 wrote:

>> From the mailing list:
> http://www.nl.freepascal.org/lists/fpc-pascal/2003-October/006123.html
>
> I read a bit about range checking there.

Thanks--a good reference to what is apparently a long-standing problem.

>
> ----- Original Message -----
> From: "Lance Boyle"
> As I've indicated in some of the comments, there appears to be some
> range checking issues--is range checking off by default?
>
> A second issue is that arrays that begin with any index other than 0
> seem to be displayed incorrectly in the debugger window of Xcode.
>
> Jerry
>


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

Marco van de Voort
In reply to this post by Lance Boyle
> On May 24, 2005, at 5:31 AM, Jonas Maebe wrote:
> >> range checking issues--is range checking off by default?
> >
> > Yes, it is. Add {$r+} at the top of your source to turn it on, or add
> > "-Cr" to the command line options of the compiler.
>
> Thanks, Jonas.
>
> Well--that's just lovely. How about getting this fixed?

It's by design, since normal for Borland + compatibles.

> What other surprises should I know about before using FPC?

That depends on your mindset. I don't know enough about Ada, but since GNAT
is a gcc derivate, expect better compile speed with FPC :-)
 
> (All: go to http://www.cs.nyu.edu/cs/faculty/schonber/gnat.html)
> (To convert Pascal to Ada: Google p2ada)
> (For a complete THINK Pascal library emulation in Ada, go to
> http://www.chez.com/blady/creations.html#ada_thp).

More interesting would be the other way around.
 
> > That's a problem of gdb not properly supporting Pascal arrays, which
> > indeed can start at an index <> 0. There is a set of patches to create
> > gdbpas, which may have this fixed, but I haven't built it for Mac OS X
> > yet (also, you'd probably have to overwrite the system's gdb with this
> > gdbpas for XCode to use it).
>
> I wonder if I would be able to specify gdbpas only when using FPC and
> the regular gdb otherwise? (And the Ada-patched gdb for Ada 8^) ?

Well, maybe all non mainstream GDB users should gang up and try to get more
GDB support accepted. (I assume Ada can make arrays start at non zero too?)

However this is a significant amount of work. Pierre did this for a while,
which really bumped GDB usability with FPC.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

Lance Boyle

On May 24, 2005, at 11:31 PM, Marco van de Voort wrote:

>> On May 24, 2005, at 5:31 AM, Jonas Maebe wrote:
>>>> range checking issues--is range checking off by default?
>>>
>>> Yes, it is. Add {$r+} at the top of your source to turn it on, or add
>>> "-Cr" to the command line options of the compiler.
>>
>> Thanks, Jonas.
>>
>> Well--that's just lovely. How about getting this fixed?
>
> It's by design, since normal for Borland + compatibles.

Well, OK--at least there is a reason.

>
>> What other surprises should I know about before using FPC?
>
> That depends on your mindset. I don't know enough about Ada, but since
> GNAT
> is a gcc derivate, expect better compile speed with FPC :-)

True. But I still haven't played with the background compiling and
smart linking in Xcode.

>
>> (All: go to http://www.cs.nyu.edu/cs/faculty/schonber/gnat.html)
>> (To convert Pascal to Ada: Google p2ada)
>> (For a complete THINK Pascal library emulation in Ada, go to
>> http://www.chez.com/blady/creations.html#ada_thp).
>
> More interesting would be the other way around.
>
>>> That's a problem of gdb not properly supporting Pascal arrays, which
>>> indeed can start at an index <> 0. There is a set of patches to
>>> create
>>> gdbpas, which may have this fixed, but I haven't built it for Mac OS
>>> X
>>> yet (also, you'd probably have to overwrite the system's gdb with
>>> this
>>> gdbpas for XCode to use it).
>>
>> I wonder if I would be able to specify gdbpas only when using FPC and
>> the regular gdb otherwise? (And the Ada-patched gdb for Ada 8^) ?
>
> Well, maybe all non mainstream GDB users should gang up and try to get
> more
> GDB support accepted. (I assume Ada can make arrays start at non zero
> too?)

That's correct.
>
> However this is a significant amount of work. Pierre did this for a
> while,
> which really bumped GDB usability with FPC.
>


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

Florian Klämpfl
In reply to this post by Lance Boyle
Lance Boyle wrote:

> Well--that's just lovely. How about getting this fixed? What other
> surprises should I know about before using FPC?

I wonder how you can be suprised, it's perfectly documented:
http://www.freepascal.org/docs-html/prog/progsu46.html#x53-510001.1.46

If you didn't use a Borland compatible compiler before, reading the manual isn't
a bad idea.

>
> Side comment--It's partly the Pascal-dialect problem that is driving me
> to do most of my new programming in Ada (Ada = no dialects). For the
> interested:
> (Mac users: go to www.macada.org for GNAT, a free, gcc-based, absolutely
> stunning Ada compiler that works with Xcode.)
> (All: go to http://www.cs.nyu.edu/cs/faculty/schonber/gnat.html)
> (To convert Pascal to Ada: Google p2ada)
> (For a complete THINK Pascal library emulation in Ada, go to
> http://www.chez.com/blady/creations.html#ada_thp).

I guess this is a pascal list here and no ada advertisement list?


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Arrays in debugger; No range errors on arrays

L505

| I guess this is a pascal list here and no ada advertisement list?
|

no, n'ada ada ada-vertisement list
(sorry, could n'ada resisted.)

I was looking into ada the other day on some wikis, though. Have to check deeper into
its origins.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Loading...