Debugger: Watches - Partly revert d1ca85c248 "change how sub-watches(nested) are retrieved." - In some case sub-watches were executed with outdated parent type info.

This commit is contained in:
Martin 2022-06-22 23:33:02 +02:00
parent 5b625349ee
commit 8f6b3940fa
2 changed files with 36 additions and 3 deletions

View File

@ -882,7 +882,7 @@ begin
exit; exit;
AWatch := TIdeWatch(Sender.OwnerData); AWatch := TIdeWatch(Sender.OwnerData);
if AWatch.Enabled then begin if AWatch.Enabled and AWatch.HasAllValidParents(GetThreadId, GetStackframe) then begin
VNode := tvWatches.FindNodeForItem(AWatch); VNode := tvWatches.FindNodeForItem(AWatch);
if VNode = nil then if VNode = nil then
exit; exit;
@ -1098,7 +1098,7 @@ begin
exit; exit;
InspectLabel.Caption := Watch.Expression; InspectLabel.Caption := Watch.Expression;
if not(Watch.Enabled) then begin if not(Watch.Enabled and Watch.HasAllValidParents(GetThreadId, GetStackframe)) then begin
InspectMemo.WordWrap := True; InspectMemo.WordWrap := True;
InspectMemo.Text := '<evaluating>'; InspectMemo.Text := '<evaluating>';
exit; exit;
@ -1233,7 +1233,7 @@ begin
try try
tvWatches.NodeText[VNode, COL_WATCH_EXPR-1]:= AWatch.DisplayName; tvWatches.NodeText[VNode, COL_WATCH_EXPR-1]:= AWatch.DisplayName;
tvWatches.NodeText[VNode, 2] := ''; tvWatches.NodeText[VNode, 2] := '';
if AWatch.Enabled then begin if AWatch.Enabled and AWatch.HasAllValidParents(GetThreadId, GetStackframe) then begin
WatchValue := AWatch.Values[GetThreadId, GetStackframe]; WatchValue := AWatch.Values[GetThreadId, GetStackframe];
if (WatchValue <> nil) and if (WatchValue <> nil) and
( (GetSelectedSnapshot = nil) or not(WatchValue.Validity in [ddsUnknown, ddsEvaluating, ddsRequested]) ) ( (GetSelectedSnapshot = nil) or not(WatchValue.Validity in [ddsUnknown, ddsEvaluating, ddsRequested]) )

View File

@ -587,6 +587,7 @@ type
function GetChildrenByNameAsField(AName, AClassName: String): TIdeWatch; function GetChildrenByNameAsField(AName, AClassName: String): TIdeWatch;
function GetTopParentWatch: TIdeWatch; function GetTopParentWatch: TIdeWatch;
function GetValue(const AThreadId: Integer; const AStackFrame: Integer): TIdeWatchValue; function GetValue(const AThreadId: Integer; const AStackFrame: Integer): TIdeWatchValue;
function GetAnyValidParentWatchValue(AThreadId: Integer; AStackFrame: Integer): TIdeWatchValue;
function GetWatchDisplayName: String; function GetWatchDisplayName: String;
protected protected
procedure InitChildWatches; procedure InitChildWatches;
@ -613,6 +614,7 @@ type
procedure LimitChildWatchCount(AMaxCnt: Integer; AKeepIndexEntriesBelow: Int64 = low(Int64)); procedure LimitChildWatchCount(AMaxCnt: Integer; AKeepIndexEntriesBelow: Int64 = low(Int64));
property ChildrenByNameAsField[AName, AClassName: String]: TIdeWatch read GetChildrenByNameAsField; property ChildrenByNameAsField[AName, AClassName: String]: TIdeWatch read GetChildrenByNameAsField;
property ChildrenByNameAsArrayEntry[AName: Int64]: TIdeWatch read GetChildrenByNameAsArrayEntry; property ChildrenByNameAsArrayEntry[AName: Int64]: TIdeWatch read GetChildrenByNameAsArrayEntry;
function HasAllValidParents(AThreadId: Integer; AStackFrame: Integer): boolean;
property ParentWatch: TIdeWatch read FParentWatch; property ParentWatch: TIdeWatch read FParentWatch;
property TopParentWatch: TIdeWatch read GetTopParentWatch; property TopParentWatch: TIdeWatch read GetTopParentWatch;
property DisplayName: String read GetWatchDisplayName write FDisplayName; property DisplayName: String read GetWatchDisplayName write FDisplayName;
@ -6244,6 +6246,17 @@ begin
end; end;
end; end;
function TIdeWatch.HasAllValidParents(AThreadId: Integer; AStackFrame: Integer
): boolean;
begin
Result := FParentWatch = nil;
if Result then
exit;
Result := (GetAnyValidParentWatchValue(AThreadId, AStackFrame) <> nil) and
FParentWatch.HasAllValidParents(AThreadId, AStackFrame);
end;
procedure TIdeWatch.DoEnableChange; procedure TIdeWatch.DoEnableChange;
begin begin
Changed; Changed;
@ -6267,6 +6280,26 @@ begin
Result := TIdeWatchValue(inherited Values[AThreadId, AStackFrame]); Result := TIdeWatchValue(inherited Values[AThreadId, AStackFrame]);
end; end;
function TIdeWatch.GetAnyValidParentWatchValue(AThreadId: Integer;
AStackFrame: Integer): TIdeWatchValue;
var
i: Integer;
vl: TWatchValueList;
begin
Result := nil;
if FParentWatch = nil then
exit;
vl := FParentWatch.FValueList;
i := vl.Count - 1;
while (i >= 0) and (
(vl.EntriesByIdx[i].Validity <> ddsValid) or
(vl.EntriesByIdx[i].ThreadId <> AThreadId) or
(vl.EntriesByIdx[i].StackFrame <> AStackFrame)
) do
dec(i);
if i >= 0 then
Result := TIdeWatchValue(vl.EntriesByIdx[i]);
end;
function TIdeWatch.GetWatchDisplayName: String; function TIdeWatch.GetWatchDisplayName: String;
begin begin
if FDisplayName <> '' then if FDisplayName <> '' then