DBG: reduced flicker in Data windows, added debugln

git-svn-id: trunk@31150 -
This commit is contained in:
martin 2011-06-10 00:44:18 +00:00
parent ad7eb43d19
commit ac70d0ff2f
5 changed files with 77 additions and 8 deletions

View File

@ -103,13 +103,11 @@ type
FViewStart: Integer; FViewStart: Integer;
FPowerImgIdx, FPowerImgIdxGrey: Integer; FPowerImgIdx, FPowerImgIdxGrey: Integer;
FInUpdateView: Boolean; FInUpdateView: Boolean;
FUpdateFlags: set of (ufNeedUpdating);
function GetImageIndex(Entry: TCallStackEntry): Integer; function GetImageIndex(Entry: TCallStackEntry): Integer;
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 CallStackChanged(Sender: TObject);
procedure CallStackCurrent(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;
@ -118,7 +116,6 @@ type
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;
@ -126,6 +123,10 @@ type
function GetSelectedSnapshot: TSnapshot; function GetSelectedSnapshot: TSnapshot;
function GetSelectedThreads(Snap: TSnapshot): TThreads; function GetSelectedThreads(Snap: TSnapshot): TThreads;
function GetSelectedCallstack: TCallStack; function GetSelectedCallstack: TCallStack;
procedure DoBreakPointsChanged; override;
procedure BreakPointChanged(const ASender: TIDEBreakPoints; const ABreakpoint: TIDEBreakPoint);
procedure CallStackChanged(Sender: TObject);
procedure CallStackCurrent(Sender: TObject);
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
property BreakPoints; property BreakPoints;
@ -173,6 +174,7 @@ end;
procedure TCallStackDlg.CallStackChanged(Sender: TObject); procedure TCallStackDlg.CallStackChanged(Sender: TObject);
begin begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackDlg.CallStackChanged from ', DbgSName(Sender), ' Upd:', IsUpdating]); {$ENDIF}
if not ToolButtonPower.Down then exit; if not ToolButtonPower.Down then exit;
if FViewStart = 0 if FViewStart = 0
then UpdateView then UpdateView
@ -182,6 +184,7 @@ end;
procedure TCallStackDlg.CallStackCurrent(Sender: TObject); procedure TCallStackDlg.CallStackCurrent(Sender: TObject);
begin begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackDlg.CallStackCurrent from ', DbgSName(Sender), ' Upd:', IsUpdating]); {$ENDIF}
if not ToolButtonPower.Down then exit; if not ToolButtonPower.Down then exit;
UpdateView; UpdateView;
end; end;
@ -231,6 +234,15 @@ var
CStack: TCallStack; CStack: TCallStack;
begin begin
if (not ToolButtonPower.Down) or FInUpdateView then exit; if (not ToolButtonPower.Down) or FInUpdateView then exit;
if IsUpdating then begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackDlg.UpdateView in IsUpdating']); {$ENDIF}
Include(FUpdateFlags, ufNeedUpdating);
exit;
end;
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackDlg.UpdateView']); {$ENDIF}
Exclude(FUpdateFlags, ufNeedUpdating);
BeginUpdate; BeginUpdate;
lvCallStack.BeginUpdate; lvCallStack.BeginUpdate;
try try
@ -241,6 +253,7 @@ begin
FInUpdateView := True; // ignore change triggered by count, if there is a change event, then Count will be updated already FInUpdateView := True; // ignore change triggered by count, if there is a change event, then Count will be updated already
CStack := GetSelectedCallstack; CStack := GetSelectedCallstack;
if CStack <> nil then CStack.Count; // trigger the update-notification, if executed immediately
FInUpdateView := False; FInUpdateView := False;
if (CStack = nil) or ((Snap <> nil) and (CStack.Count = 0)) then begin if (CStack = nil) or ((Snap <> nil) and (CStack.Count = 0)) then begin
@ -329,6 +342,7 @@ end;
procedure TCallStackDlg.DoEndUpdate; procedure TCallStackDlg.DoEndUpdate;
begin begin
if ufNeedUpdating in FUpdateFlags then UpdateView;
lvCallStack.EndUpdate; lvCallStack.EndUpdate;
EnableAllActions; EnableAllActions;
end; end;
@ -613,6 +627,7 @@ var
Entry: TCallStackEntry; Entry: TCallStackEntry;
Stack: TCallStack; Stack: TCallStack;
begin begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackDlg.BreakPointChanged ', DbgSName(ASender), ' Upd:', IsUpdating]); {$ENDIF}
Stack := GetSelectedCallstack; Stack := GetSelectedCallstack;
if (BreakPoints = nil) or (Stack = nil) then if (BreakPoints = nil) or (Stack = nil) then
Exit; Exit;

View File

@ -35,6 +35,9 @@ unit Debugger;
{$IFDEF linux} {$DEFINE DBG_ENABLE_TERMINAL} {$ENDIF} {$IFDEF linux} {$DEFINE DBG_ENABLE_TERMINAL} {$ENDIF}
{$IFDEF DBG_STATE} {$DEFINE DBG_STATE_EVENT} {$ENDIF}
{$IFDEF DBG_EVENTS} {$DEFINE DBG_STATE_EVENT} {$ENDIF}
interface interface
uses uses
@ -4261,6 +4264,7 @@ end;
procedure TCurrentThreads.SetCurrentThreadId(const AValue: Integer); procedure TCurrentThreads.SetCurrentThreadId(const AValue: Integer);
begin begin
if FCurrentThreadId = AValue then exit;
inherited SetCurrentThreadId(AValue); inherited SetCurrentThreadId(AValue);
FMonitor.CurrentChanged; // TODO ChangedSelection FMonitor.CurrentChanged; // TODO ChangedSelection
end; end;
@ -4844,7 +4848,9 @@ end;
procedure TDebugger.DoCurrent(const ALocation: TDBGLocationRec); procedure TDebugger.DoCurrent(const ALocation: TDBGLocationRec);
begin begin
{$IFDEF DBG_EVENTS} DebugLnEnter(['DebugEvent: Enter >> DoCurrent (Location) >> State=', DBGStateNames[FState]]); {$ENDIF}
if Assigned(FOnCurrent) then FOnCurrent(Self, ALocation); if Assigned(FOnCurrent) then FOnCurrent(Self, ALocation);
{$IFDEF DBG_EVENTS} DebugLnExit(['DebugEvent: Exit << DoCurrent (Location) <<']); {$ENDIF}
end; end;
procedure TDebugger.DoDbgOutput(const AText: String); procedure TDebugger.DoDbgOutput(const AText: String);
@ -4854,19 +4860,24 @@ begin
end; end;
procedure TDebugger.DoDbgEvent(const ACategory: TDBGEventCategory; const AEventType: TDBGEventType; const AText: String); procedure TDebugger.DoDbgEvent(const ACategory: TDBGEventCategory; const AEventType: TDBGEventType; const AText: String);
{$IFDEF DBG_EVENTS} var s: String; {$ENDIF}
begin begin
{$IFDEF DBG_EVENTS} writestr(s, ACategory); DebugLnEnter(['DebugEvent: Enter >> DoDbgEvent >> State=', DBGStateNames[FState], ' Category=', s]); {$ENDIF}
if Assigned(FOnDbgEvent) then FOnDbgEvent(Self, ACategory, AEventType, AText); if Assigned(FOnDbgEvent) then FOnDbgEvent(Self, ACategory, AEventType, AText);
{$IFDEF DBG_EVENTS} DebugLnExit(['DebugEvent: Exit << DoDbgEvent <<']); {$ENDIF}
end; end;
procedure TDebugger.DoException(const AExceptionType: TDBGExceptionType; procedure TDebugger.DoException(const AExceptionType: TDBGExceptionType;
const AExceptionClass: String; AExceptionAddress: TDBGPtr; const AExceptionText: String; out AContinue: Boolean); const AExceptionClass: String; AExceptionAddress: TDBGPtr; const AExceptionText: String; out AContinue: Boolean);
begin begin
{$IFDEF DBG_EVENTS} DebugLnEnter(['DebugEvent: Enter >> DoException >> State=', DBGStateNames[FState]]); {$ENDIF}
if AExceptionType = deInternal then if AExceptionType = deInternal then
DoDbgEvent(ecDebugger, etExceptionRaised, Format('Exception class "%s" at $%.' + IntToStr(TargetWidth div 4) + 'x with message "%s"', [AExceptionClass, AExceptionAddress, AExceptionText])); DoDbgEvent(ecDebugger, etExceptionRaised, Format('Exception class "%s" at $%.' + IntToStr(TargetWidth div 4) + 'x with message "%s"', [AExceptionClass, AExceptionAddress, AExceptionText]));
if Assigned(FOnException) then if Assigned(FOnException) then
FOnException(Self, AExceptionType, AExceptionClass, AExceptionText, AContinue) FOnException(Self, AExceptionType, AExceptionClass, AExceptionText, AContinue)
else else
AContinue := True; AContinue := True;
{$IFDEF DBG_EVENTS} DebugLnExit(['DebugEvent: Exit << DoException <<']); {$ENDIF}
end; end;
procedure TDebugger.DoOutput(const AText: String); procedure TDebugger.DoOutput(const AText: String);
@ -4876,18 +4887,24 @@ end;
procedure TDebugger.DoBreakpointHit(const ABreakPoint: TBaseBreakPoint; var ACanContinue: Boolean); procedure TDebugger.DoBreakpointHit(const ABreakPoint: TBaseBreakPoint; var ACanContinue: Boolean);
begin begin
{$IFDEF DBG_EVENTS} DebugLnEnter(['DebugEvent: Enter >> DoBreakpointHit << State=', DBGStateNames[FState]]); {$ENDIF}
if Assigned(FOnBreakpointHit) if Assigned(FOnBreakpointHit)
then FOnBreakpointHit(Self, ABreakPoint, ACanContinue); then FOnBreakpointHit(Self, ABreakPoint, ACanContinue);
{$IFDEF DBG_EVENTS} DebugLnExit(['DebugEvent: Exit >> DoBreakpointHit <<']); {$ENDIF}
end; end;
procedure TDebugger.DoBeforeState(const OldState: TDBGState); procedure TDebugger.DoBeforeState(const OldState: TDBGState);
begin begin
{$IFDEF DBG_STATE_EVENT} DebugLnEnter(['DebugEvent: Enter >> DoBeforeState << State=', DBGStateNames[FState]]); {$ENDIF}
if Assigned(FOnBeforeState) then FOnBeforeState(Self, OldState); if Assigned(FOnBeforeState) then FOnBeforeState(Self, OldState);
{$IFDEF DBG_STATE_EVENT} DebugLnExit(['DebugEvent: Exit >> DoBeforeState <<']); {$ENDIF}
end; end;
procedure TDebugger.DoState(const OldState: TDBGState); procedure TDebugger.DoState(const OldState: TDBGState);
begin begin
{$IFDEF DBG_STATE_EVENT} DebugLnEnter(['DebugEvent: Enter >> DoState << State=', DBGStateNames[FState]]); {$ENDIF}
if Assigned(FOnState) then FOnState(Self, OldState); if Assigned(FOnState) then FOnState(Self, OldState);
{$IFDEF DBG_STATE_EVENT} DebugLnExit(['DebugEvent: Exit >> DoState <<']); {$ENDIF}
end; end;
procedure TDebugger.EnvironmentChanged(Sender: TObject); procedure TDebugger.EnvironmentChanged(Sender: TObject);
@ -5122,6 +5139,9 @@ begin
if AValue <> FState if AValue <> FState
then begin then begin
{$IFDEF DBG_STATE}
DebugLnEnter(['DebuggerState: Setting to ', DBGStateNames[AValue],', from ', DBGStateNames[FState]]);
{$ENDIF}
OldState := FState; OldState := FState;
FState := AValue; FState := AValue;
DoBeforeState(OldState); DoBeforeState(OldState);
@ -5136,6 +5156,9 @@ begin
FWatches.DoStateChange(OldState); FWatches.DoStateChange(OldState);
finally finally
DoState(OldState); DoState(OldState);
{$IFDEF DBG_STATE}
DebugLnExit(['DebuggerState: Finished ', DBGStateNames[AValue]]);
{$ENDIF}
end; end;
end; end;
end; end;

View File

@ -56,6 +56,7 @@ type
procedure BeginUpdate; procedure BeginUpdate;
procedure EndUpdate; procedure EndUpdate;
function UpdateCount: integer; function UpdateCount: integer;
function IsUpdating: Boolean;
private (* provide some common properties *) private (* provide some common properties *)
FSnapshotManager: TSnapshotManager; FSnapshotManager: TSnapshotManager;
FSnapshotNotification: TSnapshotNotification; FSnapshotNotification: TSnapshotNotification;
@ -128,6 +129,11 @@ begin
Result := FUpdateCount; Result := FUpdateCount;
end; end;
function TDebuggerDlg.IsUpdating: Boolean;
begin
Result := FUpdateCount > 0;
end;
function TDebuggerDlg.GetSnapshotNotification: TSnapshotNotification; function TDebuggerDlg.GetSnapshotNotification: TSnapshotNotification;
begin begin
If FSnapshotNotification = nil then begin If FSnapshotNotification = nil then begin

View File

@ -5,7 +5,7 @@ unit ThreadDlg;
interface interface
uses uses
Classes, SysUtils, ComCtrls, Debugger, DebuggerDlg, LazarusIDEStrConsts, Classes, SysUtils, ComCtrls, LCLProc, Debugger, DebuggerDlg, LazarusIDEStrConsts,
BaseDebugManager, MainBase, IDEImagesIntf; BaseDebugManager, MainBase, IDEImagesIntf;
type type
@ -19,12 +19,15 @@ type
tbGoto: TToolButton; tbGoto: TToolButton;
procedure lvThreadsDblClick(Sender: TObject); procedure lvThreadsDblClick(Sender: TObject);
procedure tbCurrentClick(Sender: TObject); procedure tbCurrentClick(Sender: TObject);
procedure ThreadsChanged(Sender: TObject);
private private
imgCurrentLine: Integer; imgCurrentLine: Integer;
FUpdateFlags: set of (ufThreadChanged);
procedure JumpToSource; procedure JumpToSource;
function GetSelectedSnapshot: TSnapshot; function GetSelectedSnapshot: TSnapshot;
function GetSelectedThreads(Snap: TSnapshot): TThreads; function GetSelectedThreads(Snap: TSnapshot): TThreads;
protected
procedure DoEndUpdate; override;
procedure ThreadsChanged(Sender: TObject);
public public
{ public declarations } { public declarations }
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
@ -46,6 +49,15 @@ var
Threads: TThreads; Threads: TThreads;
Snap: TSnapshot; Snap: TSnapshot;
begin begin
if IsUpdating then begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TThreadsDlg.ThreadsChanged from ', DbgSName(Sender), ' in IsUpdating']); {$ENDIF}
Include(FUpdateFlags, ufThreadChanged);
exit;
end;
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TThreadsDlg.ThreadsChanged from ', DbgSName(Sender)]); {$ENDIF}
Exclude(FUpdateFlags, ufThreadChanged);
if ThreadsMonitor = nil then begin if ThreadsMonitor = nil then begin
lvThreads.Clear; lvThreads.Clear;
exit; exit;
@ -169,6 +181,11 @@ begin
else Result := ThreadsMonitor.Snapshots[Snap]; else Result := ThreadsMonitor.Snapshots[Snap];
end; end;
procedure TThreadsDlg.DoEndUpdate;
begin
if ufThreadChanged in FUpdateFlags then ThreadsChanged(nil);
end;
constructor TThreadsDlg.Create(TheOwner: TComponent); constructor TThreadsDlg.Create(TheOwner: TComponent);
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
@ -183,7 +200,7 @@ begin
tbGoto.Caption := lisThreadsGoto; tbGoto.Caption := lisThreadsGoto;
SnapshotNotification.OnCurrent := @ThreadsChanged; SnapshotNotification.OnCurrent := @ThreadsChanged;
ThreadsNotification.OnChange := @ThreadsChanged;; ThreadsNotification.OnChange := @ThreadsChanged;
imgCurrentLine := IDEImages.LoadImage(16, 'debugger_current_line'); imgCurrentLine := IDEImages.LoadImage(16, 'debugger_current_line');
lvThreads.SmallImages := IDEImages.Images_16; lvThreads.SmallImages := IDEImages.Images_16;

View File

@ -44,7 +44,11 @@ uses
type type
TWatchesDlgStateFlags = set of (wdsfUpdating, wdsfNeedDeleteAll, wdsfNeedDeleteCurrent); TWatchesDlgStateFlags = set of (
wdsfUpdating,
wdsfNeedDeleteAll,
wdsfNeedDeleteCurrent
);
{ TWatchesDlg } { TWatchesDlg }
@ -366,6 +370,7 @@ end;
procedure TWatchesDlg.ContextChanged(Sender: TObject); procedure TWatchesDlg.ContextChanged(Sender: TObject);
begin begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TWatchesDlg.ContextChanged ', DbgSName(Sender), ' Upd:', IsUpdating]); {$ENDIF}
UpdateAll; UpdateAll;
end; end;
@ -435,6 +440,7 @@ procedure TWatchesDlg.SnapshotChanged(Sender: TObject);
var var
NewWatches: TWatches; NewWatches: TWatches;
begin begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TWatchesDlg.SnapshotChanged ', DbgSName(Sender), ' Upd:', IsUpdating]); {$ENDIF}
lvWatches.BeginUpdate; lvWatches.BeginUpdate;
try try
NewWatches := Watches; NewWatches := Watches;
@ -614,6 +620,7 @@ var
i, l: Integer; i, l: Integer;
Snap: TSnapshot; Snap: TSnapshot;
begin begin
{$IFDEF DBG_DATA_MONITORS} DebugLn(['UpdateAll: TWatchesDlg.UpdateAll Upd:', IsUpdating]); {$ENDIF}
Snap := GetSelectedSnapshot; Snap := GetSelectedSnapshot;
if Snap <> nil if Snap <> nil
then Caption:= liswlWatchList + ' (' + Snap.LocationAsText + ')' then Caption:= liswlWatchList + ' (' + Snap.LocationAsText + ')'
@ -687,6 +694,7 @@ var
begin begin
if AWatch = nil then Exit; if AWatch = nil then Exit;
if AWatch.Collection <> FWatchesInView then exit; if AWatch.Collection <> FWatchesInView then exit;
{$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TWatchesDlg.WatchUpdate Upd:', IsUpdating, ' Watch=',AWatch.Expression]); {$ENDIF}
Item := lvWatches.Items.FindData(AWatch); Item := lvWatches.Items.FindData(AWatch);
if Item = nil if Item = nil