From 369017a0c5c1194d15296ecc17d3bdb46840d607 Mon Sep 17 00:00:00 2001 From: martin Date: Sun, 12 Feb 2012 22:59:28 +0000 Subject: [PATCH] DBG: move same debugln to LazLogger cmd-line config git-svn-id: trunk@35339 - --- components/lazutils/lazlogger.pas | 27 ++++++++++++++++++ debugger/callstackdlg.pp | 17 +++++++----- debugger/debugger.pp | 46 +++++++++++++++---------------- debugger/localsdlg.pp | 9 ++++-- debugger/threaddlg.pp | 11 +++++--- debugger/watchesdlg.pp | 19 +++++++------ 6 files changed, 84 insertions(+), 45 deletions(-) diff --git a/components/lazutils/lazlogger.pas b/components/lazutils/lazlogger.pas index 65b12aa07f..ac3c100cc1 100644 --- a/components/lazutils/lazlogger.pas +++ b/components/lazutils/lazlogger.pas @@ -247,6 +247,8 @@ type function RegisterLogGroup(const AConfigName: String; ADefaulEnabled: Boolean) : PLazLoggerLogGroup; function RegisterLogGroup(const AConfigName: String) : PLazLoggerLogGroup; + function FindOrRegisterLogGroup(const AConfigName: String; ADefaulEnabled: Boolean) : PLazLoggerLogGroup; + function FindOrRegisterLogGroup(const AConfigName: String) : PLazLoggerLogGroup; // comma separated list / not present = defaults (none unless emabled in code) / - means none property ParamForEnabledLogGroups: String read FParamForEnabledLogGroups write SetParamForEnabledLogGroups; property LogGroupList: TLazLoggerLogGroupList read GetLogGroupList; @@ -1464,6 +1466,31 @@ begin Result^.Flags := Result^.Flags + [lgfNoDefaultEnabledSpecified]; end; +function TLazLogger.FindOrRegisterLogGroup(const AConfigName: String; + ADefaulEnabled: Boolean): PLazLoggerLogGroup; +begin + Result := LogGroupList.Find(AConfigName); + if Result = nil then + Result := RegisterLogGroup(AConfigName, ADefaulEnabled) + else + begin + if (lgfNoDefaultEnabledSpecified in Result^.Flags) and + not(lgfAddedByParamParser in Result^.Flags) + then + Result^.Enabled := ADefaulEnabled; + Result^.Flags := Result^.Flags - [lgfNoDefaultEnabledSpecified, lgfAddedByParamParser]; + end; +end; + +function TLazLogger.FindOrRegisterLogGroup(const AConfigName: String): PLazLoggerLogGroup; +begin + Result := LogGroupList.Find(AConfigName); + if Result = nil then + Result := RegisterLogGroup(AConfigName) + else + Result^.Flags := Result^.Flags - [lgfAddedByParamParser]; +end; + procedure TLazLogger.DebuglnStack(const s: string); begin DebugLn(s); diff --git a/debugger/callstackdlg.pp b/debugger/callstackdlg.pp index 7a334db40b..0b502366d5 100644 --- a/debugger/callstackdlg.pp +++ b/debugger/callstackdlg.pp @@ -36,7 +36,7 @@ unit CallStackDlg; interface uses - SysUtils, Classes, Controls, Forms, LCLProc, + SysUtils, Classes, Controls, Forms, LCLProc, LazLogger, IDEWindowIntf, DebuggerStrConst, ComCtrls, Debugger, DebuggerDlg, Menus, ClipBrd, ExtCtrls, StdCtrls, ActnList, IDEImagesIntf, IDECommands; @@ -151,6 +151,7 @@ uses BaseDebugManager, LazarusIDEStrConsts; var + DBG_DATA_MONITORS: PLazLoggerLogGroup; imgSourceLine: Integer; imgNoSourceLine: Integer; @@ -199,7 +200,7 @@ end; procedure TCallStackDlg.CallStackChanged(Sender: TObject); begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataWindow: TCallStackDlg.CallStackChanged from ', DbgSName(Sender), ' Upd:', IsUpdating]); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataWindow: TCallStackDlg.CallStackChanged from ', DbgSName(Sender), ' Upd:', IsUpdating]); if not ToolButtonPower.Down then exit; if FViewStart = 0 then UpdateView @@ -209,7 +210,7 @@ end; procedure TCallStackDlg.CallStackCurrent(Sender: TObject); begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataWindow: TCallStackDlg.CallStackCurrent from ', DbgSName(Sender), ' Upd:', IsUpdating]); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataWindow: TCallStackDlg.CallStackCurrent from ', DbgSName(Sender), ' Upd:', IsUpdating]); if not ToolButtonPower.Down then exit; UpdateView; end; @@ -273,11 +274,11 @@ var begin if (not ToolButtonPower.Down) or FInUpdateView then exit; if IsUpdating then begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataWindow: TCallStackDlg.UpdateView in IsUpdating']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataWindow: TCallStackDlg.UpdateView in IsUpdating']); Include(FUpdateFlags, ufNeedUpdating); exit; end; - {$IFDEF DBG_DATA_MONITORS} try DebugLnEnter(['DebugDataWindow: >>ENTER: TCallStackDlg.UpdateView']); {$ENDIF} + try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataWindow: >>ENTER: TCallStackDlg.UpdateView']); Exclude(FUpdateFlags, ufNeedUpdating); @@ -370,7 +371,7 @@ begin lvCallStack.EndUpdate; EndUpdate; end; - {$IFDEF DBG_DATA_MONITORS} finally DebugLnExit(['DebugDataWindow: <>ENTER: TSnapshotManager.DoStateChange New-State=', DBGStateNames[FCurrentState]]); {$ENDIF} + DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: TSnapshotManager.DoStateChange New-State=', DBGStateNames[FCurrentState]]); BeginUpdate; try @@ -4072,7 +4072,7 @@ begin finally EndUpdate; end; - {$IFDEF DBG_DATA_MONITORS} DebugLnExit(['DebugDataMonitor: <>ENTER: TSnapshotManager.DoDebuggerIdle New-State=', DBGStateNames[FCurrentState]]); {$ENDIF} + DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: TSnapshotManager.DoDebuggerIdle New-State=', DBGStateNames[FCurrentState]]); try if not(smrThreads in FRequestsDone) then begin @@ -4143,7 +4143,7 @@ begin end; finally Exclude(FUpdateFlags, ufInDebuggerIdle); - {$IFDEF DBG_DATA_MONITORS} DebugLnExit(['DebugDataMonitor: <>ENTER: TCurrentWatchValueList.CreateEntry AThreadId=', AThreadId, ' AStackFrame=',AStackFrame, ' Expr=', FWatch.Expression]); {$ENDIF} + try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: TCurrentWatchValueList.CreateEntry AThreadId=', AThreadId, ' AStackFrame=',AStackFrame, ' Expr=', FWatch.Expression]); Result := TCurrentWatchValue.Create(FWatch, AThreadId, AStackFrame, ADisplayFormat); Add(Result); if FSnapShot <> nil then begin @@ -4616,7 +4616,7 @@ begin FSnapShot.Add(R); TCurrentWatchValue(Result).SnapShot := R; end; - {$IFDEF DBG_DATA_MONITORS} finally DebugLnExit(['DebugDataMonitor: <>ENTER: TCurrentCallStackList.GetEntryForThread: ThreadId=', AThreadId]); {$ENDIF} + try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: TCurrentCallStackList.GetEntryForThread: ThreadId=', AThreadId]); Result := TCurrentCallStack.Create(FMonitor); Result.ThreadId := AThreadId; Add(Result); @@ -5302,7 +5302,7 @@ begin FSnapShot.Add(R); TCurrentCallStack(Result).SnapShot := R; end; - {$IFDEF DBG_DATA_MONITORS} finally DebugLnExit(['DebugDataMonitor: <>ENTER: ', ClassName, '.DoStateChange New-State=', DBGStateNames[FNotifiedState]]); {$ENDIF} + DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: ', ClassName, '.DoStateChange New-State=', DBGStateNames[FNotifiedState]]); if FNotifiedState in [dsPause, dsInternalPause] then begin @@ -5450,7 +5450,7 @@ begin // stopped // typical: finalize snapshot and clear data. DoStateLeavePauseClean; end; - {$IFDEF DBG_DATA_MONITORS} DebugLnExit(['DebugDataMonitor: < nil) @@ -5531,7 +5531,7 @@ end; procedure TCurrentThreads.SetCurrentThreadId(const AValue: Integer); begin if FCurrentThreadId = AValue then exit; - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCurrentThreads.SetCurrentThreadId ', AValue]); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TCurrentThreads.SetCurrentThreadId ', AValue]); inherited SetCurrentThreadId(AValue); FMonitor.CurrentChanged; // TODO ChangedSelection end; @@ -5687,7 +5687,7 @@ end; procedure TThreadsMonitor.Clear; begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TThreadsMonitor.Clear']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TThreadsMonitor.Clear']); FCurrentThreads.Clear; Changed; end; @@ -9423,7 +9423,7 @@ end; procedure TCallStackMonitor.UpdateCurrentIndex; begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackMonitor.UpdateCurrentIndex']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TCallStackMonitor.UpdateCurrentIndex']); if Supplier <> nil then Supplier.UpdateCurrentIndex; NotifyCurrent; end; @@ -9436,7 +9436,7 @@ end; procedure TCallStackMonitor.CallStackClear(Sender: TObject); begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackMonitor.CallStackClear']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TCallStackMonitor.CallStackClear']); // Don't clear, set it to 0 so there are no entries shown //SetCount(0); NotifyChange; @@ -9481,7 +9481,7 @@ end; procedure TCallStackSupplier.Changed; begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackSupplier.Changed']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TCallStackSupplier.Changed']); Monitor.NotifyChange; end; @@ -9538,7 +9538,7 @@ var e: TCallStackEntry; It: TMapIterator; begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackSupplier.RequestEntries']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TCallStackSupplier.RequestEntries']); It := TMapIterator.Create(ACallstack.FEntries); if not It.Locate(ACallstack.LowestUnknown ) @@ -9559,7 +9559,7 @@ end; procedure TCallStackSupplier.CurrentChanged; begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TCallStackSupplier.CurrentChanged']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TCallStackSupplier.CurrentChanged']); if Monitor <> nil then Monitor.NotifyCurrent; end; @@ -11046,7 +11046,7 @@ initialization DBG_STATE := DebugLogger.RegisterLogGroup('DBG_STATE' {$IFDEF DBG_STATE} , True {$ENDIF} ); DBG_EVENTS := DebugLogger.RegisterLogGroup('DBG_EVENTS' {$IFDEF DBG_EVENTS} , True {$ENDIF} ); DBG_STATE_EVENT := DebugLogger.RegisterLogGroup('DBG_STATE_EVENT' {$IFDEF DBG_STATE_EVENT} , True {$ENDIF} ); - + DBG_DATA_MONITORS := DebugLogger.FindOrRegisterLogGroup('DBG_DATA_MONITORS' {$IFDEF DBG_DATA_MONITORS} , True {$ENDIF} ); finalization DoFinalization; diff --git a/debugger/localsdlg.pp b/debugger/localsdlg.pp index 73da5d7a23..8d19462405 100644 --- a/debugger/localsdlg.pp +++ b/debugger/localsdlg.pp @@ -36,7 +36,7 @@ unit LocalsDlg; interface uses - SysUtils, Classes, Forms, ClipBrd, LCLProc, + SysUtils, Classes, Forms, ClipBrd, LCLProc, LazLogger, IDEWindowIntf, DebuggerStrConst, ComCtrls, ActnList, Menus, BaseDebugManager, Debugger, DebuggerDlg; @@ -94,6 +94,7 @@ uses LazarusIDEStrConsts; var + DBG_DATA_MONITORS: PLazLoggerLogGroup; LocalsDlgWindowCreator: TIDEWindowCreator; const @@ -191,12 +192,12 @@ begin end; if IsUpdating then begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataWindow: TLocalsDlg.LocalsChanged in IsUpdating']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataWindow: TLocalsDlg.LocalsChanged in IsUpdating']); Include(FUpdateFlags, ufNeedUpdating); exit; end; Exclude(FUpdateFlags, ufNeedUpdating); - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataMonitor: TLocalsDlg.LocalsChanged']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TLocalsDlg.LocalsChanged']); if GetStackframe < 0 then begin // TODO need dedicated validity property lvLocals.Items.Clear; @@ -362,5 +363,7 @@ initialization LocalsDlgWindowCreator.DividerTemplate.Add('LocalsValue', COL_LOCALS_VALUE, drsColWidthValue); LocalsDlgWindowCreator.CreateSimpleLayout; + DBG_DATA_MONITORS := DebugLogger.FindOrRegisterLogGroup('DBG_DATA_MONITORS' {$IFDEF DBG_DATA_MONITORS} , True {$ENDIF} ); + end. diff --git a/debugger/threaddlg.pp b/debugger/threaddlg.pp index fb12608b9c..8fa60a3987 100644 --- a/debugger/threaddlg.pp +++ b/debugger/threaddlg.pp @@ -5,7 +5,7 @@ unit ThreadDlg; interface uses - Classes, SysUtils, ComCtrls, LCLProc, + Classes, SysUtils, ComCtrls, LCLProc, LazLogger, Debugger, DebuggerDlg, Forms, LazarusIDEStrConsts, IDEWindowIntf, DebuggerStrConst, BaseDebugManager, IDEImagesIntf; @@ -43,6 +43,7 @@ implementation {$R *.lfm} var + DBG_DATA_MONITORS: PLazLoggerLogGroup; ThreadDlgWindowCreator: TIDEWindowCreator; const @@ -78,12 +79,12 @@ var Snap: TSnapshot; begin if IsUpdating then begin - {$IFDEF DBG_DATA_MONITORS} DebugLn(['DebugDataWindow: TThreadsDlg.ThreadsChanged from ', DbgSName(Sender), ' in IsUpdating']); {$ENDIF} + DebugLn(DBG_DATA_MONITORS, ['DebugDataWindow: TThreadsDlg.ThreadsChanged from ', DbgSName(Sender), ' in IsUpdating']); Include(FUpdateFlags, ufThreadChanged); exit; end; - {$IFDEF DBG_DATA_MONITORS} try DebugLnEnter(['DebugDataMonitor: >>ENTER: TThreadsDlg.ThreadsChanged from ', DbgSName(Sender)]); {$ENDIF} + try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: TThreadsDlg.ThreadsChanged from ', DbgSName(Sender)]); Exclude(FUpdateFlags, ufThreadChanged); BeginUpdate; @@ -147,7 +148,7 @@ begin lvThreads.EndUpdate; EndUpdate; end; - {$IFDEF DBG_DATA_MONITORS} finally DebugLnExit(['DebugDataMonitor: <>ENTER: TWatchesDlg.UpdateAll ']); {$ENDIF} + try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataWindow: TWatchesDlg.UpdateAll: >>ENTER: TWatchesDlg.UpdateAll ']); Snap := GetSelectedSnapshot; if Snap <> nil @@ -701,7 +702,7 @@ begin lvWatches.EndUpdate; lvWatchesSelectItem(nil, nil, False); end; - {$IFDEF DBG_DATA_MONITORS} finally DebugLnExit(['DebugDataWindow: TWatchesDlg.UpdateAll: < FWatchesInView then exit; - {$IFDEF DBG_DATA_MONITORS} try DebugLnEnter(['DebugDataWindow: TWatchesDlg.WatchUpdate Upd:', IsUpdating, ' Watch=',AWatch.Expression]); {$ENDIF} + try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataWindow: TWatchesDlg.WatchUpdate Upd:', IsUpdating, ' Watch=',AWatch.Expression]); Item := lvWatches.Items.FindData(AWatch); if Item = nil @@ -751,7 +752,7 @@ begin if not FUpdatingAll then lvWatchesSelectItem(nil, nil, False); - {$IFDEF DBG_DATA_MONITORS} finally DebugLnExit(['DebugDataWindow: TWatchesDlg.WatchUpdate']); end; {$ENDIF} + finally DebugLnExit(DBG_DATA_MONITORS, ['DebugDataWindow: TWatchesDlg.WatchUpdate']); end; end; procedure TWatchesDlg.WatchRemove(const ASender: TWatches; const AWatch: TWatch); @@ -770,5 +771,7 @@ initialization WatchWindowCreator.DividerTemplate.Add('ColumnWatchValue', COL_WATCH_VALUE, drsColWidthValue); WatchWindowCreator.CreateSimpleLayout; + DBG_DATA_MONITORS := DebugLogger.FindOrRegisterLogGroup('DBG_DATA_MONITORS' {$IFDEF DBG_DATA_MONITORS} , True {$ENDIF} ); + end.