LazDebuggerFp: Make sure OnIdle is called, and all results are awaited. (Fixes Debug History) / DebugManager triggers snapshots for any dsPause and dsInternalPause.

This commit is contained in:
Martin 2021-09-26 01:56:00 +02:00
parent edb26c9d33
commit f99f5c0ed9

View File

@ -34,7 +34,7 @@ interface
uses uses
Classes, SysUtils, fgl, math, process, Classes, SysUtils, fgl, math, process,
Forms, Dialogs, syncobjs, Forms, Dialogs, syncobjs,
Maps, LazLogger, LazUTF8, lazCollections, Maps, LazLoggerBase, LazUTF8, lazCollections,
DbgIntfBaseTypes, DbgIntfDebuggerBase, DbgIntfBaseTypes, DbgIntfDebuggerBase,
FpDebugDebuggerUtils, FpDebugDebuggerWorkThreads, FpDebugDebuggerUtils, FpDebugDebuggerWorkThreads,
// FpDebug // FpDebug
@ -633,11 +633,18 @@ var
c: LongInt; c: LongInt;
begin begin
FpDebugger.FWorkQueue.Lock; FpDebugger.FWorkQueue.Lock;
Application.ProcessMessages;
FpDebugger.CheckAndRunIdle; FpDebugger.CheckAndRunIdle;
c := FpDebugger.FWorkQueue.Count; (* IdleThreadCount could (race condition) be to high.
Then DebugHistory may loose ONE item. (only one working thread.
Practically this is unlikely, since the thread had time to set
the count, since the Lock started.
*)
c := FpDebugger.FWorkQueue.Count + FpDebugger.FWorkQueue.ThreadCount - FpDebugger.FWorkQueue.IdleThreadCount;
FpDebugger.FWorkQueue.Unlock; FpDebugger.FWorkQueue.Unlock;
if c = 0 then begin if c = 0 then begin
Application.ProcessMessages;
FpDebugger.StartDebugLoop; FpDebugger.StartDebugLoop;
end end
else begin else begin
@ -3413,8 +3420,15 @@ begin
if State in [dsPause, dsInternalPause] then begin if State in [dsPause, dsInternalPause] then begin
FWorkQueue.Lock; FWorkQueue.Lock;
CheckAndRunIdle; CheckAndRunIdle;
c := FWorkQueue.Count; (* IdleThreadCount could (race condition) be to high.
Then DebugHistory may loose ONE item. (only one working thread.
Practically this is unlikely, since the thread had time to set
the count, since the Lock started.
*)
c := FWorkQueue.Count + FWorkQueue.ThreadCount - FWorkQueue.IdleThreadCount;
FWorkQueue.Unlock; FWorkQueue.Unlock;
if c = 0 then
Application.ProcessMessages;
end end
else else
c := 0; c := 0;
@ -3464,7 +3478,7 @@ end;
procedure TFpDebugDebugger.CheckAndRunIdle; procedure TFpDebugDebugger.CheckAndRunIdle;
begin begin
if (State <> dsPause) or if (not (State in [dsPause, dsInternalPause])) or
(not Assigned(OnIdle)) or (not Assigned(OnIdle)) or
(FWorkQueue.Count <> 0) (FWorkQueue.Count <> 0)
then then