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