LazDebuggerFp (pure): Ability to pause debuggee (Windows)

git-svn-id: trunk@44749 -
This commit is contained in:
joost 2014-04-16 20:19:13 +00:00
parent 0033fa7c94
commit a69e382e98
4 changed files with 36 additions and 2 deletions

View File

@ -237,6 +237,7 @@ type
procedure RemoveThread(const AID: DWord); procedure RemoveThread(const AID: DWord);
procedure Log(AString: string); procedure Log(AString: string);
procedure Log(AString: string; Options: array of const); procedure Log(AString: string; Options: array of const);
function Pause: boolean; virtual;
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; virtual; function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; virtual;
function ReadOrdinal(const AAdress: TDbgPtr; out AData): Boolean; virtual; function ReadOrdinal(const AAdress: TDbgPtr; out AData): Boolean; virtual;
@ -681,6 +682,11 @@ begin
Log(Format(AString, Options)); Log(Format(AString, Options));
end; end;
function TDbgProcess.Pause: boolean;
begin
result := false;
end;
function TDbgProcess.GetHandle: THandle; function TDbgProcess.GetHandle: THandle;
begin begin
result := 0; result := 0;

View File

@ -51,6 +51,7 @@ type
procedure StepIntoInstr; procedure StepIntoInstr;
procedure StepOverInstr; procedure StepOverInstr;
procedure Next; procedure Next;
procedure Pause;
procedure ProcessLoop; procedure ProcessLoop;
procedure SendEvents(out continue: boolean); procedure SendEvents(out continue: boolean);
@ -147,6 +148,11 @@ begin
FCurrentThread.Next; FCurrentThread.Next;
end; end;
procedure TDbgController.Pause;
begin
FCurrentProcess.Pause;
end;
procedure TDbgController.ProcessLoop; procedure TDbgController.ProcessLoop;
var var
@ -223,7 +229,7 @@ begin
end; end;
deInternalContinue : deInternalContinue :
begin begin
if FCurrentThread.Stepping then if assigned(FCurrentThread) and FCurrentThread.Stepping then
FCurrentThread.Next; FCurrentThread.Next;
end; end;
end; {case} end; {case}

View File

@ -77,6 +77,7 @@ type
TDbgWinProcess = class(TDbgProcess) TDbgWinProcess = class(TDbgProcess)
private private
FInfo: TCreateProcessDebugInfo; FInfo: TCreateProcessDebugInfo;
FPauseRequested: boolean;
protected protected
function GetHandle: THandle; override; function GetHandle: THandle; override;
function GetLastEventProcessIdentifier: THandle; override; function GetLastEventProcessIdentifier: THandle; override;
@ -100,6 +101,7 @@ type
function GetInstructionPointerRegisterValue: TDbgPtr; override; function GetInstructionPointerRegisterValue: TDbgPtr; override;
function GetStackBasePointerRegisterValue: TDbgPtr; override; function GetStackBasePointerRegisterValue: TDbgPtr; override;
function Pause: boolean; override;
procedure TerminateProcess; override; procedure TerminateProcess; override;
@ -752,6 +754,10 @@ begin
result := deInternalContinue result := deInternalContinue
else else
result := deBreakpoint; result := deBreakpoint;
end else if FPauseRequested
then begin
result := deBreakpoint;
FPauseRequested:=false;
end end
else begin else begin
// Unknown breakpoint. // Unknown breakpoint.
@ -886,6 +892,18 @@ begin
{$endif} {$endif}
end; end;
function DebugBreakProcess(Process:HANDLE): WINBOOL; external 'kernel32' name 'DebugBreakProcess';
function TDbgWinProcess.Pause: boolean;
var
hndl: Handle;
begin
hndl := OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);
FPauseRequested:=true;
result := DebugBreakProcess(hndl);
CloseHandle(hndl);
end;
procedure TDbgWinProcess.TerminateProcess; procedure TDbgWinProcess.TerminateProcess;
begin begin
Windows.TerminateProcess(Handle, 0); Windows.TerminateProcess(Handle, 0);

View File

@ -699,6 +699,10 @@ begin
StartDebugLoop; StartDebugLoop;
result := true; result := true;
end; end;
dcPause:
begin
FDbgController.Pause;
end;
dcStepOver: dcStepOver:
begin begin
FDbgController.Next; FDbgController.Next;
@ -806,7 +810,7 @@ end;
function TFpDebugDebugger.GetSupportedCommands: TDBGCommands; function TFpDebugDebugger.GetSupportedCommands: TDBGCommands;
begin begin
Result:=[dcRun, dcStop, dcStepIntoInstr, dcStepOverInstr, dcStepOver]; Result:=[dcRun, dcStop, dcStepIntoInstr, dcStepOverInstr, dcStepOver, dcPause];
end; end;
end. end.