Debugger symbol table fix

const structs are wrapped in definedType.  The debugger symbol table code is unaware of this, which results in missing or incomplete entries.

example:

const struct { int a; int b; } cs;

cs:  isForwardDeclared =    false; class = ident
    4 byte constant defined type of
    4 byte struct: 223978

const struct { int a; int b; } *pcs;

pcs:  isForwardDeclared =    false; class = ident
    4 byte  pointer to
    4 byte constant defined type of
    4 byte struct: 224145

const struct { const struct { const int a; } a[2]; } csa[5];

csa:  isForwardDeclared =    false; class = ident
    20 byte 5 element array of
    4 byte constant defined type of
    4 byte struct: 225155

const struct { const struct { const int a; } a[2]; } *cspa[5];

cspa:  isForwardDeclared =    false; class = ident
    20 byte 5 element array of
    4 byte  pointer to
    4 byte constant defined type of
    4 byte struct: 224850

This change unwraps the definedType so the underlying type info can be placed in the debugger symbol table.
This commit is contained in:
Kelvin Sherlock 2019-01-13 21:11:00 -05:00
parent cfa3e4e02d
commit 6bd600157d

View File

@ -875,6 +875,7 @@ var
var var
disp: integer; {disp to symbol of same type} disp: integer; {disp to symbol of same type}
tPtr: typePtr;
procedure WriteAddress (ip: identPtr); procedure WriteAddress (ip: identPtr);
@ -979,8 +980,11 @@ var
{ subscripts - number of subscript fields } { subscripts - number of subscript fields }
begin {WritePointerType} begin {WritePointerType}
case tp^.ptype^.kind of tp := tp^.ptype;
scalarType: WriteScalarType(tp^.ptype, $80, subscripts); while tp^.kind = definedType do
tp := tp^.dType;
case tp^.kind of
scalarType: WriteScalarType(tp, $80, subscripts);
enumType, enumType,
functionType: WriteScalarType(wordPtr, $80, subscripts); functionType: WriteScalarType(wordPtr, $80, subscripts);
otherwise: begin otherwise: begin
@ -1035,6 +1039,8 @@ var
count := count+1; count := count+1;
tp2 := tp2^.aType; tp2 := tp2^.aType;
end; {while} end; {while}
while tp2^.kind = definedType do
tp2 := tp2^.dType;
if tp2^.kind = scalarType then {write the type code} if tp2^.kind = scalarType then {write the type code}
if tp2^.baseType in [cgByte,cgUByte] then begin if tp2^.baseType in [cgByte,cgUByte] then begin
count := count-1; count := count-1;
@ -1082,25 +1088,28 @@ var
disp: integer; {disp to symbol of same type} disp: integer; {disp to symbol of same type}
begin {ExpandPointerType} begin {ExpandPointerType}
if tp^.ptype^.kind in [pointerType,arrayType,structType,unionType] then tp := tp^.ptype;
while tp^.kind = definedType do
tp := tp^.dType;
if tp^.kind in [pointerType,arrayType,structType,unionType] then
begin begin
symLength := symLength+12; symLength := symLength+12;
CnOut2(0); CnOut2(0); CnOut2(0); CnOut2(0);
CnOut2(0); CnOut2(0); CnOut2(0); CnOut2(0);
CnOut(0); CnOut(0);
case tp^.ptype^.kind of case tp^.kind of
pointerType: begin pointerType: begin
WritePointerType(tp^.ptype, 0); WritePointerType(tp, 0);
ExpandPointerType(tp^.ptype); ExpandPointerType(tp);
end; end;
arrayType: WriteArrays(tp^.ptype); arrayType: WriteArrays(tp);
structType, structType,
unionType: begin unionType: begin
disp := GetTypeDisp(tp^.ptype); disp := GetTypeDisp(tp);
if disp = noDisp then begin if disp = noDisp then begin
CnOut(12); CnOut(12);
CnOut2(0); CnOut2(0);
ExpandStructType(tp^.ptype); ExpandStructType(tp);
end {if} end {if}
else begin else begin
CnOut(13); CnOut(13);
@ -1113,27 +1122,30 @@ var
begin {GenSymbol} begin {GenSymbol}
if ip^.itype^.kind in tPtr := ip^.itype;
while tPtr^.kind = definedType do
tPtr := tPtr^.dType;
if tPtr^.kind in
[scalarType,arrayType,pointerType,enumType,structType,unionType] [scalarType,arrayType,pointerType,enumType,structType,unionType]
then begin then begin
symLength := symLength+12; {update length of symbol table} symLength := symLength+12; {update length of symbol table}
WriteName(ip); {write the name field} WriteName(ip); {write the name field}
WriteAddress(ip); {write the address field} WriteAddress(ip); {write the address field}
case ip^.itype^.kind of case tPtr^.kind of
scalarType: WriteScalarType(ip^.itype, 0, 0); scalarType: WriteScalarType(tPtr, 0, 0);
enumType: WriteScalarType(wordPtr, 0, 0); enumType: WriteScalarType(wordPtr, 0, 0);
pointerType: begin pointerType: begin
WritePointerType(ip^.itype, 0); WritePointerType(tPtr, 0);
ExpandPointerType(ip^.itype); ExpandPointerType(tPtr);
end; end;
arrayType: WriteArrays(ip^.itype); arrayType: WriteArrays(tPtr);
structType, structType,
unionType: begin unionType: begin
disp := GetTypeDisp(ip^.itype); disp := GetTypeDisp(tPtr);
if disp = noDisp then begin if disp = noDisp then begin
CnOut(12); CnOut(12);
CnOut2(0); CnOut2(0);
ExpandStructType(ip^.itype); ExpandStructType(tPtr);
end {if} end {if}
else begin else begin
CnOut(13); CnOut(13);