FpDebug: Fix context for register on higher/non-existing stack frames (count vs index) / refactor

git-svn-id: trunk@60358 -
This commit is contained in:
martin 2019-02-07 17:40:20 +00:00
parent 616069b6b2
commit 2fe7c631b4

View File

@ -847,20 +847,28 @@ var
ARegister: TDbgRegisterValue; ARegister: TDbgRegisterValue;
StackFrame: Integer; StackFrame: Integer;
AFrame: TDbgCallstackEntry; AFrame: TDbgCallstackEntry;
CtxThread: TDbgThread;
begin begin
// TODO: Thread with ID // TODO: Thread with ID
if AContext <> nil then result := false;
CtxThread := GetDbgThread(AContext);
if CtxThread = nil then
exit;
if AContext <> nil then // TODO: Always true?
StackFrame := AContext.StackFrame StackFrame := AContext.StackFrame
else else
StackFrame := 0; StackFrame := 0;
if StackFrame = 0 then if StackFrame = 0 then
begin begin
ARegister:=GetDbgThread(AContext).RegisterValueList.FindRegisterByDwarfIndex(ARegNum); ARegister:=CtxThread.RegisterValueList.FindRegisterByDwarfIndex(ARegNum);
end end
else else
begin begin
GetDbgThread(AContext).PrepareCallStackEntryList(StackFrame); CtxThread.PrepareCallStackEntryList(StackFrame+1);
AFrame := GetDbgThread(AContext).CallStackEntryList[StackFrame]; if CtxThread.CallStackEntryList.Count <= StackFrame then
exit;
AFrame := CtxThread.CallStackEntryList[StackFrame];
if AFrame <> nil then if AFrame <> nil then
ARegister:=AFrame.RegisterValueList.FindRegisterByDwarfIndex(ARegNum) ARegister:=AFrame.RegisterValueList.FindRegisterByDwarfIndex(ARegNum)
else else
@ -870,9 +878,7 @@ begin
begin begin
AValue := ARegister.NumValue; AValue := ARegister.NumValue;
result := true; result := true;
end end;
else
result := false;
end; end;
function TDbgMemReader.RegisterSize(ARegNum: Cardinal): Integer; function TDbgMemReader.RegisterSize(ARegNum: Cardinal): Integer;