IDE, Debugger-Intf: Clean-up, Move Watches list from DbgIntf to IDE

This commit is contained in:
Martin 2021-11-22 18:14:20 +01:00
parent 8e10ed53af
commit 717ec4887d
6 changed files with 47 additions and 36 deletions

View File

@ -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 }

View File

@ -11271,8 +11271,7 @@ end;
procedure TGDBMIWatches.Changed;
begin
SetLength(FParentFPList, 0);
if CurrentWatches <> nil
then CurrentWatches.ClearValues;
TriggerInvalidateWatchValues;
end;
procedure TGDBMIWatches.Clear;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;