From ffdc389c25c7192392c298723ed6c17be967b56e Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 22 Nov 2024 11:33:33 +0100 Subject: [PATCH] FpDebug: Linux, check if thread is known. (cherry picked from commit 9fd6981814052c4093f3f67e4082c589bfbb07cc) --- components/fpdebug/fpdbglinuxclasses.pas | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/components/fpdebug/fpdbglinuxclasses.pas b/components/fpdebug/fpdbglinuxclasses.pas index befa0a2f47..4dbb69bb6c 100644 --- a/components/fpdebug/fpdbglinuxclasses.pas +++ b/components/fpdebug/fpdbglinuxclasses.pas @@ -394,6 +394,14 @@ var GConsoleTty: string; GSlavePTyFd: cint; +function dbgsThreadId(AThread: TDbgThread): string; +begin + if AThread = nil then + result := 'nil' + else + result := inttostr(AThread.ID); +end; + Function WIFSTOPPED(Status: Integer): Boolean; begin WIFSTOPPED:=((Status and $FF)=$7F); @@ -1545,12 +1553,12 @@ begin if (FSOLibEventBreakpoint <> nil) and not FSOLibEventBreakpoint.Enabled then FSOLibEventBreakpoint.Enabled:=True; {$IFDEF DebuglnLinuxDebugEvents} - debuglnEnter(['>>>>> TDbgLinuxProcess.Continue TID:', AThread.ID, ' SingleStep:', SingleStep ]); try + debuglnEnter(['>>>>> TDbgLinuxProcess.Continue TID:', dbgsThreadId(AThread), ' SingleStep:', SingleStep ]); try {$ENDIF} FSingleSteppingThreadID := -1; // Terminating process and all threads - if FIsTerminating then begin + if FIsTerminating and (AThread <> nil) then begin fpseterrno(0); AThread.BeforeContinue; fpPTrace(PTRACE_KILL, AThread.ID, pointer(1), nil); @@ -1559,7 +1567,7 @@ begin exit; end; - if TDbgLinuxThread(AThread).FIsPaused then // in case of deInternal, it may not be paused and can be ignored + if (AThread <> nil) and TDbgLinuxThread(AThread).FIsPaused then // in case of deInternal, it may not be paused and can be ignored AThread.NextIsSingleStep:=SingleStep; // check for pending events in other threads @@ -1618,7 +1626,7 @@ begin exit; end; - if TDbgLinuxThread(AThread).FIsPaused then // in case of deInternal, it may not be paused and can be ignored + if (AThread <> nil) and TDbgLinuxThread(AThread).FIsPaused then // in case of deInternal, it may not be paused and can be ignored if HasInsertedBreakInstructionAtLocation(AThread.GetInstructionPointerRegisterValue) then begin TempRemoveBreakInstructionCode(AThread.GetInstructionPointerRegisterValue); TDbgLinuxThread(AThread).FIsSteppingBreakPoint := True; @@ -1653,7 +1661,7 @@ begin end; end; - if TDbgLinuxThread(AThread).FIsPaused then // in case of deInternal, it may not be paused and can be ignored + if (AThread <> nil) and TDbgLinuxThread(AThread).FIsPaused then // in case of deInternal, it may not be paused and can be ignored if not FIsTerminating then begin fpseterrno(0); //AThread.BeforeContinue;