FpDebug: Add asserts

This commit is contained in:
Martin 2021-09-26 02:09:18 +02:00
parent c8a6a985d0
commit f47220cc47
3 changed files with 5 additions and 0 deletions

View File

@ -284,6 +284,7 @@ var
aKernResult: kern_return_t;
old_StateCnt: mach_msg_Type_number_t;
begin
{$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadId('TFpInternalBreakpoint.ResetBreak');{$ENDIF}
if ID<0 then
begin
// The ID is set to -1 when the debugger does not have sufficient rights.

View File

@ -462,6 +462,7 @@ function TDbgLinuxThread.ReadThreadState: boolean;
var
io: iovec;
begin
{$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadId('TFpInternalBreakpoint.ResetBreak');{$ENDIF}
assert(FIsPaused, 'TDbgLinuxThread.ReadThreadState: FIsPaused');
result := true;
if FHasThreadState then

View File

@ -812,6 +812,7 @@ if AThread<>nil then debugln(['## ath.iss ',AThread.NextIsSingleStep]);
result := Windows.ContinueDebugEvent(MDebugEvent.dwProcessId, MDebugEvent.dwThreadId, DBG_CONTINUE);
DebugLn(not Result, 'ContinueDebugEvent failed: %d', [Windows.GetLastError]);
result := true;
MDebugEvent.dwProcessId := 0; // Flag as running // for assert in ReadThreadState
end;
function TDbgWinProcess.Detach(AProcess: TDbgProcess; AThread: TDbgThread
@ -1730,6 +1731,8 @@ end;
function TDbgWinThread.ReadThreadState: boolean;
begin
{$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadId('TFpInternalBreakpoint.ResetBreak');{$ENDIF}
assert(MDebugEvent.dwProcessId <> 0, 'TDbgWinThread.ReadThreadState: MDebugEvent.dwProcessId <> 0');
if Process.ProcessID <> MDebugEvent.dwProcessId then begin
DebugLn(DBG_WARNINGS, 'ERROR: attempt to read threadstate, for wrong process. Thread: %u Thread-Process: %u Event-Process %u', [Id, Process.ProcessID, MDebugEvent.dwProcessId]);
exit(False);