FpDebug: fix race condition, during exit debug session (new command started while FDbgControllerProcessExitEvent called ProcessMessages)

This commit is contained in:
Martin 2025-04-20 13:10:28 +02:00
parent efae02fac3
commit b1a29e7546
3 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,7 @@ uses
type
TFPDEvent = (
deNone,
deExitProcess, deCreateProcess,
deLoadLibrary, deUnloadLibrary,
deFinishedStep, deBreakpoint, deHardCodedBreakpoint,
@ -1098,6 +1099,7 @@ type
const
FPDEventNames: array[TFPDEvent] of string = (
'deNone',
'deExitProcess', 'deCreateProcess',
'deLoadLibrary', 'deUnloadLibrary',
'deFinishedStep', 'deBreakpoint', 'deHardCodedBreakpoint',

View File

@ -2101,10 +2101,12 @@ begin
if assigned(OnProcessExitEvent) then
OnProcessExitEvent(FCurrentProcess.ExitCode);
FProcessMap.Delete(FCurrentProcess.ProcessID);
if FCurrentProcess <> nil then
FProcessMap.Delete(FCurrentProcess.ProcessID);
FCurrentProcess.Free;
FCurrentProcess := nil;
HasPauseRequest := False;
FPDEvent := deNone;
continue := false;
end;
deException:

View File

@ -4131,6 +4131,10 @@ begin
if assigned(FDbgController) then
FDbgController.NextOnlyStopOnStartLine := TFpDebugDebuggerProperties(GetProperties).NextOnlyStopOnStartLine;
// don't start new commands while exit event is processed
if FDbgController.Event in [deExitProcess, deDetachFromProcess] then
exit;
if (ACommand in [dcRun, dcStepOver, dcStepInto, dcStepOut, dcStepTo, dcRunTo, dcJumpto,
dcStepOverInstr, dcStepIntoInstr, dcAttach]) and
not assigned(FDbgController.MainProcess)