Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-11

Type confusion in GDB?

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Coppens

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

Reply by email