Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: fpdbgclasses.pp
- ===================================================================
- --- fpdbgclasses.pp (revision 43291)
- +++ fpdbgclasses.pp (working copy)
- @@ -37,7 +37,7 @@
- uses
- {$ifdef windows}
- - Windows, FpImgReaderWinPE,
- + Windows,
- {$endif}
- Classes, Maps, FpDbgUtil, FpDbgWinExtra, FpDbgLoader, LazLoggerBase, LazClasses;
- @@ -68,6 +68,12 @@
- end;
- {$endif}
- + TDbgSymbolType = (
- + stNone,
- + stValue, // The symbol has a value (var, field, function, procedure (value is address of func/proc, so it can be called)
- + stType // The Symbol is a type (including proc/func declaration / without DW_AT_low_pc)
- + );
- +
- TDbgSymbolKind = (
- skNone, // undefined type
- // skUser, // userdefined type, this sym refers to another sym defined elswhere
- @@ -113,7 +119,7 @@
- TDbgSymbolFlags = set of TDbgSymbolFlag;
- TDbgSymbolField = (
- - sfName, sfKind
- + sfiName, sfiKind, sfiSymType, sfiAddress, sfiSize
- );
- TDbgSymbolFields = set of TDbgSymbolField;
- @@ -121,14 +127,22 @@
- TDbgSymbol = class(TRefCountedObject)
- private
- + FEvaluatedFields: TDbgSymbolFields;
- +
- + // Cached fields
- FName: String;
- FKind: TDbgSymbolKind;
- + FSymbolType: TDbgSymbolType;
- FAddress: TDbgPtr;
- + FSize: Integer;
- - FEvaluatedFields: TDbgSymbolFields;
- - function GetKind: TDbgSymbolKind;
- + function GetSymbolType: TDbgSymbolType; inline;
- + function GetKind: TDbgSymbolKind; inline;
- function GetName: String;
- + function GetSize: Integer;
- + function GetAddress: TDbgPtr;
- protected
- + // NOT cached fields
- function GetPointedToType: TDbgSymbol; virtual;
- function GetChild(AIndex: Integer): TDbgSymbol; virtual;
- @@ -139,23 +153,31 @@
- function GetLine: Cardinal; virtual;
- function GetParent: TDbgSymbol; virtual;
- function GetReference: TDbgSymbol; virtual;
- - function GetSize: Integer; virtual;
- -
- + protected
- + // Cached fields
- procedure SetName(AValue: String);
- procedure SetKind(AValue: TDbgSymbolKind);
- + procedure SetSymbolType(AValue: TDbgSymbolType);
- + procedure SetAddress(AValue: TDbgPtr);
- + procedure SetSize(AValue: Integer);
- procedure KindNeeded; virtual;
- procedure NameNeeded; virtual;
- + procedure SymbolTypeNeeded; virtual;
- + procedure AddressNeeded; virtual;
- + procedure SizeNeeded; virtual;
- + //procedure Needed; virtual;
- public
- constructor Create(const AName: String);
- constructor Create(const AName: String; AKind: TDbgSymbolKind; AAddress: TDbgPtr);
- destructor Destroy; override;
- // Basic info
- - property Name: String read GetName;
- - property Kind: TDbgSymbolKind read GetKind;
- + property Name: String read GetName;
- + property SymbolType: TDbgSymbolType read GetSymbolType;
- + property Kind: TDbgSymbolKind read GetKind;
- // Memory; Size is also part of type (byte vs word vs ...)
- - property Address: TDbgPtr read FAddress;
- - property Size: Integer read GetSize;
- + property Address: TDbgPtr read GetAddress;
- + property Size: Integer read GetSize; // In Bytes
- // Location
- property FileName: String read GetFile;
- property Line: Cardinal read GetLine;
- @@ -905,9 +927,16 @@
- inherited Destroy;
- end;
- +function TDbgSymbol.GetAddress: TDbgPtr;
- +begin
- + if not(sfiAddress in FEvaluatedFields) then
- + AddressNeeded;
- + Result := FAddress;
- +end;
- +
- function TDbgSymbol.GetKind: TDbgSymbolKind;
- begin
- - if not(sfKind in FEvaluatedFields) then
- + if not(sfiKind in FEvaluatedFields) then
- KindNeeded;
- Result := FKind;
- end;
- @@ -914,26 +943,58 @@
- function TDbgSymbol.GetName: String;
- begin
- - if not(sfName in FEvaluatedFields) then
- + if not(sfiName in FEvaluatedFields) then
- NameNeeded;
- Result := FName;
- end;
- +function TDbgSymbol.GetSize: Integer;
- +begin
- + if not(sfiSize in FEvaluatedFields) then
- + SizeNeeded;
- + Result := FSize;
- +end;
- +
- +function TDbgSymbol.GetSymbolType: TDbgSymbolType;
- +begin
- + if not(sfiSymType in FEvaluatedFields) then
- + SymbolTypeNeeded;
- + Result := FSymbolType;
- +end;
- +
- function TDbgSymbol.GetPointedToType: TDbgSymbol;
- begin
- Result := nil;
- end;
- +procedure TDbgSymbol.SetAddress(AValue: TDbgPtr);
- +begin
- + FAddress := AValue;
- + Include(FEvaluatedFields, sfiAddress);
- +end;
- +
- procedure TDbgSymbol.SetKind(AValue: TDbgSymbolKind);
- begin
- FKind := AValue;
- - Include(FEvaluatedFields, sfKind);
- + Include(FEvaluatedFields, sfiKind);
- end;
- +procedure TDbgSymbol.SetSymbolType(AValue: TDbgSymbolType);
- +begin
- + FSymbolType := AValue;
- + Include(FEvaluatedFields, sfiSymType);
- +end;
- +
- +procedure TDbgSymbol.SetSize(AValue: Integer);
- +begin
- + FSize := AValue;
- + Include(FEvaluatedFields, sfiSize);
- +end;
- +
- procedure TDbgSymbol.SetName(AValue: String);
- begin
- FName := AValue;
- - Include(FEvaluatedFields, sfName);
- + Include(FEvaluatedFields, sfiName);
- end;
- function TDbgSymbol.GetChild(AIndex: Integer): TDbgSymbol;
- @@ -976,11 +1037,6 @@
- Result := nil;
- end;
- -function TDbgSymbol.GetSize: Integer;
- -begin
- - Result := 0;
- -end;
- -
- procedure TDbgSymbol.KindNeeded;
- begin
- SetKind(skNone);
- @@ -991,6 +1047,21 @@
- SetName('');
- end;
- +procedure TDbgSymbol.SymbolTypeNeeded;
- +begin
- + SetSymbolType(stNone);
- +end;
- +
- +procedure TDbgSymbol.AddressNeeded;
- +begin
- + SetAddress(0);
- +end;
- +
- +procedure TDbgSymbol.SizeNeeded;
- +begin
- + SetSize(0);
- +end;
- +
- {$ifdef windows}
- { TDbgBreak }
- Index: fpdbgdwarf.pas
- ===================================================================
- --- fpdbgdwarf.pas (revision 43291)
- +++ fpdbgdwarf.pas (working copy)
- @@ -526,6 +526,8 @@
- //function GetSize: Integer; override;
- property TypeInfo: TDbgDwarfTypeIdentifier read GetTypeInfo;
- property InformationEntry: TDwarfInformationEntry read FInformationEntry;
- +
- + procedure Init; virtual;
- class function GetSubClass(ATag: Cardinal): TDbgDwarfIdentifierClass;
- public
- class function CreateSubClass(AName: String; AnInformationEntry: TDwarfInformationEntry): TDbgDwarfIdentifier;
- @@ -540,6 +542,7 @@
- TDbgDwarfValueIdentifier = class(TDbgDwarfIdentifier) // var, const, member, ...
- protected
- procedure KindNeeded; override;
- + procedure Init; override;
- public
- property TypeInfo;
- end;
- @@ -595,6 +598,7 @@
- function GetIsPointerType: Boolean; virtual;
- function GetIsStructType: Boolean; virtual;
- function GetStructTypeInfo: TDbgDwarfIdentifierStructure; virtual;
- + procedure Init; override;
- public
- class function CreateTybeSubClass(AName: String; AnInformationEntry: TDwarfInformationEntry): TDbgDwarfTypeIdentifier;
- property TypeInfo;
- @@ -685,6 +689,8 @@
- function StateMachineValid: Boolean;
- protected
- procedure KindNeeded; override;
- + procedure SizeNeeded; override;
- +
- function GetChild(AIndex: Integer): TDbgSymbol; override;
- function GetColumn: Cardinal; override;
- function GetCount: Integer; override;
- @@ -693,7 +699,6 @@
- function GetLine: Cardinal; override;
- function GetParent: TDbgSymbol; override;
- // function GetReference: TDbgSymbol; override;
- - function GetSize: Integer; override;
- public
- constructor Create(ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr); overload;
- destructor Destroy; override;
- @@ -1218,6 +1223,12 @@
- SetKind(t.Kind);
- end;
- +procedure TDbgDwarfValueIdentifier.Init;
- +begin
- + inherited Init;
- + SetSymbolType(stValue);
- +end;
- +
- { TDbgDwarfIdentifierArray }
- procedure TDbgDwarfIdentifierArray.KindNeeded;
- @@ -1473,6 +1484,12 @@
- Result := nil;
- end;
- +procedure TDbgDwarfTypeIdentifier.Init;
- +begin
- + inherited Init;
- + SetSymbolType(stType);
- +end;
- +
- function TDbgDwarfTypeIdentifier.GetIsBaseType: Boolean;
- begin
- Result := False;
- @@ -1869,6 +1886,11 @@
- SetName(AName);
- end;
- +procedure TDbgDwarfIdentifier.Init;
- +begin
- + //
- +end;
- +
- class function TDbgDwarfIdentifier.GetSubClass(ATag: Cardinal): TDbgDwarfIdentifierClass;
- begin
- case ATag of
- @@ -1910,6 +1932,7 @@
- FInformationEntry.AddReference;
- inherited Create(AName);
- + Init;
- end;
- constructor TDbgDwarfIdentifier.Create(AName: String;
- @@ -1920,6 +1943,7 @@
- FInformationEntry.AddReference;
- inherited Create(AName, AKind, AAddress);
- + Init;
- end;
- destructor TDbgDwarfIdentifier.Destroy;
- @@ -2774,11 +2798,6 @@
- Result:=inherited GetParent;
- end;
- -function TDbgDwarfProcSymbol.GetSize: Integer;
- -begin
- - Result := FAddressInfo^.EndPC - FAddressInfo^.StartPC;
- -end;
- -
- function TDbgDwarfProcSymbol.StateMachineValid: Boolean;
- var
- SM1, SM2: TDwarfLineInfoStateMachine;
- @@ -2830,6 +2849,11 @@
- SetKind(skProcedure);
- end;
- +procedure TDbgDwarfProcSymbol.SizeNeeded;
- +begin
- + SetSize(FAddressInfo^.EndPC - FAddressInfo^.StartPC);
- +end;
- +
- { TDbgDwarf }
- constructor TDbgDwarf.Create(ALoader: TDbgImageLoader);
- Index: fppascalparser.pas
- ===================================================================
- --- fppascalparser.pas (revision 43291)
- +++ fppascalparser.pas (working copy)
- @@ -598,13 +598,11 @@
- if FDbgType = nil then
- exit;
- - if FDbgType is TDbgDwarfValueIdentifier then
- - Result := TDbgDwarfValueIdentifier(FDbgType).TypeInfo
- - else
- - if FDbgType is TDbgDwarfTypeIdentifier then
- - Result := FDbgType
- - else
- - Result := nil; // Todo handled by typecast operator // maybe wrap in TTypeOf class?
- + case FDbgType.SymbolType of
- + stValue: Result := TDbgDwarfValueIdentifier(FDbgType).TypeInfo;
- + stType: Result := FDbgType;
- + else Result := nil;
- + end;
- if Result <> nil then
- Result.AddReference;
- @@ -614,7 +612,7 @@
- begin
- if FDbgType = nil then
- FDbgType := FExpression.GetDbgTyeForIdentifier(GetText);
- - Result := (FDbgType <> nil) and (FDbgType is TDbgDwarfTypeIdentifier);
- + Result := (FDbgType <> nil) and (FDbgType.SymbolType = stType);
- end;
- destructor TFpPascalExpressionPartIdentifer.Destroy;
- @@ -1446,13 +1444,13 @@
- tmp := Items[0].ResultType;
- // Todo unit
- - if (tmp <> nil) and (tmp is TDbgDwarfTypeIdentifier) and
- + if (tmp <> nil) and (tmp.SymbolType = stType) and
- (TDbgDwarfTypeIdentifier(tmp).IsStructType)
- then begin
- struct := TDbgDwarfTypeIdentifier(tmp).StructTypeInfo;
- tmp := struct.MemberByName[Items[1].GetText];
- - if (tmp <> nil) and (tmp is TDbgDwarfValueIdentifier) then begin
- + if (tmp <> nil) and (tmp.SymbolType = stValue) then begin
- Result := TDbgDwarfValueIdentifier(tmp).TypeInfo;
- Result.AddReference;
- end;
- Index: test/FpTest.lpi
- ===================================================================
- --- test/FpTest.lpi (revision 43291)
- +++ test/FpTest.lpi (working copy)
- @@ -42,7 +42,7 @@
- <PackageName Value="FCL"/>
- </Item4>
- </RequiredPackages>
- - <Units Count="3">
- + <Units Count="4">
- <Unit0>
- <Filename Value="FpTest.lpr"/>
- <IsPartOfProject Value="True"/>
- @@ -54,10 +54,15 @@
- <UnitName Value="TestPascalParser"/>
- </Unit1>
- <Unit2>
- + <Filename Value="..\..\..\debugger\fpgdbmidebugger.pp"/>
- + <IsPartOfProject Value="True"/>
- + <UnitName Value="FpGdbmiDebugger"/>
- + </Unit2>
- + <Unit3>
- <Filename Value="testtypeinfo.pas"/>
- <IsPartOfProject Value="True"/>
- <UnitName Value="TestTypeInfo"/>
- - </Unit2>
- + </Unit3>
- </Units>
- </ProjectOptions>
- <CompilerOptions>
- Index: test/testpascalparser.pas
- ===================================================================
- --- test/testpascalparser.pas (revision 43291)
- +++ test/testpascalparser.pas (working copy)
- @@ -376,6 +376,22 @@
- TestExpr([0,0,0], TFpPascalExpressionPartIdentifer, 'f', 0);
- TestExpr([0,1], TFpPascalExpressionPartIdentifer, 'a', 0);
- + CreateExpr('@f(a)(b)', True);
- + TestExpr([], TFpPascalExpressionPartOperatorAddressOf, '@', 1);
- + TestExpr([0], TFpPascalExpressionPartBracketArgumentList, '(', 2);
- + TestExpr([0,0], TFpPascalExpressionPartBracketArgumentList, '(', 2);
- + TestExpr([0,0,0], TFpPascalExpressionPartIdentifer, 'f', 0);
- + TestExpr([0,0,1], TFpPascalExpressionPartIdentifer, 'a', 0);
- + TestExpr([0,1], TFpPascalExpressionPartIdentifer, 'b', 0);
- +
- + CreateExpr('f(a)(b)^', True);
- + TestExpr([], TFpPascalExpressionPartOperatorDeRef, '^', 1);
- + TestExpr([0], TFpPascalExpressionPartBracketArgumentList, '(', 2);
- + TestExpr([0,0], TFpPascalExpressionPartBracketArgumentList, '(', 2);
- + TestExpr([0,0,0], TFpPascalExpressionPartIdentifer, 'f', 0);
- + TestExpr([0,0,1], TFpPascalExpressionPartIdentifer, 'a', 0);
- + TestExpr([0,1], TFpPascalExpressionPartIdentifer, 'b', 0);
- +
- finally
- CurrentTestExprObj.Free;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement