DBG: Refactor, clean up

git-svn-id: trunk@31131 -
This commit is contained in:
martin 2011-06-08 00:46:39 +00:00
parent 00bbb01e5d
commit 58dbddba3e
9 changed files with 433 additions and 597 deletions

View File

@ -116,8 +116,6 @@ type
procedure popDeleteAllClick(Sender: TObject); procedure popDeleteAllClick(Sender: TObject);
private private
FBaseDirectory: string; FBaseDirectory: string;
FBreakPoints: TIDEBreakPoints;
FBreakpointsNotification: TIDEBreakPointsNotification;
FStates: TBreakPointsDlgStates; FStates: TBreakPointsDlgStates;
FLockActionUpdate: Integer; FLockActionUpdate: Integer;
procedure BreakPointAdd(const ASender: TIDEBreakPoints; procedure BreakPointAdd(const ASender: TIDEBreakPoints;
@ -128,8 +126,6 @@ type
const ABreakpoint: TIDEBreakPoint); const ABreakpoint: TIDEBreakPoint);
procedure SetBaseDirectory(const AValue: string); procedure SetBaseDirectory(const AValue: string);
procedure SetBreakPoints(const AValue: TIDEBreakPoints);
procedure UpdateItem(const AnItem: TListItem; procedure UpdateItem(const AnItem: TListItem;
const ABreakpoint: TIDEBreakPoint); const ABreakpoint: TIDEBreakPoint);
procedure UpdateAll; procedure UpdateAll;
@ -138,15 +134,15 @@ type
procedure JumpToCurrentBreakPoint; procedure JumpToCurrentBreakPoint;
procedure ShowProperties; procedure ShowProperties;
protected protected
procedure DoBreakPointsChanged; override;
procedure DoBeginUpdate; override; procedure DoBeginUpdate; override;
procedure DoEndUpdate; override; procedure DoEndUpdate; override;
procedure DisableAllActions; procedure DisableAllActions;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
public public
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory; property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property BreakPoints: TIDEBreakPoints read FBreakPoints write SetBreakPoints; property BreakPoints;
end; end;
function GetBreakPointStateDescription(ABreakpoint: TBaseBreakpoint): string; function GetBreakPointStateDescription(ABreakpoint: TBaseBreakpoint): string;
@ -241,43 +237,13 @@ begin
UpdateAll; UpdateAll;
end; end;
procedure TBreakPointsDlg.SetBreakPoints(const AValue: TIDEBreakPoints);
var
i: Integer;
begin
if FBreakPoints = AValue then Exit;
BeginUpdate;
try
lvBreakPoints.Items.Clear;
if FBreakPoints <> nil
then begin
FBreakPoints.RemoveNotification(FBreakpointsNotification);
end;
FBreakPoints:=AValue;
if FBreakPoints <> nil
then begin
FBreakPoints.AddNotification(FBreakpointsNotification);
for i:=0 to FBreakPoints.Count-1 do
BreakPointUpdate(FBreakPoints, FBreakPoints.Items[i]);
end;
finally
EndUpdate;
end;
end;
constructor TBreakPointsDlg.Create(AOwner: TComponent); constructor TBreakPointsDlg.Create(AOwner: TComponent);
begin begin
inherited; inherited;
Name:='BreakPointsDlg'; Name:='BreakPointsDlg';
FBreakpointsNotification := TIDEBreakPointsNotification.Create; BreakpointsNotification.OnAdd := @BreakPointAdd;
FBreakpointsNotification.AddReference; BreakpointsNotification.OnUpdate := @BreakPointUpdate;
FBreakpointsNotification.OnAdd := @BreakPointAdd; BreakpointsNotification.OnRemove := @BreakPointRemove;
FBreakpointsNotification.OnUpdate := @BreakPointUpdate;
FBreakpointsNotification.OnRemove := @BreakPointRemove;
ActionList1.Images := IDEImages.Images_16; ActionList1.Images := IDEImages.Images_16;
ToolBar1.Images := IDEImages.Images_16; ToolBar1.Images := IDEImages.Images_16;
@ -320,16 +286,6 @@ begin
FLockActionUpdate := 0; FLockActionUpdate := 0;
end; end;
destructor TBreakPointsDlg.Destroy;
begin
SetBreakPoints(nil);
FBreakpointsNotification.OnAdd := nil;
FBreakpointsNotification.OnUpdate := nil;
FBreakpointsNotification.OnRemove := nil;
FBreakpointsNotification.ReleaseReference;
inherited;
end;
procedure TBreakPointsDlg.lvBreakPointsColumnClick(Sender: TObject; procedure TBreakPointsDlg.lvBreakPointsColumnClick(Sender: TObject;
Column: TListColumn); Column: TListColumn);
begin begin
@ -829,6 +785,18 @@ begin
DebugBoss.ShowBreakPointProperties(CurBreakPoint); DebugBoss.ShowBreakPointProperties(CurBreakPoint);
end; end;
procedure TBreakPointsDlg.DoBreakPointsChanged;
var
i: Integer;
begin
lvBreakPoints.Items.Clear;
if BreakPoints <> nil
then begin
for i:=0 to BreakPoints.Count-1 do
BreakPointUpdate(BreakPoints, BreakPoints.Items[i]);
end;
end;
procedure TBreakPointsDlg.DoBeginUpdate; procedure TBreakPointsDlg.DoBeginUpdate;
begin begin
inherited DoBeginUpdate; inherited DoBeginUpdate;

View File

@ -59,31 +59,31 @@ inherited CallStackDlg: TCallStackDlg
ShowHint = True ShowHint = True
TabOrder = 1 TabOrder = 1
object ToolButtonShow: TToolButton object ToolButtonShow: TToolButton
Left = 110 Left = 112
Top = 0 Top = 0
Action = actShow Action = actShow
ImageIndex = 0 ImageIndex = 0
end end
object ToolButtonCurrent: TToolButton object ToolButtonCurrent: TToolButton
Left = 160 Left = 162
Top = 0 Top = 0
Action = actSetCurrent Action = actSetCurrent
end end
object ToolButton4: TToolButton object ToolButton4: TToolButton
Left = 210 Left = 212
Top = 0 Top = 0
Width = 8 Width = 10
Caption = 'ToolButton4' Caption = 'ToolButton4'
Style = tbsSeparator Style = tbsSeparator
end end
object ToolButtonMore: TToolButton object ToolButtonMore: TToolButton
Left = 280 Left = 284
Top = 0 Top = 0
Action = actViewMore Action = actViewMore
ImageIndex = 1 ImageIndex = 1
end end
object ToolButtonMax: TToolButton object ToolButtonMax: TToolButton
Left = 218 Left = 222
Top = 0 Top = 0
Action = actViewLimit Action = actViewLimit
Caption = 'Max 10' Caption = 'Max 10'
@ -91,7 +91,7 @@ inherited CallStackDlg: TCallStackDlg
Style = tbsDropDown Style = tbsDropDown
end end
object ToolButtonGoto: TToolButton object ToolButtonGoto: TToolButton
Left = 488 Left = 494
Top = 0 Top = 0
Action = actViewGoto Action = actViewGoto
ImageIndex = 4 ImageIndex = 4
@ -105,31 +105,31 @@ inherited CallStackDlg: TCallStackDlg
object ToolButton8: TToolButton object ToolButton8: TToolButton
Left = 102 Left = 102
Top = 0 Top = 0
Width = 8 Width = 10
Caption = 'ToolButton8' Caption = 'ToolButton8'
Style = tbsSeparator Style = tbsSeparator
end end
object ToolButton9: TToolButton object ToolButton9: TToolButton
Left = 330 Left = 334
Top = 0 Top = 0
Width = 8 Width = 10
Caption = 'ToolButton9' Caption = 'ToolButton9'
Style = tbsSeparator Style = tbsSeparator
end end
object ToolButtonTop: TToolButton object ToolButtonTop: TToolButton
Left = 338 Left = 344
Top = 0 Top = 0
Action = actViewTop Action = actViewTop
ImageIndex = 2 ImageIndex = 2
end end
object ToolButtonBottom: TToolButton object ToolButtonBottom: TToolButton
Left = 388 Left = 394
Top = 0 Top = 0
Action = actViewBottom Action = actViewBottom
ImageIndex = 3 ImageIndex = 3
end end
object Panel1: TPanel object Panel1: TPanel
Left = 438 Left = 444
Height = 40 Height = 40
Top = 0 Top = 0
Width = 50 Width = 50
@ -158,9 +158,9 @@ inherited CallStackDlg: TCallStackDlg
Style = tbsCheck Style = tbsCheck
end end
object ToolButton2: TToolButton object ToolButton2: TToolButton
Left = 538 Left = 544
Top = 0 Top = 0
Width = 8 Width = 10
Caption = 'ToolButton2' Caption = 'ToolButton2'
Style = tbsSeparator Style = tbsSeparator
end end

View File

@ -98,40 +98,27 @@ type
procedure actSetAsCurrentClick(Sender : TObject); procedure actSetAsCurrentClick(Sender : TObject);
procedure actShowClick(Sender: TObject); procedure actShowClick(Sender: TObject);
private private
FBreakPoints: TIDEBreakPoints;
FCallStackMonitor: TCallStackMonitor;
FCallStackNotification: TCallStackNotification;
FSnapshotManager: TSnapshotManager;
FThreadNotification: TThreadsNotification;
FBreakpointsNotification: TIDEBreakPointsNotification;
FSnapshotNotification: TSnapshotNotification;
FThreadsMonitor: TThreadsMonitor;
FViewCount: Integer; FViewCount: Integer;
FViewLimit: Integer; FViewLimit: Integer;
FViewStart: Integer; FViewStart: Integer;
FPowerImgIdx, FPowerImgIdxGrey: Integer; FPowerImgIdx, FPowerImgIdxGrey: Integer;
FInUpdateView: Boolean; FInUpdateView: Boolean;
function GetImageIndex(Entry: TCallStackEntry): Integer; function GetImageIndex(Entry: TCallStackEntry): Integer;
procedure SetBreakPoints(const AValue: TIDEBreakPoints);
procedure SetSnapshotManager(const AValue: TSnapshotManager);
procedure SetThreadsMonitor(const AValue: TThreadsMonitor);
procedure SetViewLimit(const AValue: Integer); procedure SetViewLimit(const AValue: Integer);
procedure SetViewStart(AStart: Integer); procedure SetViewStart(AStart: Integer);
procedure SetViewMax; procedure SetViewMax;
procedure BreakPointChanged(const ASender: TIDEBreakPoints; const ABreakpoint: TIDEBreakPoint); procedure BreakPointChanged(const ASender: TIDEBreakPoints; const ABreakpoint: TIDEBreakPoint);
procedure CallStackChanged(Sender: TObject); procedure CallStackChanged(Sender: TObject);
procedure CallStackCurrent(Sender: TObject); procedure CallStackCurrent(Sender: TObject);
procedure ThreadsCurrent(Sender: TObject);
procedure SnapshotChanged(Sender: TObject);
procedure GotoIndex(AIndex: Integer); procedure GotoIndex(AIndex: Integer);
function GetCurrentEntry: TCallStackEntry; function GetCurrentEntry: TCallStackEntry;
function GetFunction(const Entry: TCallStackEntry): string; function GetFunction(const Entry: TCallStackEntry): string;
procedure SetCallStackMonitor(const AValue: TCallStackMonitor);
procedure UpdateView; procedure UpdateView;
procedure JumpToSource; procedure JumpToSource;
procedure CopyToClipBoard; procedure CopyToClipBoard;
procedure ToggleBreakpoint(Item: TListItem); procedure ToggleBreakpoint(Item: TListItem);
protected protected
procedure DoBreakPointsChanged; override;
procedure DoBeginUpdate; override; procedure DoBeginUpdate; override;
procedure DoEndUpdate; override; procedure DoEndUpdate; override;
procedure DisableAllActions; procedure DisableAllActions;
@ -141,12 +128,10 @@ type
function GetSelectedCallstack: TCallStack; function GetSelectedCallstack: TCallStack;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; property BreakPoints;
property CallStackMonitor;
property BreakPoints: TIDEBreakPoints read FBreakPoints write SetBreakPoints; property ThreadsMonitor;
property CallStackMonitor: TCallStackMonitor read FCallStackMonitor write SetCallStackMonitor; property SnapshotManager;
property ThreadsMonitor: TThreadsMonitor read FThreadsMonitor write SetThreadsMonitor;
property SnapshotManager: TSnapshotManager read FSnapshotManager write SetSnapshotManager;
property ViewLimit: Integer read FViewLimit write SetViewLimit; property ViewLimit: Integer read FViewLimit write SetViewLimit;
end; end;
@ -170,24 +155,13 @@ var
constructor TCallStackDlg.Create(AOwner: TComponent); constructor TCallStackDlg.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FCallStackNotification := TCallStackNotification.Create; CallStackNotification.OnChange := @CallStackChanged;
FCallStackNotification.AddReference; CallStackNotification.OnCurrent := @CallStackCurrent;
FCallStackNotification.OnChange := @CallStackChanged; BreakpointsNotification.OnAdd := @BreakPointChanged;
FCallStackNotification.OnCurrent := @CallStackCurrent; BreakpointsNotification.OnUpdate := @BreakPointChanged;
BreakpointsNotification.OnRemove := @BreakPointChanged;
FBreakpointsNotification := TIDEBreakPointsNotification.Create; ThreadsNotification.OnCurrent := @CallStackChanged;
FBreakpointsNotification.AddReference; SnapshotNotification.OnCurrent := @CallStackChanged;
FBreakpointsNotification.OnAdd := @BreakPointChanged;
FBreakpointsNotification.OnUpdate := @BreakPointChanged;
FBreakpointsNotification.OnRemove := @BreakPointChanged;
FThreadNotification := TThreadsNotification.Create;
FThreadNotification.AddReference;
FThreadNotification.OnCurrent := @ThreadsCurrent;
FSnapshotNotification := TSnapshotNotification.Create;
FSnapshotNotification.AddReference;
FSnapshotNotification.OnCurrent := @SnapshotChanged;
FViewLimit := 10; FViewLimit := 10;
FViewCount := 10; FViewCount := 10;
@ -347,29 +321,6 @@ begin
end; end;
end; end;
destructor TCallStackDlg.Destroy;
begin
SetBreakPoints(nil);
FBreakpointsNotification.OnAdd := nil;
FBreakpointsNotification.OnUpdate := nil;
FBreakpointsNotification.OnRemove := nil;
FBreakpointsNotification.ReleaseReference;
SetCallStackMonitor(nil);
FCallStackNotification.OnChange := nil;
FCallStackNotification.ReleaseReference;
SetThreadsMonitor(nil);
FThreadNotification.OnCurrent := nil;
FThreadNotification.ReleaseReference;
SetSnapshotManager(nil);
FSnapshotNotification.OnChange := nil;
FSnapshotNotification.OnCurrent := nil;
FSnapshotNotification.ReleaseReference;
inherited Destroy;
end;
procedure TCallStackDlg.DoBeginUpdate; procedure TCallStackDlg.DoBeginUpdate;
begin begin
DisableAllActions; DisableAllActions;
@ -414,10 +365,10 @@ end;
function TCallStackDlg.GetSelectedThreads(Snap: TSnapshot): TThreads; function TCallStackDlg.GetSelectedThreads(Snap: TSnapshot): TThreads;
begin begin
if FThreadsMonitor = nil then exit(nil); if ThreadsMonitor = nil then exit(nil);
if Snap = nil if Snap = nil
then Result := FThreadsMonitor.CurrentThreads then Result := ThreadsMonitor.CurrentThreads
else Result := FThreadsMonitor.Snapshots[Snap]; else Result := ThreadsMonitor.Snapshots[Snap];
end; end;
function TCallStackDlg.GetSelectedCallstack: TCallStack; function TCallStackDlg.GetSelectedCallstack: TCallStack;
@ -539,6 +490,11 @@ begin
end; end;
end; end;
procedure TCallStackDlg.DoBreakPointsChanged;
begin
UpdateView;
end;
procedure TCallStackDlg.lvCallStackDBLCLICK(Sender: TObject); procedure TCallStackDlg.lvCallStackDBLCLICK(Sender: TObject);
begin begin
JumpToSource; JumpToSource;
@ -552,16 +508,6 @@ begin
actViewLimit.Caption := TMenuItem(Sender).Caption; actViewLimit.Caption := TMenuItem(Sender).Caption;
end; end;
procedure TCallStackDlg.SnapshotChanged(Sender: TObject);
begin
CallStackChanged(nil);
end;
procedure TCallStackDlg.ThreadsCurrent(Sender: TObject);
begin
CallStackChanged(nil);
end;
procedure TCallStackDlg.ToolButtonPowerClick(Sender: TObject); procedure TCallStackDlg.ToolButtonPowerClick(Sender: TObject);
begin begin
if ToolButtonPower.Down if ToolButtonPower.Down
@ -774,30 +720,6 @@ begin
// else lblViewCnt.Caption:= IntToStr(GetSelectedCallstack.Count); // else lblViewCnt.Caption:= IntToStr(GetSelectedCallstack.Count);
end; end;
procedure TCallStackDlg.SetCallStackMonitor(const AValue: TCallStackMonitor);
begin
if FCallStackMonitor = AValue then Exit;
BeginUpdate;
try
if FCallStackMonitor <> nil
then begin
FCallStackMonitor.RemoveNotification(FCallStackNotification);
end;
FCallStackMonitor := AValue;
if FCallStackMonitor <> nil
then begin
FCallStackMonitor.AddNotification(FCallStackNotification);
end;
CallStackChanged(nil);
finally
EndUpdate;
end;
end;
procedure TCallStackDlg.SetViewLimit(const AValue: Integer); procedure TCallStackDlg.SetViewLimit(const AValue: Integer);
begin begin
ToolButtonPower.Down := True; ToolButtonPower.Down := True;
@ -814,42 +736,6 @@ begin
UpdateView; UpdateView;
end; end;
procedure TCallStackDlg.SetBreakPoints(const AValue: TIDEBreakPoints);
begin
if FBreakPoints = AValue then Exit;
if FBreakPoints <> nil
then begin
FBreakPoints.RemoveNotification(FBreakpointsNotification);
end;
FBreakPoints := AValue;
if FBreakPoints <> nil
then begin
FBreakPoints.AddNotification(FBreakpointsNotification);
end;
UpdateView;
end;
procedure TCallStackDlg.SetSnapshotManager(const AValue: TSnapshotManager);
begin
if FSnapshotManager = AValue then exit;
if FSnapshotManager <> nil then FSnapshotManager.RemoveNotification(FSnapshotNotification);
FSnapshotManager := AValue;
if FSnapshotManager <> nil then FSnapshotManager.AddNotification(FSnapshotNotification);
UpdateView;
end;
procedure TCallStackDlg.SetThreadsMonitor(const AValue: TThreadsMonitor);
begin
if FThreadsMonitor = AValue then exit;
if FThreadsMonitor <> nil then FThreadsMonitor.RemoveNotification(FThreadNotification);
FThreadsMonitor := AValue;
if FThreadsMonitor <> nil then FThreadsMonitor.AddNotification(FThreadNotification);
ThreadsCurrent(FThreadsMonitor);
end;
function TCallStackDlg.GetFunction(const Entry: TCallStackEntry): string; function TCallStackDlg.GetFunction(const Entry: TCallStackEntry): string;
begin begin
Result := Entry.GetFunctionWithArg; Result := Entry.GetFunctionWithArg;

View File

@ -56,6 +56,50 @@ type
procedure BeginUpdate; procedure BeginUpdate;
procedure EndUpdate; procedure EndUpdate;
function UpdateCount: integer; function UpdateCount: integer;
private (* provide some common properties *)
FSnapshotManager: TSnapshotManager;
FSnapshotNotification: TSnapshotNotification;
FThreadsMonitor: TThreadsMonitor;
FThreadsNotification: TThreadsNotification;
FCallStackMonitor: TCallStackMonitor;
FCallStackNotification: TCallStackNotification;
FLocalsMonitor: TLocalsMonitor;
FLocalsNotification: TLocalsNotification;
FWatchesMonitor: TWatchesMonitor;
FWatchesNotification: TWatchesNotification;
FBreakPoints: TIDEBreakPoints;
FBreakpointsNotification: TIDEBreakPointsNotification;
function GetSnapshotNotification: TSnapshotNotification;
function GetThreadsNotification: TThreadsNotification;
function GetCallStackNotification: TCallStackNotification;
function GetLocalsNotification: TLocalsNotification;
function GetWatchesNotification: TWatchesNotification;
function GetBreakpointsNotification: TIDEBreakPointsNotification;
procedure SetSnapshotManager(const AValue: TSnapshotManager);
procedure SetThreadsMonitor(const AValue: TThreadsMonitor);
procedure SetCallStackMonitor(const AValue: TCallStackMonitor);
procedure SetLocalsMonitor(const AValue: TLocalsMonitor);
procedure SetWatchesMonitor(const AValue: TWatchesMonitor);
procedure SetBreakPoints(const AValue: TIDEBreakPoints);
protected
procedure DoWatchesChanged; virtual; // called if the WatchesMonitor object was changed
procedure DoBreakPointsChanged; virtual; // called if the BreakPoint(Monitor) object was changed
property SnapshotNotification: TSnapshotNotification read GetSnapshotNotification;
property ThreadsNotification: TThreadsNotification read GetThreadsNotification;
property CallStackNotification: TCallStackNotification read GetCallStackNotification;
property LocalsNotification: TLocalsNotification read GetLocalsNotification;
property WatchesNotification: TWatchesNotification read GetWatchesNotification;
property BreakpointsNotification: TIDEBreakPointsNotification read GetBreakpointsNotification;
protected
// publish as needed
property SnapshotManager: TSnapshotManager read FSnapshotManager write SetSnapshotManager;
property ThreadsMonitor: TThreadsMonitor read FThreadsMonitor write SetThreadsMonitor;
property CallStackMonitor: TCallStackMonitor read FCallStackMonitor write SetCallStackMonitor;
property LocalsMonitor: TLocalsMonitor read FLocalsMonitor write SetLocalsMonitor;
property WatchesMonitor: TWatchesMonitor read FWatchesMonitor write SetWatchesMonitor;
property BreakPoints: TIDEBreakPoints read FBreakPoints write SetBreakPoints;
public
destructor Destroy; override;
end; end;
TDebuggerDlgClass = class of TDebuggerDlg; TDebuggerDlgClass = class of TDebuggerDlg;
@ -84,6 +128,229 @@ begin
Result := FUpdateCount; Result := FUpdateCount;
end; end;
function TDebuggerDlg.GetSnapshotNotification: TSnapshotNotification;
begin
If FSnapshotNotification = nil then begin
FSnapshotNotification := TSnapshotNotification.Create;
FSnapshotNotification.AddReference;
if (FSnapshotManager <> nil)
then FSnapshotManager.AddNotification(FSnapshotNotification);
end;
Result := FSnapshotNotification;
end;
function TDebuggerDlg.GetThreadsNotification: TThreadsNotification;
begin
if FThreadsNotification = nil then begin
FThreadsNotification := TThreadsNotification.Create;
FThreadsNotification.AddReference;
if (FThreadsMonitor <> nil)
then FThreadsMonitor.AddNotification(FThreadsNotification);
end;
Result := FThreadsNotification;
end;
function TDebuggerDlg.GetCallStackNotification: TCallStackNotification;
begin
if FCallStackNotification = nil then begin
FCallStackNotification := TCallStackNotification.Create;
FCallStackNotification.AddReference;
if (FCallStackMonitor <> nil)
then FCallStackMonitor.AddNotification(FCallStackNotification);
end;
Result := FCallStackNotification;
end;
function TDebuggerDlg.GetLocalsNotification: TLocalsNotification;
begin
If FLocalsNotification = nil then begin
FLocalsNotification := TLocalsNotification.Create;
FLocalsNotification.AddReference;
if (FLocalsMonitor <> nil)
then FLocalsMonitor.AddNotification(FLocalsNotification);
end;
Result := FLocalsNotification;
end;
function TDebuggerDlg.GetWatchesNotification: TWatchesNotification;
begin
If FWatchesNotification = nil then begin
FWatchesNotification := TWatchesNotification.Create;
FWatchesNotification.AddReference;
if (FWatchesMonitor <> nil)
then FWatchesMonitor.AddNotification(FWatchesNotification);
end;
Result := FWatchesNotification;
end;
function TDebuggerDlg.GetBreakpointsNotification: TIDEBreakPointsNotification;
begin
If FBreakpointsNotification = nil then begin
FBreakpointsNotification := TIDEBreakPointsNotification.Create;
FBreakpointsNotification.AddReference;
if (FBreakPoints <> nil)
then FBreakPoints.AddNotification(FBreakpointsNotification);
end;
Result := FBreakpointsNotification;
end;
procedure TDebuggerDlg.SetSnapshotManager(const AValue: TSnapshotManager);
begin
if FSnapshotManager = AValue then exit;
BeginUpdate;
try
if (FSnapshotManager <> nil) and (FSnapshotNotification <> nil)
then FSnapshotManager.RemoveNotification(FSnapshotNotification);
FSnapshotManager := AValue;
if (FSnapshotManager <> nil) and (FSnapshotNotification <> nil)
then FSnapshotManager.AddNotification(FSnapshotNotification);
if assigned(FSnapshotNotification.OnChange) then FSnapshotNotification.OnChange(nil);
if assigned(FSnapshotNotification.OnCurrent) then FSnapshotNotification.OnCurrent(nil);
finally
EndUpdate;
end;
end;
procedure TDebuggerDlg.SetThreadsMonitor(const AValue: TThreadsMonitor);
begin
if FThreadsMonitor = AValue then exit;
BeginUpdate;
try
if (FThreadsMonitor <> nil) and (FThreadsNotification <> nil)
then FThreadsMonitor.RemoveNotification(FThreadsNotification);
FThreadsMonitor := AValue;
if (FThreadsMonitor <> nil) and (FThreadsNotification <> nil)
then FThreadsMonitor.AddNotification(FThreadsNotification);
if assigned(FThreadsNotification.OnChange) then FThreadsNotification.OnChange(nil);
if assigned(FThreadsNotification.OnCurrent) then FThreadsNotification.OnCurrent(nil);
finally
EndUpdate;
end;
end;
procedure TDebuggerDlg.SetCallStackMonitor(const AValue: TCallStackMonitor);
begin
if FCallStackMonitor = AValue then exit;
BeginUpdate;
try
if (FCallStackMonitor <> nil) and (FCallStackNotification <> nil)
then FCallStackMonitor.RemoveNotification(FCallStackNotification);
FCallStackMonitor := AValue;
if (FCallStackMonitor <> nil) and (FCallStackNotification <> nil)
then FCallStackMonitor.AddNotification(FCallStackNotification);
if assigned(FCallStackNotification.OnChange) then FCallStackNotification.OnChange(nil);
if assigned(FCallStackNotification.OnCurrent) then FCallStackNotification.OnCurrent(nil);
finally
EndUpdate;
end;
end;
procedure TDebuggerDlg.SetLocalsMonitor(const AValue: TLocalsMonitor);
begin
if FLocalsMonitor = AValue then exit;
BeginUpdate;
try
if (FLocalsMonitor <> nil) and (FLocalsNotification <> nil)
then FLocalsMonitor.RemoveNotification(FLocalsNotification);
FLocalsMonitor := AValue;
if (FLocalsMonitor <> nil) and (FLocalsNotification <> nil)
then FLocalsMonitor.AddNotification(FLocalsNotification);
if assigned(FLocalsNotification.OnChange) then FLocalsNotification.OnChange(nil);
finally
EndUpdate;
end;
end;
procedure TDebuggerDlg.SetWatchesMonitor(const AValue: TWatchesMonitor);
begin
if FWatchesMonitor = AValue then exit;
BeginUpdate;
try
if (FWatchesMonitor <> nil) and (FWatchesNotification <> nil)
then FWatchesMonitor.RemoveNotification(FWatchesNotification);
FWatchesMonitor := AValue;
if (FWatchesMonitor <> nil) and (FWatchesNotification <> nil)
then FWatchesMonitor.AddNotification(FWatchesNotification);
DoWatchesChanged;
finally
EndUpdate;
end;
end;
procedure TDebuggerDlg.SetBreakPoints(const AValue: TIDEBreakPoints);
begin
if FBreakPoints = AValue then exit;
BeginUpdate;
try
if (FBreakPoints <> nil) and (FBreakpointsNotification <> nil)
then FBreakPoints.RemoveNotification(FBreakpointsNotification);
FBreakPoints := AValue;
if (FBreakPoints <> nil) and (FBreakpointsNotification <> nil)
then FBreakPoints.AddNotification(FBreakpointsNotification);
DoBreakPointsChanged;
finally
EndUpdate;
end;
end;
procedure TDebuggerDlg.DoWatchesChanged;
begin
//
end;
procedure TDebuggerDlg.DoBreakPointsChanged;
begin
//
end;
destructor TDebuggerDlg.Destroy;
begin
if FSnapshotNotification <> nil then begin;
FSnapshotNotification.OnChange := nil;
FSnapshotNotification.OnCurrent := nil;
end;
SetSnapshotManager(nil);
ReleaseAndNil(FSnapshotNotification);
if FThreadsNotification <> nil then begin;
FThreadsNotification.OnChange := nil;
FThreadsNotification.OnCurrent := nil;
end;
SetThreadsMonitor(nil);
ReleaseAndNil(FThreadsNotification);
if FCallStackNotification <> nil then begin;
FCallStackNotification.OnChange := nil;
FCallStackNotification.OnCurrent := nil;
end;
SetCallStackMonitor(nil);
ReleaseAndNil(FCallStackNotification);
if FLocalsNotification <> nil then begin;
FLocalsNotification.OnChange := nil;
end;
SetLocalsMonitor(nil);
ReleaseAndNil(FLocalsNotification);
if FWatchesNotification <> nil then begin;
FWatchesNotification.OnAdd := nil;
FWatchesNotification.OnRemove := nil;
FWatchesNotification.OnUpdate := nil;
end;
SetWatchesMonitor(nil);
ReleaseAndNil(FWatchesNotification);
if FBreakpointsNotification <> nil then begin;
FBreakpointsNotification.OnAdd := nil;
FBreakpointsNotification.OnRemove := nil;
FBreakpointsNotification.OnUpdate := nil;
end;
SetBreakPoints(nil);
ReleaseAndNil(FBreakpointsNotification);
inherited Destroy;
end;
procedure TDebuggerDlg.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure TDebuggerDlg.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var var
Command: Word; Command: Word;

View File

@ -33,20 +33,16 @@ type
procedure tbPowerClick(Sender: TObject); procedure tbPowerClick(Sender: TObject);
procedure tbRemoveClick(Sender: TObject); procedure tbRemoveClick(Sender: TObject);
private private
FSnapshotManager: TSnapshotManager;
FSnapshotNotification: TSnapshotNotification;
FInSnapshotChanged: Boolean; FInSnapshotChanged: Boolean;
imgCurrentLine: Integer; imgCurrentLine: Integer;
FPowerImgIdx, FPowerImgIdxGrey: Integer; FPowerImgIdx, FPowerImgIdxGrey: Integer;
FEnabledImgIdx, FDisabledIdx: Integer; FEnabledImgIdx, FDisabledIdx: Integer;
procedure SetSnapshotManager(const AValue: TSnapshotManager);
procedure SnapshotChanged(Sender: TObject); procedure SnapshotChanged(Sender: TObject);
procedure UpdateToolbar; procedure UpdateToolbar;
public public
{ public declarations } { public declarations }
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; property SnapshotManager;
property SnapshotManager: TSnapshotManager read FSnapshotManager write SetSnapshotManager;
end; end;
implementation implementation
@ -58,24 +54,24 @@ implementation
procedure THistoryDialog.lvHistoryDblClick(Sender: TObject); procedure THistoryDialog.lvHistoryDblClick(Sender: TObject);
begin begin
if tbHist.Down then begin if tbHist.Down then begin
if (FSnapshotManager.HistoryIndex = lvHistory.Selected.Index) and if (SnapshotManager.HistoryIndex = lvHistory.Selected.Index) and
(FSnapshotManager.HistorySelected) (SnapshotManager.HistorySelected)
then begin then begin
FSnapshotManager.HistorySelected := False; SnapshotManager.HistorySelected := False;
end end
else begin else begin
FSnapshotManager.HistoryIndex := lvHistory.Selected.Index; SnapshotManager.HistoryIndex := lvHistory.Selected.Index;
FSnapshotManager.HistorySelected := True; SnapshotManager.HistorySelected := True;
end; end;
end else begin end else begin
if (FSnapshotManager.SnapshotIndex = lvHistory.Selected.Index) and if (SnapshotManager.SnapshotIndex = lvHistory.Selected.Index) and
(FSnapshotManager.SnapshotSelected) (SnapshotManager.SnapshotSelected)
then begin then begin
FSnapshotManager.SnapshotSelected := False; SnapshotManager.SnapshotSelected := False;
end end
else begin else begin
FSnapshotManager.SnapshotIndex := lvHistory.Selected.Index; SnapshotManager.SnapshotIndex := lvHistory.Selected.Index;
FSnapshotManager.SnapshotSelected := True; SnapshotManager.SnapshotSelected := True;
end; end;
end; end;
end; end;
@ -88,16 +84,16 @@ end;
procedure THistoryDialog.tbClearClick(Sender: TObject); procedure THistoryDialog.tbClearClick(Sender: TObject);
begin begin
if FSnapshotManager <> nil if SnapshotManager <> nil
then FSnapshotManager.Clear; then SnapshotManager.Clear;
end; end;
procedure THistoryDialog.tbHistClick(Sender: TObject); procedure THistoryDialog.tbHistClick(Sender: TObject);
begin begin
if (FSnapshotManager = nil) or (FInSnapshotChanged) then exit; if (SnapshotManager = nil) or (FInSnapshotChanged) then exit;
if tbHistorySelected.Down then begin if tbHistorySelected.Down then begin
if tbSnap.Down then FSnapshotManager.SnapshotSelected := True; if tbSnap.Down then SnapshotManager.SnapshotSelected := True;
if tbHist.Down then FSnapshotManager.HistorySelected := True; if tbHist.Down then SnapshotManager.HistorySelected := True;
end; end;
SnapshotChanged(nil); SnapshotChanged(nil);
end; end;
@ -107,16 +103,16 @@ begin
if tbHistorySelected.Down if tbHistorySelected.Down
then tbHistorySelected.ImageIndex := FEnabledImgIdx then tbHistorySelected.ImageIndex := FEnabledImgIdx
else tbHistorySelected.ImageIndex := FDisabledIdx; else tbHistorySelected.ImageIndex := FDisabledIdx;
if FSnapshotManager = nil then exit; if SnapshotManager = nil then exit;
if tbHist.Down if tbHist.Down
then FSnapshotManager.HistorySelected := tbHistorySelected.Down then SnapshotManager.HistorySelected := tbHistorySelected.Down
else FSnapshotManager.SnapshotSelected := tbHistorySelected.Down else SnapshotManager.SnapshotSelected := tbHistorySelected.Down
end; end;
procedure THistoryDialog.tbMakeSnapClick(Sender: TObject); procedure THistoryDialog.tbMakeSnapClick(Sender: TObject);
begin begin
if (FSnapshotManager = nil) or (FSnapshotManager.Current = nil) then exit; if (SnapshotManager = nil) or (SnapshotManager.Current = nil) then exit;
FSnapshotManager.Current.AddToSnapshots; SnapshotManager.Current.AddToSnapshots;
end; end;
procedure THistoryDialog.tbPowerClick(Sender: TObject); procedure THistoryDialog.tbPowerClick(Sender: TObject);
@ -124,17 +120,17 @@ begin
if tbPower.Down if tbPower.Down
then tbPower.ImageIndex := FPowerImgIdx then tbPower.ImageIndex := FPowerImgIdx
else tbPower.ImageIndex := FPowerImgIdxGrey; else tbPower.ImageIndex := FPowerImgIdxGrey;
if FSnapshotManager <> nil if SnapshotManager <> nil
then FSnapshotManager.Active := tbPower.Down; then SnapshotManager.Active := tbPower.Down;
end; end;
procedure THistoryDialog.tbRemoveClick(Sender: TObject); procedure THistoryDialog.tbRemoveClick(Sender: TObject);
begin begin
if lvHistory.Selected = nil then exit; if lvHistory.Selected = nil then exit;
if tbHist.Down then begin if tbHist.Down then begin
FSnapshotManager.History[lvHistory.Selected.Index].RemoveFromHistory; SnapshotManager.History[lvHistory.Selected.Index].RemoveFromHistory;
end else begin end else begin
FSnapshotManager.Snapshots[lvHistory.Selected.Index].RemoveFromSnapshots; SnapshotManager.Snapshots[lvHistory.Selected.Index].RemoveFromSnapshots;
end; end;
end; end;
@ -144,7 +140,7 @@ var
Item: TListItem; Item: TListItem;
Lst: TSnapshotList; Lst: TSnapshotList;
begin begin
if (FSnapshotManager = nil) or FInSnapshotChanged then exit; if (SnapshotManager = nil) or FInSnapshotChanged then exit;
FInSnapshotChanged:= True; FInSnapshotChanged:= True;
try try
@ -158,14 +154,14 @@ begin
try try
if tbSnap.Down if tbSnap.Down
then begin then begin
Lst := FSnapshotManager.Snapshots; Lst := SnapshotManager.Snapshots;
if FSnapshotManager.SnapshotSelected if SnapshotManager.SnapshotSelected
then cur := FSnapshotManager.SnapshotIndex then cur := SnapshotManager.SnapshotIndex
else cur := -1; else cur := -1;
end else begin end else begin
Lst := FSnapshotManager.History; Lst := SnapshotManager.History;
if FSnapshotManager.HistorySelected if SnapshotManager.HistorySelected
then cur := FSnapshotManager.HistoryIndex then cur := SnapshotManager.HistoryIndex
else cur := -1; else cur := -1;
end; end;
@ -205,7 +201,7 @@ var
Lst: TSnapshotList; Lst: TSnapshotList;
Sel: Boolean; Sel: Boolean;
begin begin
if FSnapshotManager.Snapshots.Count > 0 then begin if SnapshotManager.Snapshots.Count > 0 then begin
tbSnap.Enabled := True; tbSnap.Enabled := True;
end else begin end else begin
tbSnap.Enabled := False; tbSnap.Enabled := False;
@ -214,11 +210,11 @@ begin
if tbSnap.Down if tbSnap.Down
then begin then begin
Lst := FSnapshotManager.Snapshots; Lst := SnapshotManager.Snapshots;
Sel := FSnapshotManager.SnapshotSelected; Sel := SnapshotManager.SnapshotSelected;
end else begin end else begin
Lst := FSnapshotManager.History; Lst := SnapshotManager.History;
Sel := FSnapshotManager.HistorySelected; Sel := SnapshotManager.HistorySelected;
end; end;
tbHistorySelected.Enabled := Lst.Count > 0; tbHistorySelected.Enabled := Lst.Count > 0;
@ -227,21 +223,12 @@ begin
else tbHistorySelected.Down := Sel; else tbHistorySelected.Down := Sel;
tbHistorySelected.Click; tbHistorySelected.Click;
tbClear.Enabled := (FSnapshotManager.History.Count > 0) or (FSnapshotManager.Snapshots.Count > 0); tbClear.Enabled := (SnapshotManager.History.Count > 0) or (SnapshotManager.Snapshots.Count > 0);
tbMakeSnap.Enabled := (FSnapshotManager.Current <> nil) and (not FSnapshotManager.Current.IsSnapshot); tbMakeSnap.Enabled := (SnapshotManager.Current <> nil) and (not SnapshotManager.Current.IsSnapshot);
tbRemove.Enabled := lvHistory.Selected <> nil; tbRemove.Enabled := lvHistory.Selected <> nil;
end; end;
procedure THistoryDialog.SetSnapshotManager(const AValue: TSnapshotManager);
begin
if FSnapshotManager = AValue then exit;
if FSnapshotManager <> nil then FSnapshotManager.RemoveNotification(FSnapshotNotification);
FSnapshotManager := AValue;
if FSnapshotManager <> nil then FSnapshotManager.AddNotification(FSnapshotNotification);
SnapshotChanged(nil);
end;
constructor THistoryDialog.Create(TheOwner: TComponent); constructor THistoryDialog.Create(TheOwner: TComponent);
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
@ -251,10 +238,8 @@ begin
lvHistory.Column[1].Caption := histdlgColumnTime; lvHistory.Column[1].Caption := histdlgColumnTime;
lvHistory.Column[2].Caption := histdlgColumnLoc; lvHistory.Column[2].Caption := histdlgColumnLoc;
FSnapshotNotification := TSnapshotNotification.Create; SnapshotNotification.OnChange := @SnapshotChanged;
FSnapshotNotification.AddReference; SnapshotNotification.OnCurrent := @SnapshotChanged;
FSnapshotNotification.OnChange := @SnapshotChanged;
FSnapshotNotification.OnCurrent := @SnapshotChanged;
imgCurrentLine := IDEImages.LoadImage(16, 'debugger_current_line'); imgCurrentLine := IDEImages.LoadImage(16, 'debugger_current_line');
lvHistory.SmallImages := IDEImages.Images_16; lvHistory.SmallImages := IDEImages.Images_16;
@ -288,14 +273,5 @@ begin
tbHistorySelectedClick(nil); tbHistorySelectedClick(nil);
end; end;
destructor THistoryDialog.Destroy;
begin
SetSnapshotManager(nil);
FSnapshotNotification.OnChange := nil;
FSnapshotNotification.OnCurrent := nil;
FSnapshotNotification.ReleaseReference;
inherited Destroy;
end;
end. end.

View File

@ -65,21 +65,8 @@ type
procedure actInspectUpdate(Sender: TObject); procedure actInspectUpdate(Sender: TObject);
procedure actWathExecute(Sender: TObject); procedure actWathExecute(Sender: TObject);
private private
FCallStackMonitor: TCallStackMonitor;
FLocalsMonitor: TLocalsMonitor;
FLocalsNotification: TLocalsNotification;
FSnapshotManager: TSnapshotManager;
FThreadsMonitor: TThreadsMonitor;
FThreadsNotification: TThreadsNotification;
FCallstackNotification: TCallStackNotification;
FSnapshotNotification: TSnapshotNotification;
procedure SetSnapshotManager(const AValue: TSnapshotManager);
procedure SnapshotChanged(Sender: TObject);
procedure ContextChanged(Sender: TObject); procedure ContextChanged(Sender: TObject);
procedure LocalsChanged(Sender: TObject); procedure LocalsChanged(Sender: TObject);
procedure SetCallStackMonitor(const AValue: TCallStackMonitor);
procedure SetLocals(const AValue: TLocalsMonitor);
procedure SetThreadsMonitor(const AValue: TThreadsMonitor);
function GetThreadId: Integer; function GetThreadId: Integer;
function GetSelectedThreads(Snap: TSnapshot): TThreads; function GetSelectedThreads(Snap: TSnapshot): TThreads;
function GetStackframe: Integer; function GetStackframe: Integer;
@ -89,12 +76,10 @@ type
procedure DoEndUpdate; override; procedure DoEndUpdate; override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; property LocalsMonitor;
property ThreadsMonitor;
property LocalsMonitor: TLocalsMonitor read FLocalsMonitor write SetLocals; property CallStackMonitor;
property ThreadsMonitor: TThreadsMonitor read FThreadsMonitor write SetThreadsMonitor; property SnapshotManager;
property CallStackMonitor: TCallStackMonitor read FCallStackMonitor write SetCallStackMonitor;
property SnapshotManager: TSnapshotManager read FSnapshotManager write SetSnapshotManager;
end; end;
@ -110,21 +95,10 @@ uses
constructor TLocalsDlg.Create(AOwner: TComponent); constructor TLocalsDlg.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FLocalsNotification := TLocalsNotification.Create; LocalsNotification.OnChange := @LocalsChanged;
FLocalsNotification.AddReference; ThreadsNotification.OnCurrent := @LocalsChanged;
FLocalsNotification.OnChange := @LocalsChanged; CallstackNotification.OnCurrent := @ContextChanged;
SnapshotNotification.OnCurrent := @LocalsChanged;
FThreadsNotification := TThreadsNotification.Create;
FThreadsNotification.AddReference;
FThreadsNotification.OnCurrent := @ContextChanged;
FCallstackNotification := TCallStackNotification.Create;
FCallstackNotification.AddReference;
FCallstackNotification.OnCurrent := @ContextChanged;
FSnapshotNotification := TSnapshotNotification.Create;
FSnapshotNotification.AddReference;
FSnapshotNotification.OnCurrent := @SnapshotChanged;
Caption:= lisLocals; Caption:= lisLocals;
lvLocals.Columns[0].Caption:= lisLocalsDlgName; lvLocals.Columns[0].Caption:= lisLocalsDlgName;
@ -136,27 +110,6 @@ begin
actCopyValue.Caption := lisLocalsDlgCopyValue; actCopyValue.Caption := lisLocalsDlgCopyValue;
end; end;
destructor TLocalsDlg.Destroy;
begin
SetLocals(nil);
FLocalsNotification.OnChange := nil;
FLocalsNotification.ReleaseReference;
FThreadsNotification.OnCurrent := nil;
FThreadsNotification.ReleaseReference;
FCallstackNotification.OnCurrent := nil;
FCallstackNotification.ReleaseReference;
SetSnapshotManager(nil);
FSnapshotNotification.OnChange := nil;
FSnapshotNotification.OnCurrent := nil;
FSnapshotNotification.ReleaseReference;
inherited Destroy;
end;
procedure TLocalsDlg.SnapshotChanged(Sender: TObject);
begin
LocalsChanged(nil);
end;
procedure TLocalsDlg.actInspectUpdate(Sender: TObject); procedure TLocalsDlg.actInspectUpdate(Sender: TObject);
begin begin
(Sender as TAction).Enabled := Assigned(lvLocals.Selected); (Sender as TAction).Enabled := Assigned(lvLocals.Selected);
@ -200,15 +153,6 @@ begin
Clipboard.Close; Clipboard.Close;
end; end;
procedure TLocalsDlg.SetSnapshotManager(const AValue: TSnapshotManager);
begin
if FSnapshotManager = AValue then exit;
if FSnapshotManager <> nil then FSnapshotManager.RemoveNotification(FSnapshotNotification);
FSnapshotManager := AValue;
if FSnapshotManager <> nil then FSnapshotManager.AddNotification(FSnapshotNotification);
LocalsChanged(nil);
end;
procedure TLocalsDlg.ContextChanged(Sender: TObject); procedure TLocalsDlg.ContextChanged(Sender: TObject);
begin begin
LocalsChanged(nil); LocalsChanged(nil);
@ -223,7 +167,7 @@ var
Locals: TLocals; Locals: TLocals;
Snap: TSnapshot; Snap: TSnapshot;
begin begin
if (FThreadsMonitor = nil) or (FCallStackMonitor = nil) or (FLocalsMonitor=nil) then begin if (ThreadsMonitor = nil) or (CallStackMonitor = nil) or (LocalsMonitor=nil) then begin
lvLocals.Items.Clear; lvLocals.Items.Clear;
exit; exit;
end; end;
@ -235,7 +179,7 @@ begin
Snap := GetSelectedSnapshot; Snap := GetSelectedSnapshot;
if (Snap <> nil) if (Snap <> nil)
then begin then begin
Locals := FLocalsMonitor.Snapshots[Snap][GetThreadId, GetStackframe]; Locals := LocalsMonitor.Snapshots[Snap][GetThreadId, GetStackframe];
Caption:= lisLocals + ' ('+ Snap.LocationAsText +')'; Caption:= lisLocals + ' ('+ Snap.LocationAsText +')';
end end
else begin else begin
@ -296,74 +240,12 @@ begin
end; end;
end; end;
procedure TLocalsDlg.SetCallStackMonitor(const AValue: TCallStackMonitor);
begin
if FCallStackMonitor = AValue then exit;
BeginUpdate;
try
if FCallStackMonitor <> nil
then FCallStackMonitor.RemoveNotification(FCallstackNotification);
FCallStackMonitor := AValue;
if FCallStackMonitor <> nil
then FCallStackMonitor.AddNotification(FCallstackNotification);
LocalsChanged(nil);
finally
EndUpdate;
end;
end;
procedure TLocalsDlg.SetLocals(const AValue: TLocalsMonitor);
begin
if FLocalsMonitor = AValue then Exit;
BeginUpdate;
try
if FLocalsMonitor <> nil
then begin
FLocalsMonitor.RemoveNotification(FLocalsNotification);
end;
FLocalsMonitor := AValue;
if FLocalsMonitor <> nil
then begin
FLocalsMonitor.AddNotification(FLocalsNotification);
end;
LocalsChanged(FLocalsMonitor);
finally
EndUpdate;
end;
end;
procedure TLocalsDlg.SetThreadsMonitor(const AValue: TThreadsMonitor);
begin
if FThreadsMonitor = AValue then exit;
BeginUpdate;
try
if FThreadsMonitor <> nil
then FThreadsMonitor.RemoveNotification(FThreadsNotification);
FThreadsMonitor := AValue;
if FThreadsMonitor <> nil
then FThreadsMonitor.AddNotification(FThreadsNotification);
LocalsChanged(nil);
finally
EndUpdate;
end;
end;
function TLocalsDlg.GetThreadId: Integer; function TLocalsDlg.GetThreadId: Integer;
var var
Threads: TThreads; Threads: TThreads;
begin begin
Result := -1; Result := -1;
if (FThreadsMonitor = nil) then exit; if (ThreadsMonitor = nil) then exit;
Threads := GetSelectedThreads(GetSelectedSnapshot); Threads := GetSelectedThreads(GetSelectedSnapshot);
if Threads <> nil if Threads <> nil
then Result := Threads.CurrentThreadId then Result := Threads.CurrentThreadId
@ -372,10 +254,10 @@ end;
function TLocalsDlg.GetSelectedThreads(Snap: TSnapshot): TThreads; function TLocalsDlg.GetSelectedThreads(Snap: TSnapshot): TThreads;
begin begin
if FThreadsMonitor = nil then exit(nil); if ThreadsMonitor = nil then exit(nil);
if Snap = nil if Snap = nil
then Result := FThreadsMonitor.CurrentThreads then Result := ThreadsMonitor.CurrentThreads
else Result := FThreadsMonitor.Snapshots[Snap]; else Result := ThreadsMonitor.Snapshots[Snap];
end; end;
function TLocalsDlg.GetStackframe: Integer; function TLocalsDlg.GetStackframe: Integer;

View File

@ -21,24 +21,16 @@ type
procedure tbCurrentClick(Sender: TObject); procedure tbCurrentClick(Sender: TObject);
procedure ThreadsChanged(Sender: TObject); procedure ThreadsChanged(Sender: TObject);
private private
FSnapshotManager: TSnapshotManager;
FThreadNotification: TThreadsNotification;
FSnapshotNotification: TSnapshotNotification;
FThreadsMonitor: TThreadsMonitor;
imgCurrentLine: Integer; imgCurrentLine: Integer;
procedure SetSnapshotManager(const AValue: TSnapshotManager);
procedure SnapshotChanged(Sender: TObject);
procedure SetThreadsMonitor(const AValue: TThreadsMonitor);
procedure JumpToSource; procedure JumpToSource;
function GetSelectedSnapshot: TSnapshot; function GetSelectedSnapshot: TSnapshot;
function GetSelectedThreads(Snap: TSnapshot): TThreads; function GetSelectedThreads(Snap: TSnapshot): TThreads;
public public
{ public declarations } { public declarations }
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; property ThreadsMonitor;
property ThreadsMonitor: TThreadsMonitor read FThreadsMonitor write SetThreadsMonitor; property SnapshotManager;
property SnapshotManager: TSnapshotManager read FSnapshotManager write SetSnapshotManager; end;
end;
implementation implementation
@ -54,7 +46,7 @@ var
Threads: TThreads; Threads: TThreads;
Snap: TSnapshot; Snap: TSnapshot;
begin begin
if FThreadsMonitor = nil then begin if ThreadsMonitor = nil then begin
lvThreads.Clear; lvThreads.Clear;
exit; exit;
end; end;
@ -121,12 +113,12 @@ begin
id := StrToIntDef(Item.SubItems[0], -1); id := StrToIntDef(Item.SubItems[0], -1);
if id < 0 then exit; if id < 0 then exit;
if GetSelectedSnapshot = nil if GetSelectedSnapshot = nil
then FThreadsMonitor.ChangeCurrentThread(id) then ThreadsMonitor.ChangeCurrentThread(id)
else begin else begin
Threads := GetSelectedThreads(GetSelectedSnapshot); Threads := GetSelectedThreads(GetSelectedSnapshot);
if Threads <> nil if Threads <> nil
then Threads.CurrentThreadId := id; then Threads.CurrentThreadId := id;
FThreadsMonitor.CurrentChanged; ThreadsMonitor.CurrentChanged;
end; end;
end; end;
@ -135,29 +127,6 @@ begin
JumpToSource; JumpToSource;
end; end;
procedure TThreadsDlg.SnapshotChanged(Sender: TObject);
begin
ThreadsChanged(nil);
end;
procedure TThreadsDlg.SetSnapshotManager(const AValue: TSnapshotManager);
begin
if FSnapshotManager = AValue then exit;
if FSnapshotManager <> nil then FSnapshotManager.RemoveNotification(FSnapshotNotification);
FSnapshotManager := AValue;
if FSnapshotManager <> nil then FSnapshotManager.AddNotification(FSnapshotNotification);
ThreadsChanged(FSnapshotManager);
end;
procedure TThreadsDlg.SetThreadsMonitor(const AValue: TThreadsMonitor);
begin
if FThreadsMonitor = AValue then exit;
if FThreadsMonitor <> nil then FThreadsMonitor.RemoveNotification(FThreadNotification);
FThreadsMonitor := AValue;
if FThreadsMonitor <> nil then FThreadsMonitor.AddNotification(FThreadNotification);
ThreadsChanged(FThreadsMonitor);
end;
procedure TThreadsDlg.JumpToSource; procedure TThreadsDlg.JumpToSource;
var var
Entry: TThreadEntry; Entry: TThreadEntry;
@ -196,8 +165,8 @@ end;
function TThreadsDlg.GetSelectedThreads(Snap: TSnapshot): TThreads; function TThreadsDlg.GetSelectedThreads(Snap: TSnapshot): TThreads;
begin begin
if Snap = nil if Snap = nil
then Result := FThreadsMonitor.CurrentThreads then Result := ThreadsMonitor.CurrentThreads
else Result := FThreadsMonitor.Snapshots[Snap]; else Result := ThreadsMonitor.Snapshots[Snap];
end; end;
constructor TThreadsDlg.Create(TheOwner: TComponent); constructor TThreadsDlg.Create(TheOwner: TComponent);
@ -213,29 +182,12 @@ begin
tbCurrent.Caption := lisThreadsCurrent; tbCurrent.Caption := lisThreadsCurrent;
tbGoto.Caption := lisThreadsGoto; tbGoto.Caption := lisThreadsGoto;
FThreadNotification := TThreadsNotification.Create; SnapshotNotification.OnCurrent := @ThreadsChanged;
FThreadNotification.AddReference; ThreadsNotification.OnChange := @ThreadsChanged;;
FThreadNotification.OnChange := @ThreadsChanged;
FSnapshotNotification := TSnapshotNotification.Create;
FSnapshotNotification.AddReference;
FSnapshotNotification.OnCurrent := @SnapshotChanged;
imgCurrentLine := IDEImages.LoadImage(16, 'debugger_current_line'); imgCurrentLine := IDEImages.LoadImage(16, 'debugger_current_line');
lvThreads.SmallImages := IDEImages.Images_16; lvThreads.SmallImages := IDEImages.Images_16;
end; end;
destructor TThreadsDlg.Destroy;
begin
SetThreadsMonitor(nil);
FThreadNotification.OnChange := nil;
FThreadNotification.ReleaseReference;
SetSnapshotManager(nil);
FSnapshotNotification.OnChange := nil;
FSnapshotNotification.OnCurrent := nil;
FSnapshotNotification.ReleaseReference;
inherited Destroy;
end;
end. end.

View File

@ -106,14 +106,6 @@ type
procedure SnapshotChanged(Sender: TObject); procedure SnapshotChanged(Sender: TObject);
private private
FWatchesInView: TWatches; FWatchesInView: TWatches;
FCallStackMonitor: TCallStackMonitor;
FSnapshotManager: TSnapshotManager;
FThreadsMonitor: TThreadsMonitor;
FWatchesMonitor: TWatchesMonitor;
FSnapshotNotification: TSnapshotNotification;
FWatchesNotification: TWatchesNotification;
FThreadsNotification: TThreadsNotification;
FCallstackNotification: TCallStackNotification;
FPowerImgIdx, FPowerImgIdxGrey: Integer; FPowerImgIdx, FPowerImgIdxGrey: Integer;
FUpdateAllNeeded, FUpdatingAll: Boolean; FUpdateAllNeeded, FUpdatingAll: Boolean;
FStateFlags: TWatchesDlgStateFlags; FStateFlags: TWatchesDlgStateFlags;
@ -121,10 +113,6 @@ type
function GetThreadId: Integer; function GetThreadId: Integer;
function GetSelectedThreads(Snap: TSnapshot): TThreads; function GetSelectedThreads(Snap: TSnapshot): TThreads;
function GetStackframe: Integer; function GetStackframe: Integer;
procedure SetSnapshotManager(const AValue: TSnapshotManager);
procedure SetCallStackMonitor(const AValue: TCallStackMonitor);
procedure SetThreadsMonitor(const AValue: TThreadsMonitor);
procedure SetWatchesMonitor(const AValue: TWatchesMonitor);
procedure WatchAdd(const ASender: TWatches; const AWatch: TWatch); procedure WatchAdd(const ASender: TWatches; const AWatch: TWatch);
procedure WatchUpdate(const ASender: TWatches; const AWatch: TWatch); procedure WatchUpdate(const ASender: TWatches; const AWatch: TWatch);
procedure WatchRemove(const ASender: TWatches; const AWatch: TWatch); procedure WatchRemove(const ASender: TWatches; const AWatch: TWatch);
@ -136,14 +124,13 @@ type
property Watches: TWatches read GetWatches; property Watches: TWatches read GetWatches;
protected protected
procedure DoEndUpdate; override; procedure DoEndUpdate; override;
procedure DoWatchesChanged; override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; property WatchesMonitor;
property ThreadsMonitor;
property WatchesMonitor: TWatchesMonitor read FWatchesMonitor write SetWatchesMonitor; property CallStackMonitor;
property ThreadsMonitor: TThreadsMonitor read FThreadsMonitor write SetThreadsMonitor; property SnapshotManager;
property CallStackMonitor: TCallStackMonitor read FCallStackMonitor write SetCallStackMonitor;
property SnapshotManager: TSnapshotManager read FSnapshotManager write SetSnapshotManager;
end; end;
@ -157,25 +144,14 @@ constructor TWatchesDlg.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FWatchesInView := nil; FWatchesInView := nil;
FWatchesNotification := TWatchesNotification.Create;
FWatchesNotification.AddReference;
FWatchesNotification.OnAdd := @WatchAdd;
FWatchesNotification.OnUpdate := @WatchUpdate;
FWatchesNotification.OnRemove := @WatchRemove;
FStateFlags := []; FStateFlags := [];
FThreadsNotification := TThreadsNotification.Create; WatchesNotification.OnAdd := @WatchAdd;
FThreadsNotification.AddReference; WatchesNotification.OnUpdate := @WatchUpdate;
FThreadsNotification.OnCurrent := @ContextChanged; WatchesNotification.OnRemove := @WatchRemove;
ThreadsNotification.OnCurrent := @ContextChanged;
FCallstackNotification := TCallStackNotification.Create; CallstackNotification.OnCurrent := @ContextChanged;
FCallstackNotification.AddReference; SnapshotNotification.OnCurrent := @SnapshotChanged;
FCallstackNotification.OnCurrent := @ContextChanged;
FSnapshotNotification := TSnapshotNotification.Create;
FSnapshotNotification.AddReference;
FSnapshotNotification.OnCurrent := @SnapshotChanged;
ActionList1.Images := IDEImages.Images_16; ActionList1.Images := IDEImages.Images_16;
ToolBar1.Images := IDEImages.Images_16; ToolBar1.Images := IDEImages.Images_16;
@ -227,25 +203,6 @@ begin
lvWatches.Column[1].Width := 200; lvWatches.Column[1].Width := 200;
end; end;
destructor TWatchesDlg.Destroy;
begin
//DebugLn('TWatchesDlg.Destroy ',DbgSName(Self));
SetWatchesMonitor(nil);
FWatchesNotification.OnAdd := nil;
FWatchesNotification.OnUpdate := nil;
FWatchesNotification.OnRemove := nil;
FWatchesNotification.ReleaseReference;
FThreadsNotification.OnCurrent := nil;
FThreadsNotification.ReleaseReference;
FCallstackNotification.OnCurrent := nil;
FCallstackNotification.ReleaseReference;
SetSnapshotManager(nil);
FSnapshotNotification.OnChange := nil;
FSnapshotNotification.OnCurrent := nil;
FSnapshotNotification.ReleaseReference;
inherited Destroy;
end;
function TWatchesDlg.GetSelected: TCurrentWatch; function TWatchesDlg.GetSelected: TCurrentWatch;
var var
Item: TListItem; Item: TListItem;
@ -261,7 +218,7 @@ var
Threads: TThreads; Threads: TThreads;
begin begin
Result := -1; Result := -1;
if (FThreadsMonitor = nil) then exit; if (ThreadsMonitor = nil) then exit;
Threads := GetSelectedThreads(GetSelectedSnapshot); Threads := GetSelectedThreads(GetSelectedSnapshot);
if Threads <> nil if Threads <> nil
then Result := Threads.CurrentThreadId then Result := Threads.CurrentThreadId
@ -270,10 +227,10 @@ end;
function TWatchesDlg.GetSelectedThreads(Snap: TSnapshot): TThreads; function TWatchesDlg.GetSelectedThreads(Snap: TSnapshot): TThreads;
begin begin
if FThreadsMonitor = nil then exit(nil); if ThreadsMonitor = nil then exit(nil);
if Snap = nil if Snap = nil
then Result := FThreadsMonitor.CurrentThreads then Result := ThreadsMonitor.CurrentThreads
else Result := FThreadsMonitor.Snapshots[Snap]; else Result := ThreadsMonitor.Snapshots[Snap];
end; end;
function TWatchesDlg.GetStackframe: Integer; function TWatchesDlg.GetStackframe: Integer;
@ -304,79 +261,6 @@ begin
else Result := 0; else Result := 0;
end; end;
procedure TWatchesDlg.SetSnapshotManager(const AValue: TSnapshotManager);
begin
if FSnapshotManager = AValue then exit;
if FSnapshotManager <> nil then FSnapshotManager.RemoveNotification(FSnapshotNotification);
FSnapshotManager := AValue;
if FSnapshotManager <> nil then FSnapshotManager.AddNotification(FSnapshotNotification);
SnapshotChanged(nil);
end;
procedure TWatchesDlg.SetCallStackMonitor(const AValue: TCallStackMonitor);
begin
if FCallStackMonitor = AValue then exit;
BeginUpdate;
try
if FCallStackMonitor <> nil
then FCallStackMonitor.RemoveNotification(FCallstackNotification);
FCallStackMonitor := AValue;
if FCallStackMonitor <> nil
then FCallStackMonitor.AddNotification(FCallstackNotification);
UpdateAll;
finally
EndUpdate;
end;
end;
procedure TWatchesDlg.SetThreadsMonitor(const AValue: TThreadsMonitor);
begin
if FThreadsMonitor = AValue then exit;
BeginUpdate;
try
if FThreadsMonitor <> nil
then FThreadsMonitor.RemoveNotification(FThreadsNotification);
FThreadsMonitor := AValue;
if FThreadsMonitor <> nil
then FThreadsMonitor.AddNotification(FThreadsNotification);
UpdateAll;
finally
EndUpdate;
end;
end;
procedure TWatchesDlg.SetWatchesMonitor(const AValue: TWatchesMonitor);
begin
if FWatchesMonitor = AValue then Exit;
BeginUpdate;
try
lvWatches.Items.Clear;
if FWatchesMonitor <> nil
then begin
FWatchesMonitor.RemoveNotification(FWatchesNotification);
end;
FWatchesMonitor:=AValue;
if FWatchesMonitor <> nil
then begin
FWatchesMonitor.AddNotification(FWatchesNotification);
UpdateAll;
end;
finally
EndUpdate;
end;
end;
procedure TWatchesDlg.lvWatchesSelectItem(Sender: TObject; AItem: TListItem; Selected: Boolean); procedure TWatchesDlg.lvWatchesSelectItem(Sender: TObject; AItem: TListItem; Selected: Boolean);
var var
ItemSelected: Boolean; ItemSelected: Boolean;
@ -568,13 +452,13 @@ var
Snap: TSnapshot; Snap: TSnapshot;
begin begin
Result := nil; Result := nil;
if FWatchesMonitor = nil then exit; if WatchesMonitor = nil then exit;
Snap := GetSelectedSnapshot; Snap := GetSelectedSnapshot;
if Snap <> nil if Snap <> nil
then Result := FWatchesMonitor.Snapshots[Snap] then Result := WatchesMonitor.Snapshots[Snap]
else Result := FWatchesMonitor.CurrentWatches; else Result := WatchesMonitor.CurrentWatches;
end; end;
procedure TWatchesDlg.DoEndUpdate; procedure TWatchesDlg.DoEndUpdate;
@ -586,6 +470,11 @@ begin
end; end;
end; end;
procedure TWatchesDlg.DoWatchesChanged;
begin
UpdateAll;
end;
procedure TWatchesDlg.popDeleteClick(Sender: TObject); procedure TWatchesDlg.popDeleteClick(Sender: TObject);
var var
Item: TCurrentWatch; Item: TCurrentWatch;
@ -703,7 +592,7 @@ begin
// Expression // Expression
// Result // Result
if (not ToolButtonPower.Down) or (not Visible) then exit; if (not ToolButtonPower.Down) or (not Visible) then exit;
if (FThreadsMonitor = nil) or (FCallStackMonitor = nil) then exit; if (ThreadsMonitor = nil) or (CallStackMonitor = nil) then exit;
if GetStackframe < 0 then exit; // TODO need dedicated validity property if GetStackframe < 0 then exit; // TODO need dedicated validity property
include(FStateFlags, wdsfUpdating); include(FStateFlags, wdsfUpdating);

View File

@ -830,6 +830,10 @@ procedure TDebugManager.DebuggerBeforeChangeState(ADebugger: TDebugger; AOldStat
var var
DialogType: TDebugDialogType; DialogType: TDebugDialogType;
begin begin
if Destroying or (MainIDE=nil) or (MainIDE.ToolStatus=itExiting)
then exit;
assert((ADebugger=FDebugger) and (ADebugger<>nil), 'TDebugManager.OnDebuggerChangeState');
FInStateChange := True; FInStateChange := True;
for DialogType := Low(TDebugDialogType) to High(TDebugDialogType) do for DialogType := Low(TDebugDialogType) to High(TDebugDialogType) do
if FDialogs[DialogType] <> nil then if FDialogs[DialogType] <> nil then
@ -840,6 +844,18 @@ end;
procedure TDebugManager.DebuggerChangeState(ADebugger: TDebugger; procedure TDebugManager.DebuggerChangeState(ADebugger: TDebugger;
OldState: TDBGState); OldState: TDBGState);
procedure UnlockDialogs;
var
DialogType: TDebugDialogType;
begin
if not FInStateChange then exit;
FInStateChange := False;
for DialogType := Low(TDebugDialogType) to High(TDebugDialogType) do
if FDialogs[DialogType] <> nil then
FDialogs[DialogType].EndUpdate;
end;
const const
// dsNone, dsIdle, dsStop, dsPause, dsInit, dsRun, dsError // dsNone, dsIdle, dsStop, dsPause, dsInit, dsRun, dsError
TOOLSTATEMAP: array[TDBGState] of TIDEToolStatus = ( TOOLSTATEMAP: array[TDBGState] of TIDEToolStatus = (
@ -852,29 +868,29 @@ const
var var
MsgResult: TModalResult; MsgResult: TModalResult;
i: Integer; i: Integer;
DialogType: TDebugDialogType;
begin begin
FInStateChange := False;
for DialogType := Low(TDebugDialogType) to High(TDebugDialogType) do
if FDialogs[DialogType] <> nil then
FDialogs[DialogType].EndUpdate;
if Destroying or (MainIDE=nil) or (MainIDE.ToolStatus=itExiting) if Destroying or (MainIDE=nil) or (MainIDE.ToolStatus=itExiting)
then exit; then begin
UnlockDialogs;
exit;
end;
assert((ADebugger=FDebugger) and (ADebugger<>nil), 'TDebugManager.OnDebuggerChangeState'); assert((ADebugger=FDebugger) and (ADebugger<>nil), 'TDebugManager.OnDebuggerChangeState');
if (FDebugger.State in [dsRun]) if (FDebugger.State in [dsRun])
then FCurrentBreakpoint := nil; then FCurrentBreakpoint := nil;
// Notify FSnapshots of new state (while dialogs still in updating)
if (FCurrentBreakpoint <> nil) and (bpaTakeSnapshot in FCurrentBreakpoint.Actions) then begin if (FCurrentBreakpoint <> nil) and (bpaTakeSnapshot in FCurrentBreakpoint.Actions) then begin
FSnapshots.DoStateChange(OldState); FSnapshots.DoStateChange(OldState);
FSnapshots.Current.AddToSnapshots; FSnapshots.Current.AddToSnapshots;
FSnapshots.DoDebuggerIdle(True); FSnapshots.DoDebuggerIdle(True);
end end
else if FDebugger.State <> dsInternalPause else
if FDebugger.State <> dsInternalPause
then FSnapshots.DoStateChange(OldState); then FSnapshots.DoStateChange(OldState);
UnlockDialogs;
if FDebugger.State = dsInternalPause if FDebugger.State = dsInternalPause
then exit; then exit;