mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-02 02:16:20 +02:00
FpDbg: Implemented single-stepping on Darwin
git-svn-id: trunk@44500 -
This commit is contained in:
parent
272765465b
commit
3f36dd3c53
@ -146,6 +146,7 @@ procedure DebugLoop;
|
||||
var
|
||||
AFirstLoop: boolean;
|
||||
AProcessIdentifier: THandle;
|
||||
AThreadIdentifier: THandle;
|
||||
ALib: TDbgLibrary;
|
||||
|
||||
begin
|
||||
@ -156,7 +157,7 @@ begin
|
||||
GState := dsRun;
|
||||
end;
|
||||
|
||||
if not GCurrentProcess.WaitForDebugEvent(AProcessIdentifier) then Continue;
|
||||
if not GCurrentProcess.WaitForDebugEvent(AProcessIdentifier, AThreadIdentifier) then Continue;
|
||||
|
||||
if assigned(GCurrentProcess) and not assigned(GMainProcess) then
|
||||
begin
|
||||
@ -172,8 +173,8 @@ begin
|
||||
if AFirstLoop then
|
||||
GCurrentProcess := GMainProcess;
|
||||
|
||||
//if not GetThread(MDebugEvent.dwTHreadID, GCurrentThread)
|
||||
//then WriteLN('LOOP: Unable to retrieve current thread');
|
||||
if not GCurrentProcess.GetThread(AThreadIdentifier, GCurrentThread)
|
||||
then WriteLN('LOOP: Unable to retrieve current thread');
|
||||
|
||||
GState := dsEvent;
|
||||
begin
|
||||
|
@ -169,7 +169,7 @@ type
|
||||
function ReadWString(const AAdress: TDbgPtr; const AMaxSize: Cardinal; out AData: WideString): Boolean; virtual;
|
||||
|
||||
function Continue(AProcess: TDbgProcess; AThread: TDbgThread; AState: TFPDState): boolean; virtual;
|
||||
function WaitForDebugEvent(out ProcessIdentifier: THandle): boolean; virtual; abstract;
|
||||
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; virtual; abstract;
|
||||
function ResolveDebugEvent(AThread: TDbgThread): TFPDEvent; virtual; abstract;
|
||||
|
||||
function WriteData(const AAdress: TDbgPtr; const ASize: Cardinal; const AData): Boolean; virtual;
|
||||
|
@ -72,7 +72,7 @@ type
|
||||
function GetStackBasePointerRegisterValue: TDbgPtr; override;
|
||||
|
||||
function Continue(AProcess: TDbgProcess; AThread: TDbgThread; AState: TFPDState): boolean; override;
|
||||
function WaitForDebugEvent(out ProcessIdentifier: THandle): boolean; override;
|
||||
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; override;
|
||||
function ResolveDebugEvent(AThread: TDbgThread): TFPDEvent; override;
|
||||
end;
|
||||
|
||||
@ -310,7 +310,10 @@ begin
|
||||
fpPTrace(PTRACE_CONT, ProcessID, nil, nil);
|
||||
{$endif linux}
|
||||
{$ifdef darwin}
|
||||
fpPTrace(PTRACE_CONT, ProcessID, pointer(1), nil);
|
||||
if AThread.SingleStepping then
|
||||
fpPTrace(PTRACE_SINGLESTEP, ProcessID, pointer(1), nil)
|
||||
else
|
||||
fpPTrace(PTRACE_CONT, ProcessID, pointer(1), nil);
|
||||
{$endif darwin}
|
||||
e := fpgeterrno;
|
||||
if e <> 0 then
|
||||
@ -322,7 +325,7 @@ begin
|
||||
result := true;
|
||||
end;
|
||||
|
||||
function TDbgDarwinProcess.WaitForDebugEvent(out ProcessIdentifier: THandle): boolean;
|
||||
function TDbgDarwinProcess.WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean;
|
||||
var
|
||||
aKernResult: kern_return_t;
|
||||
act_list: thread_act_array_t;
|
||||
@ -354,7 +357,7 @@ begin
|
||||
FMainThread := AThread;
|
||||
end;
|
||||
end;
|
||||
|
||||
ThreadIdentifier:=act_list^[0];
|
||||
TDbgDarwinThread(FMainThread).ReadThreadState;
|
||||
end
|
||||
end;
|
||||
|
@ -92,7 +92,7 @@ type
|
||||
|
||||
class function StartInstance(AFileName: string; AParams: string): TDbgProcess; override;
|
||||
function Continue(AProcess: TDbgProcess; AThread: TDbgThread; AState: TFPDState): boolean; override;
|
||||
function WaitForDebugEvent(out ProcessIdentifier: THandle): boolean; override;
|
||||
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; override;
|
||||
function ResolveDebugEvent(AThread: TDbgThread): TFPDEvent; override;
|
||||
procedure StartProcess(const AInfo: TCreateProcessDebugInfo);
|
||||
|
||||
@ -449,10 +449,11 @@ begin
|
||||
result := true;
|
||||
end;
|
||||
|
||||
function TDbgWinProcess.WaitForDebugEvent(out ProcessIdentifier: THandle): boolean;
|
||||
function TDbgWinProcess.WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean;
|
||||
begin
|
||||
result := Windows.WaitForDebugEvent(MDebugEvent, 10);
|
||||
ProcessIdentifier:=MDebugEvent.dwProcessId;
|
||||
ThreadIdentifier:=MDebugEvent.dwThreadId;
|
||||
end;
|
||||
|
||||
function TDbgWinProcess.ResolveDebugEvent(AThread: TDbgThread): TFPDEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user