diff --git a/components/fpdebug/fpdbgwinclasses.pas b/components/fpdebug/fpdbgwinclasses.pas
index 9d5094a167..9b3b757500 100644
--- a/components/fpdebug/fpdbgwinclasses.pas
+++ b/components/fpdebug/fpdbgwinclasses.pas
@@ -722,6 +722,11 @@ class function TDbgWinProcess.isSupported(ATargetInfo: TTargetDescriptor
(ATargetInfo.machineType in [mt386, mtX86_64]);
end;
+function dbgsThread(AThread: TDbgThread): string;
+begin
+ if AThread = nil then result := 'nil' else Result := IntToStr(AThread.ID);
+end;
+
function TDbgWinProcess.Continue(AProcess: TDbgProcess; AThread: TDbgThread;
SingleStep: boolean): boolean;
@@ -740,7 +745,7 @@ function TDbgWinProcess.Continue(AProcess: TDbgProcess; AThread: TDbgThread;
var
EventThread, t: TDbgThread;
begin
-debugln(FPDBG_WINDOWS, ['TDbgWinProcess.Continue ',SingleStep]);
+debugln(FPDBG_WINDOWS, ['TDbgWinProcess.Continue ',SingleStep, ' ',DbgSTime, ' thread=',dbgsThread(AThread), ' event-tid=', MDebugEvent.dwThreadId]);
if assigned(AThread) and not FThreadMap.HasId(AThread.ID) then begin
AThread := nil;
end;
@@ -804,6 +809,7 @@ function TDbgWinProcess.Continue(AProcess: TDbgProcess; AThread: TDbgThread;
if SingleStep then
TDbgWinThread(AThread).SetSingleStep;
end;
+debugln('go before continue');
AProcess.ThreadsBeforeContinue;
if AThread<>nil then debugln(FPDBG_WINDOWS, ['## ath.iss ',AThread.NextIsSingleStep]);
@@ -811,13 +817,18 @@ function TDbgWinProcess.Continue(AProcess: TDbgProcess; AThread: TDbgThread;
case MDebugEvent.Exception.ExceptionRecord.ExceptionCode of
EXCEPTION_BREAKPOINT, STATUS_WX86_BREAKPOINT,
EXCEPTION_SINGLE_STEP, STATUS_WX86_SINGLE_STEP: begin
+debugln(['GOING TO RUN: DBG_CONTINUE ',MDebugEvent.dwThreadId]);
result := Windows.ContinueDebugEvent(MDebugEvent.dwProcessId, MDebugEvent.dwThreadId, DBG_CONTINUE);
end
- else
- result := Windows.ContinueDebugEvent(MDebugEvent.dwProcessId, MDebugEvent.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
+ else begin
+debugln(['GOING TO RUN: DBG_EXCEPTION_NOT_HANDLED ',MDebugEvent.dwThreadId]);
+ result := Windows.ContinueDebugEvent(MDebugEvent.dwProcessId, MDebugEvent.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
+ end;
end
- else
+ else begin
+debugln(['GOING TO RUN: DBG_CONTINUE ',MDebugEvent.dwThreadId]);
result := Windows.ContinueDebugEvent(MDebugEvent.dwProcessId, MDebugEvent.dwThreadId, DBG_CONTINUE);
+ end;
DebugLn((FPDBG_WINDOWS or DBG_WARNINGS) and (not Result), 'ContinueDebugEvent failed: %d', [Windows.GetLastError]);
result := true;
MDebugEvent.dwProcessId := 0; // Flag as running // for assert in ReadThreadState
@@ -1562,6 +1573,7 @@ procedure TDbgWinThread.Suspend;
var
r: DWORD;
begin
+debugln(['About to suspend ', id, ' already=', FIsSuspended, ' skip break=',FIsSkippingBreakPoint]);
if FIsSuspended then
exit;
r := SuspendThread(Handle);
@@ -1586,6 +1598,7 @@ procedure TDbgWinThread.Resume;
begin
if not FIsSuspended then
exit;
+debugln(['About to Resume', id]);
r := ResumeThread(Handle);
FIsSuspended := not(r <> DWORD(-1));
debugln(DBG_WARNINGS and (r = DWORD(-1)), 'Failed to resume Thread %d (handle: %d). Error: %s', [Id, Handle, GetLastErrorText]);
@@ -1609,11 +1622,17 @@ procedure TDbgWinThread.SetSingleStep;
if not ReadThreadState then
exit;
{$ifdef cpux86_64}
- if (TDbgWinProcess(Process).FBitness = b32) then
+ if (TDbgWinProcess(Process).FBitness = b32) then begin
+debugln(['Settig single step flag ', id, ' current = ', FCurrentContext^.WOW.EFlags or FLAG_TRACE_BIT]);
FCurrentContext^.WOW.EFlags := FCurrentContext^.WOW.EFlags or FLAG_TRACE_BIT // TODO WOW_FLAG....
- else
+ end
+ else begin
{$endif}
+debugln(['Settig single step flag ', id, ' current = ', FCurrentContext^.def.EFlags or FLAG_TRACE_BIT]);
FCurrentContext^.def.EFlags := FCurrentContext^.def.EFlags or FLAG_TRACE_BIT;
+ {$ifdef cpux86_64}
+ end;
+ {$endif}
FThreadContextChanged:=true;
end;
@@ -1681,8 +1700,9 @@ function TDbgWinThread.DetectHardwareWatchpoint: Pointer;
procedure TDbgWinThread.BeforeContinue;
begin
+debugln(['TDbgWinThread.BeforeContinue ', id, ' / ',FThreadContextChanged, ' susp=',FIsSuspended]);
if ID = MDebugEvent.dwThreadId then begin
- inherited;
+ inherited; ///////////////////////////// MOVE this up, outside the "IF"
{$ifdef cpux86_64}
if (TDbgWinProcess(Process).FBitness = b32) then begin