mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 23:49:36 +02:00
LazDebuggerFp, FpDebug: Refactor FindContext
git-svn-id: trunk@61968 -
This commit is contained in:
parent
3e1d403bae
commit
fa44aa0f0b
@ -310,7 +310,6 @@ var
|
||||
i: Integer;
|
||||
m: TFpValue;
|
||||
n, v: String;
|
||||
Reg: TDBGPtr;
|
||||
PrettyPrinter: TFpPascalPrettyPrinter;
|
||||
begin
|
||||
result := false;
|
||||
@ -318,8 +317,7 @@ begin
|
||||
(AController.CurrentProcess.DbgInfo = nil) then
|
||||
exit;
|
||||
|
||||
Reg := AController.CurrentThread.GetInstructionPointerRegisterValue;
|
||||
AContext := AController.CurrentProcess.DbgInfo.FindContext(AController.CurrentThread.ID, 0, Reg);
|
||||
AContext := AController.CurrentProcess.FindContext(AController.CurrentThread.ID, 0);
|
||||
|
||||
if (AContext = nil) or (AContext.SymbolAtAddress = nil) then
|
||||
exit;
|
||||
@ -663,7 +661,6 @@ function TFpDebugThreadEvaluateCommand.Execute(AController: TFpServerDbgControll
|
||||
var
|
||||
AContext: TFpDbgInfoContext;
|
||||
APasExpr: TFpPascalExpression;
|
||||
ADbgInfo: TDbgInfo;
|
||||
Res: Boolean;
|
||||
APrettyPrinter: TFpPascalPrettyPrinter;
|
||||
ATypeInfo: TDBGType;
|
||||
@ -677,8 +674,7 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
ADbgInfo := AController.CurrentProcess.DbgInfo;
|
||||
AContext := ADbgInfo.FindContext(AController.CurrentThread.ID, 0, AController.CurrentThread.GetInstructionPointerRegisterValue);
|
||||
AContext := AController.CurrentProcess.FindContext(AController.CurrentThread.ID, 0);
|
||||
if AContext = nil then
|
||||
begin
|
||||
FValidity:=ddsInvalid;
|
||||
|
@ -391,6 +391,8 @@ type
|
||||
function AddBreak(const ALocation: TDBGPtrArray): TFpInternalBreakpoint; overload;
|
||||
function FindProcSymbol(const AName: String): TFpSymbol;
|
||||
function FindProcSymbol(AAdress: TDbgPtr): TFpSymbol;
|
||||
function FindContext(AThreadId, AStackFrame: Integer): TFpDbgInfoContext;
|
||||
function FindContext(AAddress: TDbgPtr): TFpDbgInfoContext; deprecated 'use FindContext(thread,stack)';
|
||||
function GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
|
||||
function GetThread(const AID: Integer; out AThread: TDbgThread): Boolean;
|
||||
procedure RemoveBreak(const ABreakPoint: TFpInternalBreakpoint);
|
||||
@ -776,7 +778,7 @@ begin
|
||||
if assigned(ProcSymbol) then begin
|
||||
ProcVal := ProcSymbol.Value;
|
||||
if (ProcVal <> nil) then begin
|
||||
InstrPointerValue := FThread.GetInstructionPointerRegisterValue;
|
||||
InstrPointerValue := AnAddress;
|
||||
if InstrPointerValue <> 0 then begin
|
||||
AContext := FThread.Process.DbgInfo.FindContext(FThread.ID, Index, InstrPointerValue);
|
||||
if AContext <> nil then begin
|
||||
@ -1185,6 +1187,7 @@ end;
|
||||
function TDbgProcess.FindProcSymbol(const AName: String): TFpSymbol;
|
||||
begin
|
||||
Result := FDbgInfo.FindProcSymbol(AName);
|
||||
// SymbolTableInfo.FindProcSymbol()
|
||||
end;
|
||||
|
||||
function TDbgProcess.FindProcSymbol(AAdress: TDbgPtr): TFpSymbol;
|
||||
@ -1199,6 +1202,38 @@ begin
|
||||
if Result <> nil then Exit;
|
||||
end;
|
||||
Result := nil;
|
||||
// SymbolTableInfo.FindProcSymbol()
|
||||
end;
|
||||
|
||||
function TDbgProcess.FindContext(AThreadId, AStackFrame: Integer): TFpDbgInfoContext;
|
||||
var
|
||||
Thread: TDbgThread;
|
||||
Frame: TDbgCallstackEntry;
|
||||
Addr: TDBGPtr;
|
||||
begin
|
||||
Result := nil;
|
||||
if not GetThread(AThreadId, Thread) then
|
||||
exit;
|
||||
if AStackFrame = 0 then
|
||||
Addr := Thread.GetInstructionPointerRegisterValue
|
||||
else
|
||||
begin
|
||||
Thread.PrepareCallStackEntryList(AStackFrame + 1);
|
||||
Frame := Thread.CallStackEntryList[AStackFrame];
|
||||
if Frame = nil then
|
||||
exit;
|
||||
Addr := Frame.AnAddress;
|
||||
end;
|
||||
if Addr = 0 then
|
||||
exit;
|
||||
Result := FDbgInfo.FindContext(AThreadId, AStackFrame, Addr);
|
||||
// SymbolTableInfo.FindContext()
|
||||
end;
|
||||
|
||||
function TDbgProcess.FindContext(AAddress: TDbgPtr): TFpDbgInfoContext;
|
||||
begin
|
||||
Result := FDbgInfo.FindContext(AAddress);
|
||||
// SymbolTableInfo.FindContext()
|
||||
end;
|
||||
|
||||
function TDbgProcess.GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
|
||||
|
@ -478,7 +478,7 @@ type
|
||||
TODO: for now address may be needed, as stack decoding is not done yet
|
||||
*)
|
||||
function FindContext(AThreadId, AStackFrame: Integer; {%H-}AAddress: TDbgPtr = 0): TFpDbgInfoContext; virtual;
|
||||
function FindContext({%H-}AAddress: TDbgPtr): TFpDbgInfoContext; virtual; deprecated 'use FindContextFindContext(thread,stack,address)';
|
||||
function FindContext({%H-}AAddress: TDbgPtr): TFpDbgInfoContext; virtual; deprecated 'use FindContext(thread,stack,address)';
|
||||
function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; virtual; overload;
|
||||
function FindProcSymbol(const {%H-}AName: String): TFpSymbol; virtual; overload;
|
||||
property HasInfo: Boolean read FHasInfo;
|
||||
|
@ -627,8 +627,6 @@ var
|
||||
v, params: String;
|
||||
i: Integer;
|
||||
ProcVal, m: TFpValue;
|
||||
RegList: TDbgRegisterValueList;
|
||||
Reg: TDbgRegisterValue;
|
||||
AController: TDbgController;
|
||||
CurThreadId: Integer;
|
||||
AContext: TFpDbgInfoContext;
|
||||
@ -660,17 +658,9 @@ begin
|
||||
|
||||
params := '';
|
||||
if (ProcVal <> nil) then begin
|
||||
if e.Index = 0 then
|
||||
RegList := AController.CurrentThread.RegisterValueList
|
||||
else
|
||||
RegList := ThreadCallStack[e.Index].RegisterValueList;
|
||||
if AController.CurrentProcess.Mode=dm32 then
|
||||
Reg := RegList.FindRegisterByDwarfIndex(8)
|
||||
else
|
||||
Reg := RegList.FindRegisterByDwarfIndex(16);
|
||||
if Reg <> nil then begin
|
||||
AContext := AController.CurrentProcess.FindContext(CurThreadId, e.Index);
|
||||
if AContext <> nil then begin
|
||||
// TODO: TDbgCallstackEntry.GetParamsAsString
|
||||
AContext := AController.CurrentProcess.DbgInfo.FindContext(CurThreadId, e.Index, Reg.NumValue);
|
||||
if AContext <> nil then begin
|
||||
AContext.MemManager.DefaultContext := AContext;
|
||||
if ProcVal is TFpValueDwarfBase then
|
||||
@ -747,9 +737,6 @@ var
|
||||
m: TFpValue;
|
||||
n, v: String;
|
||||
CurThreadId, CurStackFrame: Integer;
|
||||
AFrame: TDbgCallstackEntry;
|
||||
RegList: TDbgRegisterValueList;
|
||||
Reg: TDbgRegisterValue;
|
||||
CurStackList: TCallStackBase;
|
||||
begin
|
||||
AController := FpDebugger.FDbgController;
|
||||
@ -767,27 +754,11 @@ begin
|
||||
else
|
||||
CurStackFrame := 0;
|
||||
|
||||
if CurStackFrame > 0 then
|
||||
begin
|
||||
TFpDebugDebugger(Debugger).PrepareCallStackEntryList(CurStackFrame);
|
||||
AFrame := AController.CurrentThread.CallStackEntryList[CurStackFrame];
|
||||
if AFrame = nil then
|
||||
begin
|
||||
ALocals.SetDataValidity(ddsInvalid);
|
||||
exit;
|
||||
end;
|
||||
RegList := AFrame.RegisterValueList;
|
||||
end
|
||||
else
|
||||
RegList := AController.CurrentThread.RegisterValueList;
|
||||
if AController.CurrentProcess.Mode=dm32 then
|
||||
Reg := RegList.FindRegisterByDwarfIndex(8)
|
||||
else
|
||||
Reg := RegList.FindRegisterByDwarfIndex(16);
|
||||
if Reg <> nil then
|
||||
AContext := AController.CurrentProcess.DbgInfo.FindContext(CurThreadId, CurStackFrame, Reg.NumValue)
|
||||
else
|
||||
AContext := nil;
|
||||
AContext := AController.CurrentProcess.FindContext(CurThreadId, CurStackFrame);
|
||||
if AContext = nil then begin
|
||||
ALocals.SetDataValidity(ddsInvalid);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if (AContext = nil) or (AContext.SymbolAtAddress = nil) then begin
|
||||
ALocals.SetDataValidity(ddsInvalid);
|
||||
@ -899,7 +870,7 @@ begin
|
||||
bpkSource: FInternalBreakpoint := TFpDebugDebugger(Debugger).AddBreak(Source, cardinal(Line));
|
||||
else
|
||||
Raise Exception.Create('Breakpoints of this kind are not suported.');
|
||||
end;
|
||||
end;
|
||||
debuglnExit(DBG_BREAKPOINTS, ['<< TFPBreakpoint.SetBreak ' ]);
|
||||
FIsSet:=true;
|
||||
if not assigned(FInternalBreakpoint) then
|
||||
@ -1383,8 +1354,11 @@ begin
|
||||
else begin
|
||||
ThreadId := Threads.CurrentThreads.CurrentThreadId;
|
||||
StackList := CallStack.CurrentCallStackList.EntriesForThreads[ThreadId];
|
||||
if StackList <> nil then
|
||||
StackFrame := CallStack.CurrentCallStackList.EntriesForThreads[ThreadId].CurrentIndex
|
||||
if StackList <> nil then begin
|
||||
StackFrame := CallStack.CurrentCallStackList.EntriesForThreads[ThreadId].CurrentIndex;
|
||||
if StackFrame < 0 then
|
||||
StackFrame := 0;
|
||||
end
|
||||
else
|
||||
StackFrame := 0;
|
||||
DispFormat := wdfDefault;
|
||||
@ -1587,40 +1561,10 @@ end;
|
||||
|
||||
function TFpDebugDebugger.GetContextForEvaluate(const ThreadId,
|
||||
StackFrame: Integer): TFpDbgInfoContext;
|
||||
var
|
||||
AController: TDbgController;
|
||||
ADbgInfo: TDbgInfo;
|
||||
Reg: TDbgRegisterValue;
|
||||
RegList: TDbgRegisterValueList;
|
||||
AFrame: TDbgCallstackEntry;
|
||||
begin
|
||||
Result := nil;
|
||||
AController := FDbgController;
|
||||
ADbgInfo := AController.CurrentProcess.DbgInfo;
|
||||
|
||||
if StackFrame > 0 then begin
|
||||
PrepareCallStackEntryList(StackFrame+1);
|
||||
if FDbgController.CurrentThread.CallStackEntryList.Count <= StackFrame then
|
||||
exit;
|
||||
AFrame := FDbgController.CurrentThread.CallStackEntryList[StackFrame];
|
||||
if AFrame = nil then
|
||||
exit;
|
||||
RegList := AFrame.RegisterValueList;
|
||||
end
|
||||
else
|
||||
RegList := AController.CurrentThread.RegisterValueList;
|
||||
|
||||
if AController.CurrentProcess.Mode = dm32 then
|
||||
Reg := RegList.FindRegisterByDwarfIndex(8)
|
||||
else
|
||||
Reg := RegList.FindRegisterByDwarfIndex(16);
|
||||
if Reg <> nil then begin
|
||||
Result := ADbgInfo.FindContext(ThreadId, StackFrame, Reg.NumValue);
|
||||
if Result <> nil then
|
||||
Result.MemManager.DefaultContext := Result;
|
||||
end
|
||||
else
|
||||
Result := nil;
|
||||
Result := FDbgController.CurrentProcess.FindContext(ThreadId, StackFrame);
|
||||
if Result <> nil then
|
||||
Result.MemManager.DefaultContext := Result;
|
||||
end;
|
||||
|
||||
function TFpDebugDebugger.GetClassInstanceName(AnAddr: TDBGPtr): string;
|
||||
|
Loading…
Reference in New Issue
Block a user