FpDebug: Implemented watch for "SomeString[index]"

git-svn-id: trunk@59861 -
This commit is contained in:
martin 2018-12-19 01:40:19 +00:00
parent c3e01c7dc4
commit 53ff21a2b4
2 changed files with 63 additions and 5 deletions

View File

@ -241,6 +241,21 @@ type
constructor Create(AValue: QWord; ASigned: Boolean = True);
end;
{ TFpDbgValueConstChar }
TFpDbgValueConstChar = class(TFpDbgValue) // skChar / Not for strings
private
FValue: String;
FSigned: Boolean;
protected
property Value: String read FValue write FValue;
function GetKind: TDbgSymbolKind; override;
function GetFieldFlags: TFpDbgValueFieldFlags; override;
function GetAsString: AnsiString; override;
public
constructor Create(AValue: AnsiString);
end;
{ TFpDbgValueConstFloat }
TFpDbgValueConstFloat = class(TFpDbgValue)
@ -500,6 +515,29 @@ begin
WriteStr(Result, ADbgSymbolKind);
end;
{ TFpDbgValueConstChar }
function TFpDbgValueConstChar.GetKind: TDbgSymbolKind;
begin
Result := skChar;
end;
function TFpDbgValueConstChar.GetFieldFlags: TFpDbgValueFieldFlags;
begin
Result := [svfString]
end;
function TFpDbgValueConstChar.GetAsString: AnsiString;
begin
Result := Value;
end;
constructor TFpDbgValueConstChar.Create(AValue: AnsiString);
begin
inherited Create;
FValue := AValue;
end;
{ TFpDbgCircularRefCountedObject }
procedure TFpDbgCircularRefCountedObject.DoPlainReferenceAdded;

View File

@ -71,6 +71,7 @@ type
destructor Destroy; override;
function DebugDump(AWithResults: Boolean = False): String;
procedure ResetEvaluation;
property TextExpression: String read FTextExpression;
property Error: TFpError read FError;
property Valid: Boolean read GetValid;
// Set by GetResultValue
@ -1024,6 +1025,7 @@ var
Offs: Int64;
ti: TFpDbgSymbol;
IsPChar: Boolean;
v: String;
begin
Result := nil;
assert(Count >= 2, 'TFpPascalExpressionPartBracketIndex.DoGetResultValue: Count >= 2');
@ -1087,11 +1089,29 @@ begin
SetError('Error dereferencing'); // TODO: set correct error
if TmpVal2 <> nil then TmpVal2.AddReference;
end;
skString: begin
//TODO
SetError('Not implemented');
TmpVal.ReleaseReference;
exit;
skString, skAnsiString: begin
//TODO: move to FpDwarfValue.member ??
if (svfInteger in TmpIndex.FieldFlags) then
Offs := TmpIndex.AsInteger
else
if (svfOrdinal in TmpIndex.FieldFlags) and (TmpIndex.AsCardinal <= high(Int64))
then
Offs := Int64(TmpIndex.AsCardinal)
else
begin
SetError('Can not calculate Index');
TmpVal.ReleaseReference;
exit;
end;
v := TmpVal.AsString;
if (Offs < 1) or (Offs > Length(v)) then begin
SetError('Index out of range');
TmpVal.ReleaseReference;
exit;
end;
TmpVal2 := TFpDbgValueConstChar.Create(v[Offs]);
end
else
begin