mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 06:56:10 +02:00
LazDebugger, lldb: more except handling
git-svn-id: trunk@58951 -
This commit is contained in:
parent
bcf4d94306
commit
39bce25a6e
@ -84,7 +84,7 @@ type
|
|||||||
|
|
||||||
TLldbDebuggerCommandRun = class(TLldbDebuggerCommand)
|
TLldbDebuggerCommandRun = class(TLldbDebuggerCommand)
|
||||||
private type
|
private type
|
||||||
TExceptionInfoCommand = (exiReg0, exiClass, exiMsg);
|
TExceptionInfoCommand = (exiReg0, exiReg1, exiClass, exiMsg);
|
||||||
TExceptionInfoCommands = set of TExceptionInfoCommand;
|
TExceptionInfoCommands = set of TExceptionInfoCommand;
|
||||||
private
|
private
|
||||||
FMode: (cmRun, cmRunToCatch, cmRunAfterCatch, cmRunToTmpBrk);
|
FMode: (cmRun, cmRunToCatch, cmRunAfterCatch, cmRunToTmpBrk);
|
||||||
@ -93,7 +93,7 @@ type
|
|||||||
FThreadInstr: TLldbInstructionThreadList;
|
FThreadInstr: TLldbInstructionThreadList;
|
||||||
FCurrentExceptionInfo: record
|
FCurrentExceptionInfo: record
|
||||||
FHasCommandData: TExceptionInfoCommands; // cleared in Setstate
|
FHasCommandData: TExceptionInfoCommands; // cleared in Setstate
|
||||||
FObjAddress: TDBGPtr;
|
FObjAddress, FFramePtr: TDBGPtr;
|
||||||
FExceptClass: String;
|
FExceptClass: String;
|
||||||
FExceptMsg: String;
|
FExceptMsg: String;
|
||||||
end;
|
end;
|
||||||
@ -101,16 +101,19 @@ type
|
|||||||
FFramesDescending: Boolean;
|
FFramesDescending: Boolean;
|
||||||
procedure ThreadInstructionSucceeded(Sender: TObject);
|
procedure ThreadInstructionSucceeded(Sender: TObject);
|
||||||
procedure ExceptionReadReg0Success(Sender: TObject);
|
procedure ExceptionReadReg0Success(Sender: TObject);
|
||||||
|
procedure ExceptionReadReg1Success(Sender: TObject);
|
||||||
procedure ExceptionReadClassSuccess(Sender: TObject);
|
procedure ExceptionReadClassSuccess(Sender: TObject);
|
||||||
procedure ExceptionReadMsgSuccess(Sender: TObject);
|
procedure ExceptionReadMsgSuccess(Sender: TObject);
|
||||||
procedure CatchesStackInstructionFinished(Sender: TObject);
|
procedure CatchesStackInstructionFinished(Sender: TObject);
|
||||||
procedure SearchFpStackInstructionFinished(Sender: TObject);
|
procedure SearchFpStackInstructionFinished(Sender: TObject);
|
||||||
|
procedure SearchExceptFpStackInstructionFinished(Sender: TObject);
|
||||||
procedure TempBreakPointSet(Sender: TObject);
|
procedure TempBreakPointSet(Sender: TObject);
|
||||||
procedure RunInstructionSucceeded(AnInstruction: TObject);
|
procedure RunInstructionSucceeded(AnInstruction: TObject);
|
||||||
procedure ResetStateToRun;
|
procedure ResetStateToRun;
|
||||||
procedure SetNextStepCommand(AStepAction: TLldbInstructionProcessStepAction);
|
procedure SetNextStepCommand(AStepAction: TLldbInstructionProcessStepAction);
|
||||||
procedure SetTempBreakPoint(AnAddr: TDBGPtr);
|
procedure SetTempBreakPoint(AnAddr: TDBGPtr);
|
||||||
procedure DeleteTempBreakPoint;
|
procedure DeleteTempBreakPoint;
|
||||||
|
Procedure SetDebuggerLocation(AnAddr, AFrame: TDBGPtr; AFuncName, AFile, AFullFile: String; SrcLine: integer);
|
||||||
protected
|
protected
|
||||||
FStepAction: TLldbInstructionProcessStepAction;
|
FStepAction: TLldbInstructionProcessStepAction;
|
||||||
procedure DoLineDataReceived(var ALine: String); override;
|
procedure DoLineDataReceived(var ALine: String); override;
|
||||||
@ -235,7 +238,7 @@ type
|
|||||||
FTargetRegisters: array[0..2] of String;
|
FTargetRegisters: array[0..2] of String;
|
||||||
FLldbMissingBreakSetDisable: Boolean;
|
FLldbMissingBreakSetDisable: Boolean;
|
||||||
FExceptionInfo: record
|
FExceptionInfo: record
|
||||||
FReg0Cmd, FExceptClassCmd, FExceptMsgCmd: String;
|
FReg0Cmd, FReg1Cmd, FExceptClassCmd, FExceptMsgCmd: String;
|
||||||
FAtExcepiton: Boolean; // cleared in Setstate
|
FAtExcepiton: Boolean; // cleared in Setstate
|
||||||
end;
|
end;
|
||||||
(* DoAfterLineReceived is called after DebugInstruction.ProcessInputFromDbg
|
(* DoAfterLineReceived is called after DebugInstruction.ProcessInputFromDbg
|
||||||
@ -541,6 +544,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
fr := 0;
|
fr := 0;
|
||||||
|
prev := 0;
|
||||||
repeat
|
repeat
|
||||||
ParseNewFrameLocation(r[fr], Id, IsCur, addr, stack, frame, func, Arguments, filename, fullfile, line, d);
|
ParseNewFrameLocation(r[fr], Id, IsCur, addr, stack, frame, func, Arguments, filename, fullfile, line, d);
|
||||||
Arguments.Free;
|
Arguments.Free;
|
||||||
@ -558,7 +562,7 @@ begin
|
|||||||
if frame = FFramePtrAtStart then
|
if frame = FFramePtrAtStart then
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (fr > 0) and (
|
if (prev <> 0) and (
|
||||||
( (fr < prev) and not(FFramePtrAtStart < fr) ) or
|
( (fr < prev) and not(FFramePtrAtStart < fr) ) or
|
||||||
( (fr > prev) and not(FFramePtrAtStart > fr) )
|
( (fr > prev) and not(FFramePtrAtStart > fr) )
|
||||||
)
|
)
|
||||||
@ -585,6 +589,42 @@ begin
|
|||||||
SetNextStepCommand(saContinue);
|
SetNextStepCommand(saContinue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLldbDebuggerCommandRun.SearchExceptFpStackInstructionFinished(
|
||||||
|
Sender: TObject);
|
||||||
|
var
|
||||||
|
r: TStringArray;
|
||||||
|
fr: Integer;
|
||||||
|
Id, line: Integer;
|
||||||
|
IsCur: Boolean;
|
||||||
|
addr, stack, frame: TDBGPtr;
|
||||||
|
func, filename, fullfile, d: String;
|
||||||
|
Arguments: TStringList;
|
||||||
|
begin
|
||||||
|
r := TLldbInstructionStackTrace(Sender).Res;
|
||||||
|
if Length(r) < 2 then begin
|
||||||
|
SetDebuggerState(dsPause);
|
||||||
|
Finished;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
fr := 0;
|
||||||
|
repeat
|
||||||
|
ParseNewFrameLocation(r[fr], Id, IsCur, addr, stack, frame, func, Arguments, filename, fullfile, line, d);
|
||||||
|
Arguments.Free;
|
||||||
|
|
||||||
|
if frame = FCurrentExceptionInfo.FFramePtr then
|
||||||
|
break;
|
||||||
|
|
||||||
|
inc(fr);
|
||||||
|
until fr >= Length(r);
|
||||||
|
|
||||||
|
if (fr < Length(r)) and (line > 0) then
|
||||||
|
SetDebuggerLocation(Addr, Frame, Func, filename, FullFile, Line);
|
||||||
|
|
||||||
|
SetDebuggerState(dsPause);
|
||||||
|
Finished;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLldbDebuggerCommandRun.ThreadInstructionSucceeded(Sender: TObject);
|
procedure TLldbDebuggerCommandRun.ThreadInstructionSucceeded(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FState := crStopped;
|
FState := crStopped;
|
||||||
@ -596,6 +636,12 @@ begin
|
|||||||
Include(FCurrentExceptionInfo.FHasCommandData, exiReg0);
|
Include(FCurrentExceptionInfo.FHasCommandData, exiReg0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLldbDebuggerCommandRun.ExceptionReadReg1Success(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FCurrentExceptionInfo.FFramePtr := StrToInt64Def(TLldbInstructionReadExpression(Sender).Res, 0);
|
||||||
|
Include(FCurrentExceptionInfo.FHasCommandData, exiReg1);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLldbDebuggerCommandRun.ExceptionReadClassSuccess(Sender: TObject);
|
procedure TLldbDebuggerCommandRun.ExceptionReadClassSuccess(Sender: TObject);
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
@ -683,6 +729,7 @@ const
|
|||||||
var
|
var
|
||||||
ExcClass, ExcMsg: String;
|
ExcClass, ExcMsg: String;
|
||||||
CanContinue: Boolean;
|
CanContinue: Boolean;
|
||||||
|
Instr: TLldbInstructionStackTrace;
|
||||||
begin
|
begin
|
||||||
if exiClass in FCurrentExceptionInfo.FHasCommandData then
|
if exiClass in FCurrentExceptionInfo.FHasCommandData then
|
||||||
ExcClass := FCurrentExceptionInfo.FExceptClass
|
ExcClass := FCurrentExceptionInfo.FExceptClass
|
||||||
@ -702,6 +749,15 @@ const
|
|||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
Debugger.FExceptionInfo.FAtExcepiton := True;
|
Debugger.FExceptionInfo.FAtExcepiton := True;
|
||||||
|
|
||||||
|
if (exiReg1 in FCurrentExceptionInfo.FHasCommandData) and (FCurrentExceptionInfo.FFramePtr <> 0) then begin
|
||||||
|
Instr := TLldbInstructionStackTrace.Create(MaxStackSearch, 0, Debugger.FCurrentThreadId);
|
||||||
|
Instr.OnFinish := @SearchExceptFpStackInstructionFinished;
|
||||||
|
QueueInstruction(Instr);
|
||||||
|
Instr.ReleaseReference;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
Debugger.FCurrentLocation.SrcLine := -1;
|
Debugger.FCurrentLocation.SrcLine := -1;
|
||||||
SetDebuggerState(dsPause); // after GetLocation => dsPause may run stack, watches etc
|
SetDebuggerState(dsPause); // after GetLocation => dsPause may run stack, watches etc
|
||||||
end;
|
end;
|
||||||
@ -781,17 +837,6 @@ const
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure SetDebuggerLocation(AnAddr, AFrame: TDBGPtr;
|
|
||||||
AFuncName, AFile, AFullFile: String; SrcLine: integer);
|
|
||||||
begin
|
|
||||||
Debugger.FCurrentThreadFramePtr := AFrame;
|
|
||||||
Debugger.FCurrentLocation.Address := AnAddr;
|
|
||||||
Debugger.FCurrentLocation.FuncName := AFuncName;
|
|
||||||
Debugger.FCurrentLocation.SrcFile := AFile;
|
|
||||||
Debugger.FCurrentLocation.SrcFullName := AFullFile;
|
|
||||||
Debugger.FCurrentLocation.SrcLine := SrcLine;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
Instr: TLldbInstruction;
|
Instr: TLldbInstruction;
|
||||||
found: TStringArray;
|
found: TStringArray;
|
||||||
@ -827,6 +872,11 @@ begin
|
|||||||
Instr.OnSuccess := @ExceptionReadReg0Success;
|
Instr.OnSuccess := @ExceptionReadReg0Success;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
if StrStartsWith(s, Debugger.FExceptionInfo.FReg1Cmd, True) then begin
|
||||||
|
Instr := TLldbInstructionReadExpression.Create;
|
||||||
|
Instr.OnSuccess := @ExceptionReadReg1Success;
|
||||||
|
end
|
||||||
|
else
|
||||||
if StrStartsWith(s, Debugger.FExceptionInfo.FExceptClassCmd, True) then begin
|
if StrStartsWith(s, Debugger.FExceptionInfo.FExceptClassCmd, True) then begin
|
||||||
Instr := TLldbInstructionReadExpression.Create;
|
Instr := TLldbInstructionReadExpression.Create;
|
||||||
Instr.OnSuccess := @ExceptionReadClassSuccess;
|
Instr.OnSuccess := @ExceptionReadClassSuccess;
|
||||||
@ -1007,6 +1057,17 @@ begin
|
|||||||
FTmpBreakId := 0;
|
FTmpBreakId := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLldbDebuggerCommandRun.SetDebuggerLocation(AnAddr, AFrame: TDBGPtr;
|
||||||
|
AFuncName, AFile, AFullFile: String; SrcLine: integer);
|
||||||
|
begin
|
||||||
|
Debugger.FCurrentThreadFramePtr := AFrame;
|
||||||
|
Debugger.FCurrentLocation.Address := AnAddr;
|
||||||
|
Debugger.FCurrentLocation.FuncName := AFuncName;
|
||||||
|
Debugger.FCurrentLocation.SrcFile := AFile;
|
||||||
|
Debugger.FCurrentLocation.SrcFullName := AFullFile;
|
||||||
|
Debugger.FCurrentLocation.SrcLine := SrcLine;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TLldbDebuggerCommandRun.Create(AOwner: TLldbDebugger);
|
constructor TLldbDebuggerCommandRun.Create(AOwner: TLldbDebugger);
|
||||||
begin
|
begin
|
||||||
AOwner.FExceptionInfo.FAtExcepiton := False;
|
AOwner.FExceptionInfo.FAtExcepiton := False;
|
||||||
@ -2010,12 +2071,14 @@ begin
|
|||||||
Debugger.FBreakErrorBreak.OnFinish := nil;
|
Debugger.FBreakErrorBreak.OnFinish := nil;
|
||||||
|
|
||||||
Debugger.FExceptionInfo.FReg0Cmd := '';
|
Debugger.FExceptionInfo.FReg0Cmd := '';
|
||||||
|
Debugger.FExceptionInfo.FReg1Cmd := '';
|
||||||
Debugger.FExceptionInfo.FExceptClassCmd := '';
|
Debugger.FExceptionInfo.FExceptClassCmd := '';
|
||||||
Debugger.FExceptionInfo.FExceptMsgCmd := '';
|
Debugger.FExceptionInfo.FExceptMsgCmd := '';
|
||||||
|
|
||||||
BrkId := Debugger.FExceptionBreak.BreakId;
|
BrkId := Debugger.FExceptionBreak.BreakId;
|
||||||
if BrkId > 0 then begin
|
if BrkId > 0 then begin
|
||||||
Debugger.FExceptionInfo.FReg0Cmd := 'p/x ' + Debugger.FTargetRegisters[0];
|
Debugger.FExceptionInfo.FReg0Cmd := 'p/x ' + Debugger.FTargetRegisters[0];
|
||||||
|
Debugger.FExceptionInfo.FReg1Cmd := 'p/x ' + Debugger.FTargetRegisters[1];
|
||||||
Debugger.FExceptionInfo.FExceptClassCmd := 'p ((char ***)' + Debugger.FTargetRegisters[0] + ')[0][3]';
|
Debugger.FExceptionInfo.FExceptClassCmd := 'p ((char ***)' + Debugger.FTargetRegisters[0] + ')[0][3]';
|
||||||
Debugger.FExceptionInfo.FExceptMsgCmd := 'p ((char **)' + Debugger.FTargetRegisters[0] + ')[1]';
|
Debugger.FExceptionInfo.FExceptMsgCmd := 'p ((char **)' + Debugger.FTargetRegisters[0] + ')[1]';
|
||||||
// 'p ((EXCEPTION *)' + Debugger.FTargetRegisters[0] + ')->FMESSAGE'
|
// 'p ((EXCEPTION *)' + Debugger.FTargetRegisters[0] + ')->FMESSAGE'
|
||||||
|
Loading…
Reference in New Issue
Block a user