[fpc-pascal] Type confusion in GDB?
John Coppens
john at jcoppens.com
Tue Nov 15 18:23:53 CET 2005
Hi all.
I was debugging a program and found that the contents of an 'array of
integer' was shown wrong... It took me quite a while to realize that GDB
was showing 32-bit integers, while the pascal program was using 16-bit
ones (at least think is happening):
Assign 1 to firstcol[0]:
(gdb) print firstcol
$27 = {1, 0 <repeats 19 times>}
Assign 81 to firstcol[1]:
(gdb) print firstcol
$28 = {5308417, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0}
(NOTE that here the 80 actually belongs to another variable (lastcol)).
Printing the array in hex gave me the clue:
$30 = {$510001, $0, $0, $0, $0, $0, $0, $0, $0, $0, $50, $0, $0, $0, $0,
$0, $0, $0, $0, $0}
The $51 is actually the 81...
I think the confusion comes from the fact that firstcol is defined as:
firstcol: array[1..nspecmax] of 1..ncolmax;
which is a range type, not recognized by GDB, and which is 16 bit (in
this case, could probably be even 8 bit).
This problem is not mentioned in the 'Caveats'...
Hope this is of some help.
John
More information about the fpc-pascal
mailing list