LazDebuggerFp, FpDebug: Fix watch-function-call when debuggee has crashed. Prevent the function call

This commit is contained in:
Martin 2023-03-13 11:01:09 +01:00
parent 42ae1a7765
commit cac376d0f9
4 changed files with 32 additions and 1 deletions

View File

@ -788,6 +788,7 @@ type
procedure RestoreTempBreakInstructionCodes;
function HasInsertedBreakInstructionAtLocation(const ALocation: TDBGPtr): Boolean; // returns Int3, if there is no break at this location
function CanContinueForWatchEval(ACurrentThread: TDbgThread): boolean; virtual;
function Continue(AProcess: TDbgProcess; AThread: TDbgThread; SingleStep: boolean): boolean; virtual;
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; virtual; abstract;
function ResolveDebugEvent(AThread: TDbgThread): TFPDEvent; virtual;
@ -2876,6 +2877,12 @@ begin
Result := FBreakMap.HasInsertedBreakInstructionAtLocation(ALocation);
end;
function TDbgProcess.CanContinueForWatchEval(ACurrentThread: TDbgThread
): boolean;
begin
Result := True;
end;
procedure TDbgProcess.MaskBreakpointsInReadData(const AAdress: TDbgPtr; const ASize: Cardinal; var AData);
begin
if FBreakMap <> nil then

View File

@ -2118,7 +2118,8 @@ begin
Result := nil;
if (FPDEvent in [deExitProcess, deFailed]) or
(FMainProcess = nil) or (FCurrentProcess = nil) or
(FCurrentThread = nil)
(FCurrentThread = nil) or
(not FCurrentProcess.CanContinueForWatchEval(FCurrentThread))
then
exit;

View File

@ -370,6 +370,7 @@ type
procedure LoadInfo; override;
function CanContinueForWatchEval(ACurrentThread: TDbgThread): boolean; override;
function Continue(AProcess: TDbgProcess; AThread: TDbgThread; SingleStep: boolean): boolean; override;
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; override;
end;
@ -1503,6 +1504,13 @@ begin
end;
end;
function TDbgLinuxProcess.CanContinueForWatchEval(ACurrentThread: TDbgThread
): boolean;
begin
Result := inherited CanContinueForWatchEval(ACurrentThread);
Result := Result and (TDbgLinuxThread(ACurrentThread).FExceptionSignal = 0)
end;
function TDbgLinuxProcess.Continue(AProcess: TDbgProcess; AThread: TDbgThread; SingleStep: boolean): boolean;
function CheckNoError: Boolean;
var

View File

@ -213,6 +213,7 @@ type
class function isSupported(ATargetInfo: TTargetDescriptor): boolean; override;
function CanContinueForWatchEval(ACurrentThread: TDbgThread): boolean; override;
function Continue(AProcess: TDbgProcess; AThread: TDbgThread; SingleStep: boolean): boolean; override;
function Detach(AProcess: TDbgProcess; AThread: TDbgThread): boolean; override;
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; override;
@ -789,6 +790,20 @@ begin
(ATargetInfo.machineType in [mt386, mtX86_64]);
end;
function TDbgWinProcess.CanContinueForWatchEval(ACurrentThread: TDbgThread
): boolean;
begin
Result := inherited CanContinueForWatchEval(ACurrentThread);
Result := Result and
( (TDbgWinThread(ACurrentThread).FHasExceptionCleared) or
(MDebugEvent.dwDebugEventCode <> EXCEPTION_DEBUG_EVENT) or
(MDebugEvent.Exception.ExceptionRecord.ExceptionCode = EXCEPTION_BREAKPOINT) or
(MDebugEvent.Exception.ExceptionRecord.ExceptionCode = STATUS_WX86_BREAKPOINT) or
(MDebugEvent.Exception.ExceptionRecord.ExceptionCode = EXCEPTION_SINGLE_STEP) or
(MDebugEvent.Exception.ExceptionRecord.ExceptionCode = STATUS_WX86_SINGLE_STEP)
);
end;
function TDbgWinProcess.Continue(AProcess: TDbgProcess; AThread: TDbgThread;
SingleStep: boolean): boolean;