mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 19:00:59 +02:00
LazDebuggerFpLLDB: Enable capturing debug history (snapshots) on idle or break-action
git-svn-id: trunk@59811 -
This commit is contained in:
parent
1f8096d5b5
commit
950ab08ab8
@ -107,6 +107,8 @@ type
|
|||||||
private
|
private
|
||||||
FMode: (cmRun, cmRunToCatch, cmRunAfterCatch, cmRunToTmpBrk);
|
FMode: (cmRun, cmRunToCatch, cmRunAfterCatch, cmRunToTmpBrk);
|
||||||
FState: (crRunning, crReadingThreads, crStopped, crStoppedRaise, crDone);
|
FState: (crRunning, crReadingThreads, crStopped, crStoppedRaise, crDone);
|
||||||
|
FNextStepAction: TLldbInstructionProcessStepAction;
|
||||||
|
FWaitToResume: Boolean;
|
||||||
FCurBrkId, FTmpBreakId: Integer;
|
FCurBrkId, FTmpBreakId: Integer;
|
||||||
FThreadInstr: TLldbInstructionThreadList;
|
FThreadInstr: TLldbInstructionThreadList;
|
||||||
FCurrentExceptionInfo: record
|
FCurrentExceptionInfo: record
|
||||||
@ -129,6 +131,7 @@ type
|
|||||||
procedure RunInstructionSucceeded(AnInstruction: TObject);
|
procedure RunInstructionSucceeded(AnInstruction: TObject);
|
||||||
procedure ResetStateToRun;
|
procedure ResetStateToRun;
|
||||||
procedure SetNextStepCommand(AStepAction: TLldbInstructionProcessStepAction);
|
procedure SetNextStepCommand(AStepAction: TLldbInstructionProcessStepAction);
|
||||||
|
procedure ResumeWithNextStepCommand;
|
||||||
procedure SetTempBreakPoint(AnAddr: TDBGPtr);
|
procedure SetTempBreakPoint(AnAddr: TDBGPtr);
|
||||||
procedure DeleteTempBreakPoint;
|
procedure DeleteTempBreakPoint;
|
||||||
Procedure SetDebuggerLocation(AnAddr, AFrame: TDBGPtr; AFuncName, AFile, AFullFile: String; SrcLine: integer);
|
Procedure SetDebuggerLocation(AnAddr, AFrame: TDBGPtr; AFuncName, AFile, AFullFile: String; SrcLine: integer);
|
||||||
@ -136,6 +139,8 @@ type
|
|||||||
FStepAction: TLldbInstructionProcessStepAction;
|
FStepAction: TLldbInstructionProcessStepAction;
|
||||||
procedure DoLineDataReceived(var ALine: String); override;
|
procedure DoLineDataReceived(var ALine: String); override;
|
||||||
procedure DoCancel; override;
|
procedure DoCancel; override;
|
||||||
|
procedure DoInitialExecute; virtual; abstract;
|
||||||
|
procedure DoExecute; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TLldbDebugger);
|
constructor Create(AOwner: TLldbDebugger);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -146,7 +151,7 @@ type
|
|||||||
TLldbDebuggerCommandRunStep = class(TLldbDebuggerCommandRun)
|
TLldbDebuggerCommandRunStep = class(TLldbDebuggerCommandRun)
|
||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
procedure DoExecute; override;
|
procedure DoInitialExecute; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TLldbDebugger; AStepAction: TLldbInstructionProcessStepAction);
|
constructor Create(AOwner: TLldbDebugger; AStepAction: TLldbInstructionProcessStepAction);
|
||||||
end;
|
end;
|
||||||
@ -159,7 +164,7 @@ type
|
|||||||
procedure ExceptBreakInstructionFinished(Sender: TObject);
|
procedure ExceptBreakInstructionFinished(Sender: TObject);
|
||||||
procedure TargetCreated(Sender: TObject);
|
procedure TargetCreated(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
procedure DoExecute; override;
|
procedure DoInitialExecute; override;
|
||||||
constructor Create(AOwner: TLldbDebugger);
|
constructor Create(AOwner: TLldbDebugger);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -245,6 +250,7 @@ type
|
|||||||
FDebugProcess: TDebugProcess;
|
FDebugProcess: TDebugProcess;
|
||||||
FDebugInstructionQueue: TLldbInstructionQueue;
|
FDebugInstructionQueue: TLldbInstructionQueue;
|
||||||
FCommandQueue: TLldbDebuggerCommandQueue;
|
FCommandQueue: TLldbDebuggerCommandQueue;
|
||||||
|
FInIdle: Boolean;
|
||||||
FCurrentLocation: TDBGLocationRec;
|
FCurrentLocation: TDBGLocationRec;
|
||||||
FCurrentStackFrame: Integer;
|
FCurrentStackFrame: Integer;
|
||||||
FCurrentThreadId: Integer;
|
FCurrentThreadId: Integer;
|
||||||
@ -302,6 +308,7 @@ type
|
|||||||
function CreateThreads: TThreadsSupplier; override;
|
function CreateThreads: TThreadsSupplier; override;
|
||||||
function GetTargetWidth: Byte; override;
|
function GetTargetWidth: Byte; override;
|
||||||
|
|
||||||
|
function GetIsIdle: Boolean; override;
|
||||||
function GetSupportedCommands: TDBGCommands; override;
|
function GetSupportedCommands: TDBGCommands; override;
|
||||||
//function GetCommands: TDBGCommands; override;
|
//function GetCommands: TDBGCommands; override;
|
||||||
function RequestCommand(const ACommand: TDBGCommand;
|
function RequestCommand(const ACommand: TDBGCommand;
|
||||||
@ -1045,7 +1052,16 @@ begin
|
|||||||
InstructionQueue.CancelAllForCommand(Self); // in case there still are any
|
InstructionQueue.CancelAllForCommand(Self); // in case there still are any
|
||||||
DeleteTempBreakPoint;
|
DeleteTempBreakPoint;
|
||||||
// Must not call Finished; => would cancel DeleteTempBreakPoint;
|
// Must not call Finished; => would cancel DeleteTempBreakPoint;
|
||||||
CommandQueue.CommandFinished(Self);
|
if CommandQueue.RunningCommand = Self then
|
||||||
|
CommandQueue.CommandFinished(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLldbDebuggerCommandRun.DoExecute;
|
||||||
|
begin
|
||||||
|
if FWaitToResume then
|
||||||
|
ResumeWithNextStepCommand
|
||||||
|
else
|
||||||
|
DoInitialExecute;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLldbDebuggerCommandRun.RunInstructionSucceeded(AnInstruction: TObject
|
procedure TLldbDebuggerCommandRun.RunInstructionSucceeded(AnInstruction: TObject
|
||||||
@ -1067,10 +1083,26 @@ end;
|
|||||||
|
|
||||||
procedure TLldbDebuggerCommandRun.SetNextStepCommand(
|
procedure TLldbDebuggerCommandRun.SetNextStepCommand(
|
||||||
AStepAction: TLldbInstructionProcessStepAction);
|
AStepAction: TLldbInstructionProcessStepAction);
|
||||||
|
begin
|
||||||
|
FNextStepAction := AStepAction;
|
||||||
|
{$IFDEF LLDB_SKIP_SNAP}
|
||||||
|
ResumeWithNextStepCommand;
|
||||||
|
exit;
|
||||||
|
{$ENDIF}
|
||||||
|
FWaitToResume := True;
|
||||||
|
|
||||||
|
// Run the queue, before continue
|
||||||
|
CommandQueue.QueueCommand(Self);
|
||||||
|
CommandQueue.CommandFinished(Self);
|
||||||
|
//CommandQueue.FRunningCommand := nil;
|
||||||
|
//CommandQueue.Run;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLldbDebuggerCommandRun.ResumeWithNextStepCommand;
|
||||||
var
|
var
|
||||||
Instr: TLldbInstructionProcessStep;
|
Instr: TLldbInstructionProcessStep;
|
||||||
begin
|
begin
|
||||||
if AStepAction in [saOver, saInto, saOut, saInsOver] then
|
if FNextStepAction in [saOver, saInto, saOut, saInsOver] then
|
||||||
Debugger.FReRaiseBreak.Enable
|
Debugger.FReRaiseBreak.Enable
|
||||||
else
|
else
|
||||||
Debugger.FReRaiseBreak.Disable;
|
Debugger.FReRaiseBreak.Disable;
|
||||||
@ -1083,7 +1115,7 @@ begin
|
|||||||
else begin
|
else begin
|
||||||
Debugger.FCatchesBreak.Disable;
|
Debugger.FCatchesBreak.Disable;
|
||||||
Debugger.FPopExceptStack.Disable;
|
Debugger.FPopExceptStack.Disable;
|
||||||
Instr := TLldbInstructionProcessStep.Create(AStepAction);
|
Instr := TLldbInstructionProcessStep.Create(FNextStepAction);
|
||||||
end;
|
end;
|
||||||
Instr.OnFinish := @RunInstructionSucceeded;
|
Instr.OnFinish := @RunInstructionSucceeded;
|
||||||
QueueInstruction(Instr);
|
QueueInstruction(Instr);
|
||||||
@ -1800,7 +1832,7 @@ procedure TLldbRegisterSupplier.RequestData(ARegisters: TRegisters);
|
|||||||
var
|
var
|
||||||
Cmd: TLldbDebuggerCommandRegister;
|
Cmd: TLldbDebuggerCommandRegister;
|
||||||
begin
|
begin
|
||||||
if (Debugger = nil) or not(Debugger.State in [dsPause, dsStop]) then
|
if (Debugger = nil) or not(Debugger.State in [dsPause, dsInternalPause, dsStop]) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
Cmd := TLldbDebuggerCommandRegister.Create(TLldbDebugger(Debugger), ARegisters);
|
Cmd := TLldbDebuggerCommandRegister.Create(TLldbDebugger(Debugger), ARegisters);
|
||||||
@ -1840,8 +1872,18 @@ procedure TLldbDebuggerCommandQueue.Run;
|
|||||||
begin
|
begin
|
||||||
if (FRunningCommand <> nil) or (FLockQueueRun > 0) then
|
if (FRunningCommand <> nil) or (FLockQueueRun > 0) then
|
||||||
exit;
|
exit;
|
||||||
if Count = 0 then
|
{$IFnDEF LLDB_SKIP_IDLE}
|
||||||
|
if Count = 0 then begin
|
||||||
|
if Assigned(FDebugger.OnIdle) and (not FDebugger.FInIdle) then begin
|
||||||
|
FDebugger.FInIdle := True;
|
||||||
|
LockQueueRun;
|
||||||
|
FDebugger.OnIdle(Self);
|
||||||
|
UnLockQueueRun;
|
||||||
|
FDebugger.FInIdle := False;
|
||||||
|
end;
|
||||||
exit;
|
exit;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
FRunningCommand := Items[0];
|
FRunningCommand := Items[0];
|
||||||
FRunningCommand.AddReference;
|
FRunningCommand.AddReference;
|
||||||
@ -2057,7 +2099,7 @@ end;
|
|||||||
|
|
||||||
{ TLldbDebuggerCommandRunStep }
|
{ TLldbDebuggerCommandRunStep }
|
||||||
|
|
||||||
procedure TLldbDebuggerCommandRunStep.DoExecute;
|
procedure TLldbDebuggerCommandRunStep.DoInitialExecute;
|
||||||
begin
|
begin
|
||||||
SetNextStepCommand(FStepAction);
|
SetNextStepCommand(FStepAction);
|
||||||
end;
|
end;
|
||||||
@ -2201,7 +2243,7 @@ begin
|
|||||||
FRunInstr.ReleaseReference;
|
FRunInstr.ReleaseReference;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLldbDebuggerCommandRunLaunch.DoExecute;
|
procedure TLldbDebuggerCommandRunLaunch.DoInitialExecute;
|
||||||
var
|
var
|
||||||
Instr: TLldbInstruction;
|
Instr: TLldbInstruction;
|
||||||
begin
|
begin
|
||||||
@ -2426,6 +2468,7 @@ begin
|
|||||||
if State in [dsNone, dsIdle, dsStop] then
|
if State in [dsNone, dsIdle, dsStop] then
|
||||||
SetState(dsInit);
|
SetState(dsInit);
|
||||||
|
|
||||||
|
FInIdle := False;
|
||||||
Cmd := TLldbDebuggerCommandRunLaunch.Create(Self);
|
Cmd := TLldbDebuggerCommandRunLaunch.Create(Self);
|
||||||
QueueCommand(Cmd);
|
QueueCommand(Cmd);
|
||||||
Cmd.ReleaseReference;
|
Cmd.ReleaseReference;
|
||||||
@ -2488,7 +2531,6 @@ function TLldbDebugger.LldbStep(AStepAction: TLldbInstructionProcessStepAction
|
|||||||
var
|
var
|
||||||
Cmd: TLldbDebuggerCommandRunStep;
|
Cmd: TLldbDebuggerCommandRunStep;
|
||||||
begin
|
begin
|
||||||
// TODO
|
|
||||||
Result := True;
|
Result := True;
|
||||||
Cmd := TLldbDebuggerCommandRunStep.Create(Self, AStepAction);
|
Cmd := TLldbDebuggerCommandRunStep.Create(Self, AStepAction);
|
||||||
QueueCommand(Cmd);
|
QueueCommand(Cmd);
|
||||||
@ -2647,6 +2689,11 @@ begin
|
|||||||
Result := FTargetWidth;
|
Result := FTargetWidth;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLldbDebugger.GetIsIdle: Boolean;
|
||||||
|
begin
|
||||||
|
Result := FInIdle or ( (CommandQueue.Count = 0) and (CommandQueue.RunningCommand = nil) );
|
||||||
|
end;
|
||||||
|
|
||||||
function TLldbDebugger.GetSupportedCommands: TDBGCommands;
|
function TLldbDebugger.GetSupportedCommands: TDBGCommands;
|
||||||
begin
|
begin
|
||||||
Result := [dcRun, dcStop, dcStepOver, dcStepInto, dcStepOut, dcEvaluate,
|
Result := [dcRun, dcStop, dcStepOver, dcStepInto, dcStepOut, dcEvaluate,
|
||||||
|
Loading…
Reference in New Issue
Block a user