mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 10:36:01 +02:00
FpDebug: improve stack unwinding by disassembler, add checks if NewFrame is valid/known
This commit is contained in:
parent
c4ab5aa2cf
commit
cee3781c3c
@ -5457,8 +5457,10 @@ var
|
|||||||
if (Oper.ByteCount = 0)
|
if (Oper.ByteCount = 0)
|
||||||
then begin
|
then begin
|
||||||
if IsLea then exit(False);
|
if IsLea then exit(False);
|
||||||
if (IsRegister(Oper.Value, 'bp')) then
|
if (IsRegister(Oper.Value, 'bp')) then begin
|
||||||
AVal := NewFrame
|
if NewFrame = 0 then exit(False);
|
||||||
|
AVal := NewFrame;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if (IsRegister(Oper.Value, 'sp')) then
|
if (IsRegister(Oper.Value, 'sp')) then
|
||||||
AVal := NewStack
|
AVal := NewStack
|
||||||
@ -5481,15 +5483,18 @@ var
|
|||||||
if IsLea and not (ofMemory in Oper.Flags) then exit(False);
|
if IsLea and not (ofMemory in Oper.Flags) then exit(False);
|
||||||
OpVal := ValueFromMem(CurAddr[Oper.CodeIndex], Oper.ByteCount, Oper.FormatFlags);
|
OpVal := ValueFromMem(CurAddr[Oper.CodeIndex], Oper.ByteCount, Oper.FormatFlags);
|
||||||
|
|
||||||
if (IsRegister(Oper.Value, 'bp%s')) then
|
if (IsRegister(Oper.Value, 'bp%s')) then begin
|
||||||
|
if NewFrame = 0 then exit(False);
|
||||||
{$PUSH}{$R-}{$Q-}
|
{$PUSH}{$R-}{$Q-}
|
||||||
AVal := NewFrame + OpVal
|
AVal := NewFrame + OpVal;
|
||||||
{$POP}
|
{$POP}
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if (IsRegister(Oper.Value, 'sp%s')) then
|
if (IsRegister(Oper.Value, 'sp%s')) then begin
|
||||||
{$PUSH}{$R-}{$Q-}
|
{$PUSH}{$R-}{$Q-}
|
||||||
AVal := NewStack + OpVal
|
AVal := NewStack + OpVal;
|
||||||
{$POP}
|
{$POP}
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if (Oper.Value = '%s') and (not(ofMemory in Oper.Flags))
|
if (Oper.Value = '%s') and (not(ofMemory in Oper.Flags))
|
||||||
then begin
|
then begin
|
||||||
@ -5672,7 +5677,7 @@ begin
|
|||||||
while (Cnt > 0) do begin
|
while (Cnt > 0) do begin
|
||||||
if ClearRecValList then ARegisterValueList.Clear;
|
if ClearRecValList then ARegisterValueList.Clear;
|
||||||
|
|
||||||
if ForceDifferentBranch or (NewAddr >= MaxAddr) or( NewAddr > MaxAddrCurrentBlock) then begin
|
if ForceDifferentBranch or (NewStack = 0) or (NewAddr >= MaxAddr) or( NewAddr > MaxAddrCurrentBlock) then begin
|
||||||
CheckConditionalForwAddr;
|
CheckConditionalForwAddr;
|
||||||
FinishCurAddrBlock;
|
FinishCurAddrBlock;
|
||||||
while (CurConditionalForwardAddr >= 0) and
|
while (CurConditionalForwardAddr >= 0) and
|
||||||
@ -5888,7 +5893,8 @@ begin
|
|||||||
else
|
else
|
||||||
if (IsRegister(instr.X86Instruction.Operand[2].Value, 'bp%s')) then begin
|
if (IsRegister(instr.X86Instruction.Operand[2].Value, 'bp%s')) then begin
|
||||||
{$PUSH}{$R-}{$Q-}
|
{$PUSH}{$R-}{$Q-}
|
||||||
NewFrame := NewFrame + Val;
|
if NewFrame <> 0 then
|
||||||
|
NewFrame := NewFrame + Val;
|
||||||
{$POP}
|
{$POP}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -5916,7 +5922,10 @@ begin
|
|||||||
else
|
else
|
||||||
if (IsRegister(instr.X86Instruction.Operand[2].Value, 'bp%s')) then begin
|
if (IsRegister(instr.X86Instruction.Operand[2].Value, 'bp%s')) then begin
|
||||||
{$PUSH}{$R-}{$Q-}
|
{$PUSH}{$R-}{$Q-}
|
||||||
NewStack := NewFrame + Val;
|
if NewFrame <> 0 then
|
||||||
|
NewStack := NewFrame + Val
|
||||||
|
else
|
||||||
|
NewStack := 0;
|
||||||
{$POP}
|
{$POP}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -5973,7 +5982,8 @@ begin
|
|||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
{$PUSH}{$R-}{$Q-}
|
{$PUSH}{$R-}{$Q-}
|
||||||
NewFrame := NewFrame + int64(Tmp);
|
if NewFrame <> 0 then
|
||||||
|
NewFrame := NewFrame + int64(Tmp);
|
||||||
{$POP}
|
{$POP}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -6005,7 +6015,8 @@ begin
|
|||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
{$PUSH}{$R-}{$Q-}
|
{$PUSH}{$R-}{$Q-}
|
||||||
NewFrame := NewFrame - int64(Tmp);
|
if NewFrame <> 0 then
|
||||||
|
NewFrame := NewFrame - int64(Tmp);
|
||||||
{$POP}
|
{$POP}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user