Patch for pascal-dynamic arrays

Jonas Maebe jonas.maebe@elis.ugent.be
Sun May 16 21:49:00 GMT 2010


On 16 May 2010, at 19:23, Jan Kratochvil wrote:

> That's correct.  Both DW_AT_lower_bound and DW_AT_upper_bound express the
> boundaries inclusively.  Array of length 0 must have DW_AT_upper_bound equal
> to DW_AT_lower_bound minus one.

I've fixed this, thanks. I've also committed the patch to FPC svn.

> I am not sure where is a problem there but GDB handles non-pascal arrays of
> length zero right AFAIK.

Thanks to your patch, I can now successfully build the new gdb on SL54. In Pascal language mode, both empty arrays and strings are printed as '0x0'. That's probably an issue in the Pascal value printer. In C language mode (with the same binary), an empty string is (correctly) printed as '0x625418 ""', while an empty array is printed as just the address of the variable containing the pointer to the array (which looks a bit strange, but I guess it's consistent with how in C arrays and pointers are pretty much the same).

Array:

19	  setlength(a,8);
(gdb) set lang pascal
(gdb) ptype a
type = array [0..-1] of LongInt
(gdb) p a
$12 = 0x0
(gdb) set lang c
(gdb) ptype a
type = LongInt [0]
(gdb) p a
$13 = 0x625418
(gdb) n
20	  a[0]:=5;
(gdb) set lang pascal
(gdb) ptype a
type = array [0..7] of LongInt
(gdb) p a
$14 = {0, 0, 0, 0, 0, 0, 0, 0}
(gdb) set lang c
(gdb) ptype a
type = LongInt [8]
(gdb) p a
$15 = {0, 0, 0, 0, 0, 0, 0, 0}


String:

45	  setlength(s,8);
(gdb) set lang pascal
(gdb) ptype s
type = array [1..0] of Char
(gdb) p s
$16 = 0x0
(gdb) set lang c
(gdb) ptype s
type = Char [0]
(gdb) p s
$17 = 0x625428 ""
(gdb) n
46	  s[1]:=chr(5);
(gdb) set lang pascal
(gdb) ptype s
type = array [1..8] of Char
(gdb) p s
$18 = #0#0#0#0#0#0#0
(gdb) set lang c
(gdb) ptype s
type = Char [8]
(gdb) p s
$19 = "\000\000\000\000\000\000\000"


Jonas


More information about the Archer mailing list