LazDebuggerFp (pure): Implemented step-over (next)

git-svn-id: trunk@44737 -
This commit is contained in:
joost 2014-04-15 19:22:01 +00:00
parent c780ddd0a7
commit acecc4a260
4 changed files with 85 additions and 4 deletions

View File

@ -103,11 +103,17 @@ type
FID: Integer; FID: Integer;
FHandle: THandle; FHandle: THandle;
FSingleStepping: Boolean; FSingleStepping: Boolean;
FStepping: Boolean;
function GetRegisterValueList: TDbgRegisterValueList; function GetRegisterValueList: TDbgRegisterValueList;
protected protected
FRegisterValueListValid: boolean; FRegisterValueListValid: boolean;
FRegisterValueList: TDbgRegisterValueList; FRegisterValueList: TDbgRegisterValueList;
FStoreStepSrcFilename: string;
FStoreStepSrcLineNo: integer;
FStoreStepStackFrame: TDBGPtr;
FStoreStepFuncAddr: TDBGPtr;
FHiddenBreakpoint: TDbgBreakpoint; FHiddenBreakpoint: TDbgBreakpoint;
procedure StoreStepInfo;
procedure LoadRegisterValues; virtual; procedure LoadRegisterValues; virtual;
public public
constructor Create(const AProcess: TDbgProcess; const AID: Integer; const AHandle: THandle); virtual; constructor Create(const AProcess: TDbgProcess; const AID: Integer; const AHandle: THandle); virtual;
@ -116,9 +122,12 @@ type
destructor Destroy; override; destructor Destroy; override;
function SingleStep: Boolean; virtual; function SingleStep: Boolean; virtual;
function StepOver: Boolean; virtual; function StepOver: Boolean; virtual;
function Next: Boolean; virtual;
function CompareStepInfo: boolean;
property ID: Integer read FID; property ID: Integer read FID;
property Handle: THandle read FHandle; property Handle: THandle read FHandle;
property SingleStepping: boolean read FSingleStepping write FSingleStepping; property SingleStepping: boolean read FSingleStepping write FSingleStepping;
property Stepping: boolean read FStepping write FStepping;
property RegisterValueList: TDbgRegisterValueList read GetRegisterValueList; property RegisterValueList: TDbgRegisterValueList read GetRegisterValueList;
property HiddenBreakpoint: TDbgBreakpoint read FHiddenBreakpoint; property HiddenBreakpoint: TDbgBreakpoint read FHiddenBreakpoint;
end; end;
@ -743,6 +752,40 @@ begin
result := FRegisterValueList; result := FRegisterValueList;
end; end;
function TDbgThread.CompareStepInfo: boolean;
var
AnAddr: TDBGPtr;
Sym: TFpDbgSymbol;
begin
AnAddr := FProcess.GetInstructionPointerRegisterValue;
sym := FProcess.FindSymbol(AnAddr);
if assigned(sym) then
begin
result := (FStoreStepSrcFilename=sym.FileName) and (FStoreStepSrcLineNo=sym.Line) and
(FStoreStepFuncAddr=sym.Address.Address);
end
else
result := true;
end;
procedure TDbgThread.StoreStepInfo;
var
AnAddr: TDBGPtr;
Sym: TFpDbgSymbol;
begin
FStoreStepStackFrame := FProcess.GetStackBasePointerRegisterValue;
AnAddr := FProcess.GetInstructionPointerRegisterValue;
sym := FProcess.FindSymbol(AnAddr);
if assigned(sym) then
begin
FStoreStepSrcFilename:=sym.FileName;
FStoreStepSrcLineNo:=sym.Line;
FStoreStepFuncAddr:=sym.Address.Address;
end
else
FStoreStepSrcLineNo:=-1;
end;
procedure TDbgThread.LoadRegisterValues; procedure TDbgThread.LoadRegisterValues;
begin begin
// Do nothing // Do nothing
@ -786,8 +829,6 @@ var
CallInstr: boolean; CallInstr: boolean;
begin begin
Result := False;
CallInstr:=false; CallInstr:=false;
if FProcess.ReadData(FProcess.GetInstructionPointerRegisterValue,sizeof(CodeBin),CodeBin) then if FProcess.ReadData(FProcess.GetInstructionPointerRegisterValue,sizeof(CodeBin),CodeBin) then
begin begin
@ -803,6 +844,15 @@ begin
end end
else else
SingleStep; SingleStep;
Result := True;
end;
function TDbgThread.Next: Boolean;
begin
result := StepOver;
StoreStepInfo;
FStepping:=result;
end; end;
{ TDbgBreak } { TDbgBreak }

View File

@ -50,6 +50,7 @@ type
procedure Stop; procedure Stop;
procedure StepIntoInstr; procedure StepIntoInstr;
procedure StepOverInstr; procedure StepOverInstr;
procedure Next;
procedure ProcessLoop; procedure ProcessLoop;
procedure SendEvents(out continue: boolean); procedure SendEvents(out continue: boolean);
@ -141,6 +142,11 @@ begin
FCurrentThread.StepOver; FCurrentThread.StepOver;
end; end;
procedure TDbgController.Next;
begin
FCurrentThread.Next;
end;
procedure TDbgController.ProcessLoop; procedure TDbgController.ProcessLoop;
var var
@ -179,6 +185,8 @@ begin
if assigned(FCurrentThread) then if assigned(FCurrentThread) then
begin begin
FCurrentThread.SingleStepping:=false; FCurrentThread.SingleStepping:=false;
if FPDEvent<>deInternalContinue then
FCurrentThread.Stepping := False;
if assigned(FCurrentThread.HiddenBreakpoint) then if assigned(FCurrentThread.HiddenBreakpoint) then
FCurrentThread.ClearHiddenBreakpoint; FCurrentThread.ClearHiddenBreakpoint;
end; end;
@ -213,6 +221,11 @@ begin
begin begin
debugln('Reached breakpoint at %s.',[FormatAddress(FCurrentProcess.GetInstructionPointerRegisterValue)]); debugln('Reached breakpoint at %s.',[FormatAddress(FCurrentProcess.GetInstructionPointerRegisterValue)]);
end; end;
deInternalContinue :
begin
if FCurrentThread.Stepping then
FCurrentThread.Next;
end;
end; {case} end; {case}
AExit:=true; AExit:=true;
until AExit; until AExit;

View File

@ -748,7 +748,10 @@ begin
result := deBreakpoint result := deBreakpoint
else if assigned(AThread) and assigned(AThread.HiddenBreakpoint) then begin else if assigned(AThread) and assigned(AThread.HiddenBreakpoint) then begin
AThread.HiddenBreakpoint.Hit(AThread.ID); AThread.HiddenBreakpoint.Hit(AThread.ID);
result := deBreakpoint; if AThread.Stepping and AThread.CompareStepInfo then
result := deInternalContinue
else
result := deBreakpoint;
end end
else begin else begin
// Unknown breakpoint. // Unknown breakpoint.
@ -775,6 +778,14 @@ begin
else else
result := deBreakpoint; result := deBreakpoint;
if AThread.Stepping then
begin
if AThread.CompareStepInfo then
result := deInternalContinue
else
result := deBreakpoint;
end;
// If there is a breakpoint on this location, handle the breakpoint. // If there is a breakpoint on this location, handle the breakpoint.
// Or else the int3-interrupt instruction won't be cleared and the // Or else the int3-interrupt instruction won't be cleared and the
// breakpoint will be triggered again. (Notice that the location of // breakpoint will be triggered again. (Notice that the location of

View File

@ -600,6 +600,13 @@ begin
StartDebugLoop; StartDebugLoop;
result := true; result := true;
end; end;
dcStepOver:
begin
FDbgController.Next;
SetState(dsRun);
StartDebugLoop;
result := true;
end;
end; {case} end; {case}
end; end;
@ -700,7 +707,7 @@ end;
function TFpDebugDebugger.GetSupportedCommands: TDBGCommands; function TFpDebugDebugger.GetSupportedCommands: TDBGCommands;
begin begin
Result:=[dcRun, dcStop, dcStepIntoInstr, dcStepOverInstr]; Result:=[dcRun, dcStop, dcStepIntoInstr, dcStepOverInstr, dcStepOver];
end; end;
end. end.