Debugger: Remove IDbgWatchValueIntf.Value in favour of IDbgWatchValueIntf.ResData.CreatePrePrinted

This commit is contained in:
Martin 2024-02-23 20:26:50 +01:00
parent fee8dbf80e
commit adc63a1a42
10 changed files with 40 additions and 53 deletions

View File

@ -14713,7 +14713,7 @@ begin
end;
end;
FWatchValue.Value := FTextValue;
FWatchValue.ResData.CreatePrePrinted(FTextValue);
FWatchValue.TypeInfo := TypeInfo;
FTypeInfo := nil;
FWatchValue.Validity := FValidity;

View File

@ -1150,8 +1150,9 @@ begin
ErrorHandler.OnErrorTextLookup := @GetErrorText;
AResText := ErrorHandler.ErrorAsString(APasExpr.Error);
if FWatchValue <> nil then begin
FWatchValue.Value := AResText;
FWatchValue.Validity := ddsError;
FWatchValue.BeginUpdate;
FWatchValue.ResData.CreateError(AResText);
FWatchValue.EndUpdate;
end;
exit;
end;
@ -1160,8 +1161,9 @@ begin
if ResValue = nil then begin
AResText := 'Error';
if FWatchValue <> nil then begin
FWatchValue.Value := AResText;
FWatchValue.Validity := ddsError;
FWatchValue.BeginUpdate;
FWatchValue.ResData.CreateError(AResText);
FWatchValue.EndUpdate;
end;
exit;
end;
@ -1268,9 +1270,11 @@ begin
if not Result then
FreeAndNil(ATypeInfo);
if FWatchValue <> nil then begin
FWatchValue.Value := AResText;
FWatchValue.BeginUpdate;
FWatchValue.ResData.CreatePrePrinted(AResText);
FWatchValue.TypeInfo := ATypeInfo;
FWatchValue.Validity := ddsValid;
FWatchValue.EndUpdate;
end;
finally
PrettyPrinter.Free;

View File

@ -646,21 +646,24 @@ end;
procedure TFPDSendWatchEvaluateCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
var
s: string;
i: TDebuggerDataState;
i, V: TDebuggerDataState;
begin
inherited DoOnCommandSuccesfull(ACommandResponse);
if assigned(FWatchValue) then
begin
FWatchValue.Value:=ACommandResponse.Get('message','');
FWatchValue.BeginUpdate;
FWatchValue.ResData.CreatePrePrinted(ACommandResponse.Get('message',''));
s := ACommandResponse.Get('validity','');
FWatchValue.Validity:=ddsError;
V := ddsError;
for i := low(TDebuggerDataState) to high(TDebuggerDataState) do
if DebuggerDataStateStr[i]=s then
begin
FWatchValue.Validity:=i;
V :=i;
break;
end;
FWatchValue.Validity:=V;
FWatchValue.EndUpdate;
end;
end;

View File

@ -1081,13 +1081,11 @@ begin
if not IsWatchValueAlive then exit;
if not PasExpr.Valid then begin
DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
if ErrorCode(PasExpr.Error) <> fpErrAnyError then begin
Result := True;
AResText := ErrorHandler.ErrorAsString(PasExpr.Error);;
AResText := ErrorHandler.ErrorAsString(PasExpr.Error);
if AWatchValue <> nil then begin;
AWatchValue.Value := AResText;
AWatchValue.Validity := ddsError;
AWatchValue.ResData.CreateError(AResText);
end;
exit;
end;
@ -1151,7 +1149,7 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
Result := True;
if AWatchValue <> nil then begin
if not IsWatchValueAlive then exit;
AWatchValue.Value := AResText;
AWatchValue.ResData.CreatePrePrinted(AResText);
AWatchValue.Validity := ddsValid; // TODO ddsError ?
end;
exit;
@ -1181,12 +1179,15 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
Result := True;
debugln(DBG_VERBOSE, ['TFPGDBMIWatches.InternalRequestData GOOOOOOD ', AExpression]);
if AWatchValue <> nil then begin
AWatchValue.Value := AResText;
AWatchValue.TypeInfo := ATypeInfo;
if IsError(ResValue.LastError) then
AWatchValue.Validity := ddsError
else
if IsError(ResValue.LastError) then begin
AWatchValue.ResData.CreateError(AResText);
AWatchValue.Validity := ddsError;
end
else begin
AWatchValue.ResData.CreatePrePrinted(AResText);
AWatchValue.Validity := ddsValid;
end;
end;
end;

View File

@ -1717,8 +1717,7 @@ begin
Result := True;
AResText := ErrorHandler.ErrorAsString(PasExpr.Error);
if AWatchValue <> nil then begin
AWatchValue.Value := AResText;
AWatchValue.Validity := ddsError;
AWatchValue.ResData.CreateError(AResText);
end;
exit;
end;
@ -1796,7 +1795,7 @@ begin
Result := True;
if AWatchValue <> nil then begin
if not IsWatchValueAlive then exit;
AWatchValue.Value := AResText;
AWatchValue.ResData.CreatePrePrinted(AResText);
AWatchValue.Validity := ddsValid; // TODO ddsError ?
end;
exit;
@ -1829,12 +1828,15 @@ begin
Result := True;
debugln(DBG_VERBOSE, ['TFPLldbWatches.InternalRequestData GOOOOOOD ', AExpression]);
if AWatchValue <> nil then begin
AWatchValue.Value := AResText;
AWatchValue.TypeInfo := ATypeInfo;
if IsError(ResValue.LastError) then
AWatchValue.Validity := ddsError
else
if IsError(ResValue.LastError) then begin
AWatchValue.ResData.CreateError(AResText);
AWatchValue.Validity := ddsError;
end
else begin
AWatchValue.ResData.CreatePrePrinted(AResText);
AWatchValue.Validity := ddsValid;
end;
end;
end;

View File

@ -246,9 +246,7 @@ type
function GetThreadId: Integer;
function GetValidity: TDebuggerDataState;
procedure SetTypeInfo(AValue: TDBGTypeBase);
function GetValue: String; // FpGdbmiDebugger
procedure SetValidity(AValue: TDebuggerDataState);
procedure SetValue(AValue: String);
property EvaluateFlags: TWatcheEvaluateFlags read GetEvaluateFlags;
property FirstIndexOffs: Int64 read GetFirstIndexOffs;
@ -258,7 +256,6 @@ type
property Expression: String read GetExpression;
property Validity: TDebuggerDataState read GetValidity write SetValidity;
property Value: String read GetValue write SetValue;
property TypeInfo: TDBGTypeBase {read GetTypeInfo} write SetTypeInfo;
end;

View File

@ -2561,9 +2561,11 @@ procedure TLldbDebuggerCommandEvaluate.EvalInstructionSucceeded(Sender: TObject
);
begin
if FWatchValue <> nil then begin
FWatchValue.Value := FInstr.Res;
FWatchValue.BeginUpdate;
FWatchValue.ResData.CreatePrePrinted(FInstr.Res);
//FWatchValue.TypeInfo := TypeInfo;
FWatchValue.Validity := ddsValid;
FWatchValue.EndUpdate;
end
else
if FCallback <> nil then

View File

@ -93,7 +93,6 @@ type
function GetTypeInfo: TDBGType; override;
function GetValidity: TDebuggerDataState; override;
function GetValue: String; override;
procedure SetValue(AValue: String); override;
public
constructor Create(AOwnerWatch: TWatch;
const AThreadId: Integer;
@ -478,13 +477,6 @@ begin
end;
end;
procedure TTestWatchValue.SetValue(AValue: String);
begin
BeginUpdate;
ResData.CreatePrePrinted(AValue);
EndUpdate;
end;
constructor TTestWatchValue.Create(AOwnerWatch: TWatch; const AThreadId: Integer;
const AStackFrame: Integer);
begin

View File

@ -783,7 +783,6 @@ type
FSnapShot: TIdeWatchValue;
procedure SetSnapShot(const AValue: TIdeWatchValue);
protected
procedure SetValue(AValue: String); override; // TODO: => one per DisplayFormat???
procedure SetWatch(AValue: TWatch); override;
function GetBackendExpression: String; reintroduce;
function GetValidity: TDebuggerDataState; override;
@ -4150,13 +4149,6 @@ begin
then FSnapShot.Assign(self);
end;
procedure TCurrentWatchValue.SetValue(AValue: String);
begin
BeginUpdate;
ResData.CreatePrePrinted(AValue);
EndUpdate;
end;
procedure TCurrentWatchValue.SetWatch(AValue: TWatch);
begin
CancelRequestData;

View File

@ -78,7 +78,6 @@ type
function GetThreadId: Integer;
function GetValidity: TDebuggerDataState; virtual;
procedure SetValidity(AValue: TDebuggerDataState); virtual;
procedure SetValue(AValue: String); virtual;
procedure SetTypeInfo(AValue: TDBGType);
procedure SetTypeInfo(AValue: TDBGTypeBase);
@ -113,7 +112,7 @@ type
public
property Watch: TWatch read FWatch write SetWatch;
property Validity: TDebuggerDataState read GetValidity write SetValidity;
property Value: String read GetValue write SetValue;
property Value: String read GetValue;
property TypeInfo: TDBGType read GetTypeInfo write SetTypeInfo;
property ResultData: TWatchResultData read GetResultData;
end;
@ -462,11 +461,6 @@ begin
Result := FThreadId;
end;
procedure TWatchValue.SetValue(AValue: String);
begin
assert(False, 'TWatchValue.SetValue: False');
end;
procedure TWatchValue.SetTypeInfo(AValue: TDBGType);
begin
//assert(Self is TCurrentWatchValue, 'TWatchValue.SetTypeInfo');