Debugger: Replace TWatchValue.DisplayFormat with TWatchValue.IsMemDump. All other DisplayFormat settings are on TWatch only.

This commit is contained in:
Martin 2024-02-24 13:36:24 +01:00
parent adc63a1a42
commit 8b491579a1
6 changed files with 62 additions and 54 deletions

View File

@ -245,7 +245,7 @@ type
function GetStackFrame: Integer;
function GetThreadId: Integer;
function GetValidity: TDebuggerDataState;
procedure SetTypeInfo(AValue: TDBGTypeBase);
procedure SetTypeInfo(AValue: TDBGTypeBase); // Must not be used by MemDump
procedure SetValidity(AValue: TDebuggerDataState);
property EvaluateFlags: TWatcheEvaluateFlags read GetEvaluateFlags;
@ -256,7 +256,7 @@ type
property Expression: String read GetExpression;
property Validity: TDebuggerDataState read GetValidity write SetValidity;
property TypeInfo: TDBGTypeBase {read GetTypeInfo} write SetTypeInfo;
property TypeInfo: TDBGTypeBase {read GetTypeInfo} write SetTypeInfo; // Must not be used by MemDump
end;

View File

@ -11580,6 +11580,7 @@ var
WatchPrinter: TWatchResultPrinter;
ResultText: String;
ResData: TWatchResultData;
DispFormat: TWatchDisplayFormat;
begin
if (Sender <> FHintWatchData.WatchValue) or (FHintWatchData.WatchValue = nil) or
(SourceEditorManager = nil) or
@ -11594,15 +11595,19 @@ begin
ResultText := '';
WatchPrinter := TWatchResultPrinter.Create;
try
DispFormat := wdfDefault;
if FHintWatchData.WatchValue.Watch <> nil then
DispFormat := FHintWatchData.WatchValue.Watch.DisplayFormat;
if FHintWatchData.WatchValue.Validity = ddsValid then begin
ResData := FHintWatchData.WatchValue.ResultData;
if (ResData <> nil) and
not( (ResData.ValueKind = rdkPrePrinted) and (FHintWatchData.WatchValue.TypeInfo <> nil) )
then begin
if not ValueFormatterSelectorList.FormatValue(ResData,
FHintWatchData.WatchValue.DisplayFormat, WatchPrinter, ResultText)
DispFormat, WatchPrinter, ResultText)
then begin
ResultText := WatchPrinter.PrintWatchValue(ResData, FHintWatchData.WatchValue.DisplayFormat);
ResultText := WatchPrinter.PrintWatchValue(ResData, DispFormat);
if (ResData.ValueKind = rdkArray) and (ResData.ArrayLength > 0)
then
ResultText := Format(drsLen, [ResData.ArrayLength]) + ResultText;
@ -11612,7 +11617,7 @@ begin
else begin
if (FHintWatchData.WatchValue.TypeInfo = nil) or
not ValueFormatterSelectorList.FormatValue(FHintWatchData.WatchValue.TypeInfo,
FHintWatchData.WatchValue.Value, FHintWatchData.WatchValue.DisplayFormat, ResultText)
FHintWatchData.WatchValue.Value, DispFormat, ResultText)
then begin
ResultText := FHintWatchData.WatchValue.Value;
if (FHintWatchData.WatchValue.TypeInfo <> nil) and

View File

@ -4136,7 +4136,7 @@ end;
function TCurrentWatchValue.GetIntfEvaluateFlags: TWatcheEvaluateFlags;
begin
Result := EvaluateFlags;
if FDisplayFormat = wdfMemDump then
if IsMemDump then
Result := Result + [defMemDump];
end;
@ -4310,6 +4310,8 @@ begin
for i := 0 to c - 1 do begin
e := TIdeWatchValue.Create(Watch);
e.LoadDataFromXMLConfig(AConfig, APath + IntToStr(i) + '/');
// TODO xxxx may load the same entry more than once with diff display format
// check before adding
Add(e);
end;
end;
@ -4551,7 +4553,7 @@ begin
then Include(FEvaluateFlags, defClassAutoCast)
else Exclude(FEvaluateFlags, defClassAutoCast);
FRepeatCount := AConfig.GetValue(APath + 'RepeatCount', 0);
AConfig.GetValue(APath + 'DisplayFormat', int64(ord(wdfDefault)), FDisplayFormat, system.TypeInfo(TWatchDisplayFormat));
FIsMemDump := AConfig.GetValue(APath + 'DisplayFormat', 'wdfDefault') = 'wdfMemDump'; // use constants from TWatchDisplayFormat
// Defaults to PrePrinted
FResultData := TWatchResultData.CreateFromXMLConfig(AConfig, APath);
@ -4570,17 +4572,15 @@ begin
AConfig.SetDeleteValue(APath + 'ClassAutoCast', defClassAutoCast in EvaluateFlags, False);
AConfig.SetDeleteValue(APath + 'RepeatCount', RepeatCount, 0);
if (Watch <> nil) and (FDisplayFormat <> wdfMemDump) and
(FResultData <> nil) and
(FResultData.ValueKind <> rdkPrePrinted)
then begin
// Use same path => "Value" will be readable for older IDE (read as wdDefault)
// ResultData does not write any "path/value" conflicting with the above fields
ResultData.SaveDataToXMLConfig(AConfig, APath);
if IsMemDump then begin
AConfig.SetDeleteValue(APath + 'DisplayFormat', 'wdfMemDump', 'wdfDefault'); // use constants from TWatchDisplayFormat
AConfig.SetValue(APath + 'Value', Value);
end
else begin
AConfig.SetDeleteValue(APath + 'DisplayFormat', DisplayFormat, int64(ord(wdfDefault)), system.TypeInfo(TWatchDisplayFormat));
AConfig.SetValue(APath + 'Value', Value);
if ResultData <> nil then
// Use same path => "Value" will be readable for older IDE (read as wdDefault)
// ResultData does not write any "path/value" conflicting with the above fields
ResultData.SaveDataToXMLConfig(AConfig, APath);
end;
end;
@ -4588,7 +4588,7 @@ constructor TIdeWatchValue.Create(AOwnerWatch: TWatch);
begin
inherited Create(AOwnerWatch);
Validity := ddsUnknown;
FDisplayFormat := Watch.DisplayFormat;
FIsMemDump := Watch.DisplayFormat = wdfMemDump;
FEvaluateFlags := Watch.EvaluateFlags;
FRepeatCount := Watch.RepeatCount;
FFirstIndexOffs := Watch.FirstIndexOffs;
@ -4607,7 +4607,7 @@ begin
inherited Assign(AnOther);
FThreadId := TIdeWatchValue(AnOther).FThreadId;
FStackFrame := TIdeWatchValue(AnOther).FStackFrame;
FDisplayFormat := TIdeWatchValue(AnOther).FDisplayFormat;
FIsMemDump := TIdeWatchValue(AnOther).FIsMemDump;
end;
function TIdeWatchValue.ExpressionForChildField(AName: String;

View File

@ -39,7 +39,7 @@ type
function GetEnabled: Boolean;
function GetValidity: TDebuggerDataState;
function GetDisplayFormat: TWatchDisplayFormat;
// function GetDisplayFormat: TWatchDisplayFormat;
function GetTypeInfo: TDBGType; deprecated;
function GetValue: string;
function GetResultData: TWatchResultData;
@ -49,7 +49,7 @@ type
property Enabled: Boolean read GetEnabled;
property Validity: TDebuggerDataState read GetValidity;
property DisplayFormat: TWatchDisplayFormat read GetDisplayFormat;
// property DisplayFormat: TWatchDisplayFormat read GetDisplayFormat;
property TypeInfo: TDBGType read GetTypeInfo;
property Value: string read GetValue; // for <Error> etc
property ResultData: TWatchResultData read GetResultData;
@ -60,9 +60,9 @@ type
{ TWatchValue }
TWatchValue = class(TRefCountedObject)
private
protected
FWatch: TWatch;
FIsMemDump: Boolean;
FTypeInfo: TDBGType;
FValidity: TDebuggerDataState;
FResultData: TWatchResultData;
@ -70,7 +70,6 @@ type
FResultDataContent: (rdcNotAnalysed, rdcNotSpecial, rdcJSon);
procedure SetWatch(AValue: TWatch); virtual;
function GetDisplayFormat: TWatchDisplayFormat;
function GetEvaluateFlags: TWatcheEvaluateFlags;
function GetFirstIndexOffs: Int64;
function GetRepeatCount: Integer;
@ -83,8 +82,9 @@ type
function GetResultData: TWatchResultData; virtual;
procedure SetResultData(AResultData: TWatchResultData);
property IsMemDump: Boolean read FIsMemDump;
protected
FDisplayFormat: TWatchDisplayFormat;
FEvaluateFlags: TWatcheEvaluateFlags;
FRepeatCount: Integer;
FFirstIndexOffs: Int64;
@ -102,7 +102,6 @@ type
destructor Destroy; override;
procedure Assign(AnOther: TWatchValue); virtual;
procedure ClearDisplayData; // keep only what's needed for the snapshot
property DisplayFormat: TWatchDisplayFormat read GetDisplayFormat;
property EvaluateFlags: TWatcheEvaluateFlags read GetEvaluateFlags;
property FirstIndexOffs: Int64 read GetFirstIndexOffs;
property RepeatCount: Integer read GetRepeatCount;
@ -440,17 +439,6 @@ begin
FWatch := AValue;
end;
function TWatchValue.GetDisplayFormat: TWatchDisplayFormat;
begin
if (FWatch = nil) or
(FDisplayFormat = wdfMemDump) or
(FWatch.FDisplayFormat = wdfMemDump)
then
Result := FDisplayFormat
else
Result := FWatch.DisplayFormat;
end;
function TWatchValue.GetRepeatCount: Integer;
begin
Result := FRepeatCount;
@ -823,7 +811,7 @@ begin
while i >= 0 do begin
Result := TWatchValue(FList[i]);
if (Result.ThreadId = AThreadId) and (Result.StackFrame = AStackFrame) and
(Result.DisplayFormat = FWatch.DisplayFormat) and
(Result.IsMemDump = (FWatch.DisplayFormat = wdfMemDump)) and
(Result.EvaluateFlags = FWatch.EvaluateFlags) and
(Result.FFirstIndexOffs <= AFirstIndexOffs) and
(Result.FFirstIndexOffs + Result.FRepeatCount > AFirstIndexOffs) and
@ -871,7 +859,7 @@ begin
while i >= 0 do begin
Result := TWatchValue(FList[i]);
if (Result.ThreadId = AThreadId) and (Result.StackFrame = AStackFrame) and
(Result.DisplayFormat = FWatch.DisplayFormat) and
(Result.IsMemDump = (FWatch.DisplayFormat = wdfMemDump)) and
(Result.RepeatCount = FWatch.RepeatCount) and
(Result.FirstIndexOffs = FWatch.FirstIndexOffs) and
(Result.EvaluateFlags = FWatch.EvaluateFlags)

View File

@ -834,6 +834,7 @@ function TDbgTreeViewLocalsValueMgr.GetFieldAsText(Nd: PVirtualNode;
var
ResData: TWatchResultData;
da: TDBGPtr;
DispFormat: TWatchDisplayFormat;
begin
if AWatchAbleResult = nil then
exit(inherited);
@ -868,6 +869,7 @@ begin
end;
end;
DispFormat := wdfDefault; // TODO TIdeLocalsValue(AWatchAble).DisplayFormat
if vdoAllowMultiLine in AnOpts then
FLocalsDlg.FWatchPrinter.FormatFlags := [rpfIndent, rpfMultiLine];
try
@ -876,15 +878,15 @@ begin
not( (ResData.ValueKind = rdkPrePrinted) and (AWatchAbleResult.TypeInfo <> nil) )
then begin
if not ValueFormatterSelectorList.FormatValue(ResData,
AWatchAbleResult.DisplayFormat, FLocalsDlg.FWatchPrinter, Result)
DispFormat, FLocalsDlg.FWatchPrinter, Result)
then begin
Result := FLocalsDlg.FWatchPrinter.PrintWatchValue(ResData, AWatchAbleResult.DisplayFormat);
Result := FLocalsDlg.FWatchPrinter.PrintWatchValue(ResData, DispFormat);
end;
end
else begin
if (AWatchAbleResult.TypeInfo = nil) or
not ValueFormatterSelectorList.FormatValue(AWatchAbleResult.TypeInfo,
AWatchAbleResult.Value, AWatchAbleResult.DisplayFormat, Result)
AWatchAbleResult.Value, DispFormat, Result)
then begin
Result := AWatchAbleResult.Value;
end;
@ -910,21 +912,23 @@ var
WatchValueStr: String;
ResData: TWatchResultData;
da: TDBGPtr;
DispFormat: TWatchDisplayFormat;
begin
ResData := AWatchAbleResult.ResultData;
DispFormat := wdfDefault; // TODO TIdeLocalsValue(AWatchAble).DisplayFormat
if (ResData <> nil) and
not( (ResData.ValueKind = rdkPrePrinted) and (AWatchAbleResult.TypeInfo <> nil) )
then begin
if not ValueFormatterSelectorList.FormatValue(ResData,
AWatchAbleResult.DisplayFormat, FLocalsDlg.FWatchPrinter, WatchValueStr)
DispFormat, FLocalsDlg.FWatchPrinter, WatchValueStr)
then begin
WatchValueStr := FLocalsDlg.FWatchPrinter.PrintWatchValue(ResData, AWatchAbleResult.DisplayFormat);
WatchValueStr := FLocalsDlg.FWatchPrinter.PrintWatchValue(ResData, DispFormat);
end;
end
else begin
if (AWatchAbleResult.TypeInfo = nil) or
not ValueFormatterSelectorList.FormatValue(AWatchAbleResult.TypeInfo,
AWatchAbleResult.Value, AWatchAbleResult.DisplayFormat, WatchValueStr)
AWatchAbleResult.Value, DispFormat, WatchValueStr)
then begin
WatchValueStr := AWatchAbleResult.Value;
end;

View File

@ -1173,7 +1173,7 @@ begin
if (d.ResultData <> nil) and
not( (d.ResultData.ValueKind = rdkPrePrinted) and (t <> nil) )
then begin
if ValueFormatterSelectorList.FormatValue(d.ResultData, d.DisplayFormat, FWatchPrinter, s)
if ValueFormatterSelectorList.FormatValue(d.ResultData, Watch.DisplayFormat, FWatchPrinter, s)
then begin
InspectMemo.WordWrap := True;
InspectMemo.Text := s;
@ -1182,7 +1182,7 @@ begin
end
else
if (t <> nil) and
ValueFormatterSelectorList.FormatValue(t, d.Value, d.DisplayFormat, s)
ValueFormatterSelectorList.FormatValue(t, d.Value, Watch.DisplayFormat, s)
then begin
InspectMemo.WordWrap := True;
InspectMemo.Text := s;
@ -1191,7 +1191,7 @@ begin
if (t <> nil) and (t.Fields <> nil) and (t.Fields.Count > 0) and
(d.DisplayFormat in [wdfDefault, wdfStructure])
(Watch.DisplayFormat in [wdfDefault, wdfStructure])
then begin
InspectMemo.WordWrap := False;
InspectMemo.Lines.BeginUpdate;
@ -1221,7 +1221,7 @@ begin
InspectMemo.WordWrap := True;
if d.ResultData <> nil then
s := FWatchPrinter.PrintWatchValue(d.ResultData, d.DisplayFormat)
s := FWatchPrinter.PrintWatchValue(d.ResultData, Watch.DisplayFormat)
else
s := d.Value;
InspectMemo.Text := s;
@ -1434,8 +1434,10 @@ function TDbgTreeViewWatchValueMgr.GetFieldAsText(Nd: PVirtualNode;
AWatchAble: TObject; AWatchAbleResult: IWatchAbleResultIntf;
AField: TTreeViewDataToTextField; AnOpts: TTreeViewDataToTextOptions): String;
var
TheWatch: TIdeWatch absolute AWatchAble;
ResData: TWatchResultData;
da: TDBGPtr;
DispFormat: TWatchDisplayFormat;
begin
if AWatchAbleResult = nil then
exit(inherited);
@ -1444,7 +1446,7 @@ begin
case AField of
vdfName:
if AWatchAble <> nil then
Result := TIdeWatch(AWatchAble).Expression;
Result := TheWatch.Expression;
vdfValue: begin
if AWatchAbleResult = nil then begin
Result := '<not evaluated>';
@ -1470,6 +1472,9 @@ begin
end;
end;
DispFormat := wdfDefault;
if AWatchAble <> nil then
DispFormat := TheWatch.DisplayFormat;
if vdoAllowMultiLine in AnOpts then
FWatchDlg.FWatchPrinter.FormatFlags := [rpfIndent, rpfMultiLine];
try
@ -1478,15 +1483,15 @@ begin
not( (ResData.ValueKind = rdkPrePrinted) and (AWatchAbleResult.TypeInfo <> nil) )
then begin
if not ValueFormatterSelectorList.FormatValue(ResData,
AWatchAbleResult.DisplayFormat, FWatchDlg.FWatchPrinter, Result)
DispFormat, FWatchDlg.FWatchPrinter, Result)
then begin
Result := FWatchDlg.FWatchPrinter.PrintWatchValue(ResData, AWatchAbleResult.DisplayFormat);
Result := FWatchDlg.FWatchPrinter.PrintWatchValue(ResData, DispFormat);
end;
end
else begin
if (AWatchAbleResult.TypeInfo = nil) or
not ValueFormatterSelectorList.FormatValue(AWatchAbleResult.TypeInfo,
AWatchAbleResult.Value, AWatchAbleResult.DisplayFormat, Result)
AWatchAbleResult.Value, DispFormat, Result)
then begin
Result := AWatchAbleResult.Value;
end;
@ -1509,9 +1514,11 @@ end;
procedure TDbgTreeViewWatchValueMgr.UpdateColumnsText(AWatchAble: TObject;
AWatchAbleResult: IWatchAbleResultIntf; AVNode: PVirtualNode);
var
TheWatch: TIdeWatch absolute AWatchAble;
ResData: TWatchResultData;
WatchValueStr: String;
da: TDBGPtr;
DispFormat: TWatchDisplayFormat;
begin
TreeView.NodeText[AVNode, COL_WATCH_EXPR-1]:= TIdeWatch(AWatchAble).DisplayName;
TreeView.NodeText[AVNode, 2] := '';
@ -1527,15 +1534,19 @@ begin
(AWatchAbleResult.Validity in [ddsValid, ddsInvalid, ddsError]) or // snapshot
(AWatchAbleResult.ResultData <> nil)
then begin
DispFormat := wdfDefault;
if AWatchAble <> nil then
DispFormat := TheWatch.DisplayFormat;
ResData := AWatchAbleResult.ResultData;
if (ResData <> nil) and
not( (ResData.ValueKind = rdkPrePrinted) and (AWatchAbleResult.TypeInfo <> nil) )
then begin
FWatchDlg.FWatchPrinter.FormatFlags := [rpfClearMultiLine];
if not ValueFormatterSelectorList.FormatValue(ResData,
AWatchAbleResult.DisplayFormat, FWatchDlg.FWatchPrinter, WatchValueStr)
DispFormat, FWatchDlg.FWatchPrinter, WatchValueStr)
then begin
WatchValueStr := FWatchDlg.FWatchPrinter.PrintWatchValue(ResData, AWatchAbleResult.DisplayFormat);
WatchValueStr := FWatchDlg.FWatchPrinter.PrintWatchValue(ResData, DispFormat);
if (ResData.ValueKind = rdkArray) and (ResData.ArrayLength > 0)
then
WatchValueStr := Format(drsLen, [ResData.ArrayLength]) + WatchValueStr;
@ -1552,7 +1563,7 @@ begin
else begin
if (AWatchAbleResult.TypeInfo = nil) or
not ValueFormatterSelectorList.FormatValue(AWatchAbleResult.TypeInfo,
AWatchAbleResult.Value, AWatchAbleResult.DisplayFormat, WatchValueStr)
AWatchAbleResult.Value, DispFormat, WatchValueStr)
then begin
WatchValueStr := AWatchAbleResult.Value;
if (AWatchAbleResult.TypeInfo <> nil) and