issue examining pointer/array/record elements with GDB
Original Reporter info from Mantis: sethdgrover@gmail.com
-
Reporter name: Seth Grover
Original Reporter info from Mantis: sethdgrover@gmail.com
- Reporter name: Seth Grover
Description:
I believe FPC is creating invalid debug information for use with GDB in some cases involving records containing dynamic arrays of records.
Given this simple program:
=============================================
program project1;
{mode objfpc}{H+}
type
Record1 = record
a : integer;
b : integer;
end;
Record1Array = array of Record1;
Record2 = record
c : integer;
recs : Record1Array;
end;
PRecord2 = ^Record2;
var
myRec2 : PRecord2;
i : integer;
begin
new(myRec2);
myRec2^.c := 16;
SetLength(myRec2^.recs, myRec2^.c);
for i := 0 to myRec2^.c-1 do begin
myRec2^.recs[i].a := i;
myRec2^.recs[i].b := myRec2^.c - i - 1;
writeln(myRec2^.recs[i].a, ',', myRec2^.recs[i].b);
end;
dispose(myRec2);
end.
=============================================
If I compile this program with FPC 2.4.4 with debugging (-g), line
numbers in backtraces (-gl), and dwarf debug information (-gw), then
fire up GDB, put a breakpoint at the writeln, then run, observe what happens:
(gdb) print MYREC2^
$3 = {C = 16, RECS = 0x7ffff7fee050}
(gdb) print MYREC2^.RECS
$4 = (^RECORD1ARRAY) 0x7ffff7fee050
(gdb) print MYREC2^.RECS^[I]
$5 = {A = 0, B = 15}
(gdb) print MYREC2^.RECS^[I].A
Type RECORD1ARRAY is not a structure or union type.
GDB seems to be able to keep track of things find up to the point
where I try to access an element of the records which comprise the
array. I can print MYREC2^.RECS^[I] just fine, but not print
MYREC2^.RECS^[I].A.
Mantis conversion info:
- Mantis ID: 20225
- OS: Linux
- OS Build: Debian/Ubuntu
- Platform: i386 and x86_64
- Version: 2.4.4