diff --git a/components/debuggerintf/dbgintfdebuggerbase.pp b/components/debuggerintf/dbgintfdebuggerbase.pp index 22396ed3fd..d4db938868 100644 --- a/components/debuggerintf/dbgintfdebuggerbase.pp +++ b/components/debuggerintf/dbgintfdebuggerbase.pp @@ -256,11 +256,11 @@ type FDebugger: TDebuggerIntf; FMonitor: TDebuggerDataMonitor; procedure SetMonitor(const AValue: TDebuggerDataMonitor); + property Monitor: TDebuggerDataMonitor read FMonitor write SetMonitor; protected procedure DoNewMonitor; virtual; property Debugger: TDebuggerIntf read FDebugger write FDebugger; protected - property Monitor: TDebuggerDataMonitor read FMonitor write SetMonitor; procedure DoStateLeavePauseClean; override; procedure DoStateChange(const AOldState: TDBGState); virtual; @@ -768,32 +768,27 @@ type TWatchesSupplier = class(TDebuggerDataSupplier) private - function GetCurrentWatches: TWatches; function GetMonitor: TWatchesMonitor; procedure SetMonitor(AValue: TWatchesMonitor); + property Monitor: TWatchesMonitor read GetMonitor write SetMonitor; protected procedure DoStateChange(const AOldState: TDBGState); override; // workaround for state changes during TWatchValue.GetValue procedure InternalRequestData(AWatchValue: TWatchValue); virtual; public constructor Create(const ADebugger: TDebuggerIntf); + procedure TriggerInvalidateWatchValues; procedure RequestData(AWatchValue: TWatchValue); - property CurrentWatches: TWatches read GetCurrentWatches; - property Monitor: TWatchesMonitor read GetMonitor write SetMonitor; end; { TWatchesMonitor } TWatchesMonitor = class(TDebuggerDataMonitor) private - FWatches: TWatches; function GetSupplier: TWatchesSupplier; procedure SetSupplier(AValue: TWatchesSupplier); protected - function CreateWatches: TWatches; virtual; + procedure InvalidateWatchValues; virtual; public - constructor Create; - destructor Destroy; override; - property Watches: TWatches read FWatches; property Supplier: TWatchesSupplier read GetSupplier write SetSupplier; end; @@ -4415,13 +4410,6 @@ begin else AWatchValue.SetValidity(ddsInvalid); end; -function TWatchesSupplier.GetCurrentWatches: TWatches; -begin - Result := Nil; - if Monitor <> nil then - Result := Monitor.Watches; -end; - function TWatchesSupplier.GetMonitor: TWatchesMonitor; begin Result := TWatchesMonitor(inherited Monitor); @@ -4445,6 +4433,12 @@ begin AWatchValue.SetValidity(ddsInvalid); end; +procedure TWatchesSupplier.TriggerInvalidateWatchValues; +begin + if Monitor <> nil then + Monitor.InvalidateWatchValues; +end; + constructor TWatchesSupplier.Create(const ADebugger: TDebuggerIntf); begin inherited Create(ADebugger); @@ -4463,21 +4457,9 @@ begin inherited Supplier := AValue; end; -function TWatchesMonitor.CreateWatches: TWatches; +procedure TWatchesMonitor.InvalidateWatchValues; begin - Result := TWatches.Create; -end; - -constructor TWatchesMonitor.Create; -begin - FWatches := CreateWatches; - inherited Create; -end; - -destructor TWatchesMonitor.Destroy; -begin - inherited Destroy; - FreeAndNil(FWatches); + // end; { TLocalsSupplier } diff --git a/components/lazdebuggergdbmi/gdbmidebugger.pp b/components/lazdebuggergdbmi/gdbmidebugger.pp index 711bc6f7bc..2100432777 100644 --- a/components/lazdebuggergdbmi/gdbmidebugger.pp +++ b/components/lazdebuggergdbmi/gdbmidebugger.pp @@ -11271,8 +11271,7 @@ end; procedure TGDBMIWatches.Changed; begin SetLength(FParentFPList, 0); - if CurrentWatches <> nil - then CurrentWatches.ClearValues; + TriggerInvalidateWatchValues; end; procedure TGDBMIWatches.Clear; diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas index 59025257be..c38bea4b53 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas @@ -651,7 +651,7 @@ procedure TFpThreadWorkerModifyUpdate.DoCallback_DecRef(Data: PtrInt); begin // FDebugger.Locals.CurrentLocalsList.Clear; - FDebugger.Watches.CurrentWatches.ClearValues; + FDebugger.Watches.TriggerInvalidateWatchValues; FDebugger.CallStack.CurrentCallStackList.Clear; UnQueue_DecRef; diff --git a/components/lazdebuggers/lazdebuggerfpgdbmi/fpgdbmidebugger.pp b/components/lazdebuggers/lazdebuggerfpgdbmi/fpgdbmidebugger.pp index 258540eca6..d8167025a4 100644 --- a/components/lazdebuggers/lazdebuggerfpgdbmi/fpgdbmidebugger.pp +++ b/components/lazdebuggers/lazdebuggerfpgdbmi/fpgdbmidebugger.pp @@ -222,7 +222,7 @@ procedure IDEMenuClicked(Sender: TObject); begin UseGDB := MenuCmd.Checked; if (CurrentDebugger <> nil) and (CurrentDebugger.Watches <> nil) then - CurrentDebugger.Watches.CurrentWatches.ClearValues; + CurrentDebugger.Watches.TriggerInvalidateWatchValues; if (CurrentDebugger <> nil) and (CurrentDebugger.Locals <> nil) then CurrentDebugger.Locals.CurrentLocalsList.Clear; end; diff --git a/components/lazdebuggers/lazdebugtestbase/ttestdebuggerclasses.pas b/components/lazdebuggers/lazdebugtestbase/ttestdebuggerclasses.pas index 95c2a8ec79..fb03f4863f 100644 --- a/components/lazdebuggers/lazdebugtestbase/ttestdebuggerclasses.pas +++ b/components/lazdebuggers/lazdebugtestbase/ttestdebuggerclasses.pas @@ -118,10 +118,16 @@ type { TTestWatchesMonitor } TTestWatchesMonitor = class(TWatchesMonitor) + private + FWatches: TWatches; protected procedure DoStateChangeEx(const AOldState, ANewState: TDBGState); override; procedure RequestData(AWatchValue: TWatchValue); - function CreateWatches: TWatches; override; + function CreateWatches: TWatches; + public + constructor Create; + destructor Destroy; override; + property Watches: TWatches read FWatches; end; TTestRegistersMonitor = class; @@ -337,6 +343,18 @@ begin TTestWatches(Result).FMonitor := Self; end; +constructor TTestWatchesMonitor.Create; +begin + inherited Create; + FWatches := CreateWatches; +end; + +destructor TTestWatchesMonitor.Destroy; +begin + inherited Destroy; + FreeAndNil(FWatches); +end; + { TTestWatchValue } procedure TTestWatchValue.RequestData; diff --git a/debugger/debugger.pp b/debugger/debugger.pp index 2878ac9e4c..3c89362525 100644 --- a/debugger/debugger.pp +++ b/debugger/debugger.pp @@ -757,6 +757,7 @@ type TIdeWatchesMonitor = class(TWatchesMonitor) private + FWatches: TWatches; FSnapshots: TDebuggerDataSnapShotList; FOnModified: TNotifyEvent; FIgnoreModified: Integer; @@ -768,12 +769,13 @@ type procedure DoStateLeavePause; override; procedure DoStateLeavePauseClean; override; procedure DoModified; override; + procedure InvalidateWatchValues; override; //procedure NotifyChange procedure NotifyAdd(const AWatches: TCurrentWatches; const AWatch: TCurrentWatch); procedure NotifyRemove(const AWatches: TCurrentWatches; const AWatch: TCurrentWatch); procedure NotifyUpdate(const AWatches: TCurrentWatches; const AWatch: TCurrentWatch); procedure RequestData(AWatchValue: TCurrentWatchValue); - function CreateWatches: TWatches; override; + function CreateWatches: TWatches; virtual; function CreateSnapshot(CreateEmpty: Boolean = False): TObject; public constructor Create; @@ -782,6 +784,7 @@ type procedure RemoveNotification(const ANotification: TWatchesNotification); procedure NewSnapshot(AnID: Pointer; CreateEmpty: Boolean = False); procedure RemoveSnapshot(AnID: Pointer); + property Watches: TWatches read FWatches; property CurrentWatches: TCurrentWatches read GetCurrentWatches;// FCurrentWatches; property Snapshots[AnID: Pointer]: TIdeWatches read GetSnapshot; public @@ -3496,6 +3499,13 @@ begin FOnModified(Self); end; +procedure TIdeWatchesMonitor.InvalidateWatchValues; +begin + inherited InvalidateWatchValues; + if Watches <> nil then + Watches.ClearValues; +end; + procedure TIdeWatchesMonitor.NotifyAdd(const AWatches: TCurrentWatches; const AWatch: TCurrentWatch); begin FNotificationList.NotifyAdd(AWatches, AWatch); @@ -3532,6 +3542,7 @@ end; constructor TIdeWatchesMonitor.Create; begin + FWatches := CreateWatches; FSnapshots := TDebuggerDataSnapShotList.Create; FIgnoreModified := 0; FNotificationList := TWatchesNotificationList.Create; @@ -3543,6 +3554,7 @@ begin FSnapshots.Clear; FNotificationList.Clear; inherited Destroy; + FreeAndNil(FWatches); FreeAndNil(FNotificationList); FreeAndNil(FSnapshots); end;