mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 10:07:19 +01:00
FpDebug: fix uncaught floating point exception. Issue #41816
(cherry picked from commit 19bad7521b)
This commit is contained in:
parent
40ab8eea52
commit
c1afe07a35
@ -27,7 +27,7 @@ uses
|
|||||||
FpDbgCommon, FpdMemoryTools,
|
FpDbgCommon, FpdMemoryTools,
|
||||||
FpErrorMessages,
|
FpErrorMessages,
|
||||||
FpImgReaderBase,
|
FpImgReaderBase,
|
||||||
FpDbgCpuX86;
|
FpDbgCpuX86, LazDebuggerIntfFloatTypes;
|
||||||
|
|
||||||
type
|
type
|
||||||
user_regs_struct64 = record
|
user_regs_struct64 = record
|
||||||
@ -854,6 +854,7 @@ begin
|
|||||||
FRegisterValueList.DbgRegisterAutoCreate['gs'].SetValue(FUserRegs.regs64[gs], IntToStr(FUserRegs.regs64[gs]),8,47);
|
FRegisterValueList.DbgRegisterAutoCreate['gs'].SetValue(FUserRegs.regs64[gs], IntToStr(FUserRegs.regs64[gs]),8,47);
|
||||||
|
|
||||||
if FFpRegsAvail then begin
|
if FFpRegsAvail then begin
|
||||||
|
DisableFloatExceptions;
|
||||||
FRegisterValueList.DbgRegisterAutoCreate['st0'].SetValue(0, FloatToStr(PExtended(@FFpRegs.st_space[ 0*4])^),10,500);
|
FRegisterValueList.DbgRegisterAutoCreate['st0'].SetValue(0, FloatToStr(PExtended(@FFpRegs.st_space[ 0*4])^),10,500);
|
||||||
FRegisterValueList.DbgRegisterAutoCreate['st1'].SetValue(0, FloatToStr(PExtended(@FFpRegs.st_space[ 1*4])^),10,501);
|
FRegisterValueList.DbgRegisterAutoCreate['st1'].SetValue(0, FloatToStr(PExtended(@FFpRegs.st_space[ 1*4])^),10,501);
|
||||||
FRegisterValueList.DbgRegisterAutoCreate['st2'].SetValue(0, FloatToStr(PExtended(@FFpRegs.st_space[ 2*4])^),10,502);
|
FRegisterValueList.DbgRegisterAutoCreate['st2'].SetValue(0, FloatToStr(PExtended(@FFpRegs.st_space[ 2*4])^),10,502);
|
||||||
@ -883,6 +884,7 @@ begin
|
|||||||
|
|
||||||
FRegisterValueList.DbgRegisterAutoCreate['mxcsr'].SetValue(FFpRegs.fos, IntToStr(FFpRegs.mxcsr),4,620);
|
FRegisterValueList.DbgRegisterAutoCreate['mxcsr'].SetValue(FFpRegs.fos, IntToStr(FFpRegs.mxcsr),4,620);
|
||||||
|
|
||||||
|
EnableFloatExceptions;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
FRegisterValueListValid:=true;
|
FRegisterValueListValid:=true;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ uses
|
|||||||
{$IFDEF WINDOWS} Windows, {$ENDIF}
|
{$IFDEF WINDOWS} Windows, {$ENDIF}
|
||||||
Classes, SysUtils, fgl, math, LazUTF8, lazCollections, UTF8Process,
|
Classes, SysUtils, fgl, math, LazUTF8, lazCollections, UTF8Process,
|
||||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
||||||
DbgIntfDebuggerBase, FpdMemoryTools, LazDebuggerUtils, syncobjs;
|
DbgIntfDebuggerBase, FpdMemoryTools, LazDebuggerUtils, LazDebuggerIntfFloatTypes, syncobjs;
|
||||||
|
|
||||||
type
|
type
|
||||||
TFPDMode = (dm32, dm64);
|
TFPDMode = (dm32, dm64);
|
||||||
@ -470,6 +470,7 @@ end;
|
|||||||
|
|
||||||
function XmmToString(const xmm: M128A): String;
|
function XmmToString(const xmm: M128A): String;
|
||||||
begin
|
begin
|
||||||
|
DisableFloatExceptions;
|
||||||
Result := format('{"D": [%s, %s], "S": [%s, %s, %s, %s], "I64": [%s, %s], "I32": [%s, %s, %s, %s], "I16": [%s, %s, %s, %s, %s, %s, %s, %s], "I8": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s]}', [
|
Result := format('{"D": [%s, %s], "S": [%s, %s, %s, %s], "I64": [%s, %s], "I32": [%s, %s, %s, %s], "I16": [%s, %s, %s, %s, %s, %s, %s, %s], "I8": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s]}', [
|
||||||
FloatToStr(PDouble(@xmm+0)^), FloatToStr(PDouble(@xmm+8)^),
|
FloatToStr(PDouble(@xmm+0)^), FloatToStr(PDouble(@xmm+8)^),
|
||||||
|
|
||||||
@ -495,10 +496,12 @@ begin
|
|||||||
IntToStr(PInt8(@xmm+12)^), IntToStr(PInt8(@xmm+13)^),
|
IntToStr(PInt8(@xmm+12)^), IntToStr(PInt8(@xmm+13)^),
|
||||||
IntToStr(PInt8(@xmm+14)^), IntToStr(PInt8(@xmm+15)^)
|
IntToStr(PInt8(@xmm+14)^), IntToStr(PInt8(@xmm+15)^)
|
||||||
]);
|
]);
|
||||||
|
EnableFloatExceptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function YmmToString(const Xmm, Ymm: M128A): String;
|
function YmmToString(const Xmm, Ymm: M128A): String;
|
||||||
begin
|
begin
|
||||||
|
DisableFloatExceptions;
|
||||||
Result := format('{"D": [%s, %s, %s, %s], "S": [%s, %s, %s, %s, %s, %s, %s, %s], "I64": [%s, %s, %s, %s], "I32": [%s, %s, %s, %s, %s, %s, %s, %s], "I16": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s], "I8": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s]}', [
|
Result := format('{"D": [%s, %s, %s, %s], "S": [%s, %s, %s, %s, %s, %s, %s, %s], "I64": [%s, %s, %s, %s], "I32": [%s, %s, %s, %s, %s, %s, %s, %s], "I16": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s], "I8": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s]}', [
|
||||||
FloatToStr(PDouble(@xmm+0)^), FloatToStr(PDouble(@xmm+8)^),
|
FloatToStr(PDouble(@xmm+0)^), FloatToStr(PDouble(@xmm+8)^),
|
||||||
FloatToStr(PDouble(@ymm+0)^), FloatToStr(PDouble(@ymm+8)^),
|
FloatToStr(PDouble(@ymm+0)^), FloatToStr(PDouble(@ymm+8)^),
|
||||||
@ -542,7 +545,7 @@ begin
|
|||||||
IntToStr(PInt8(@ymm+12)^), IntToStr(PInt8(@ymm+13)^),
|
IntToStr(PInt8(@ymm+12)^), IntToStr(PInt8(@ymm+13)^),
|
||||||
IntToStr(PInt8(@ymm+14)^), IntToStr(PInt8(@ymm+15)^)
|
IntToStr(PInt8(@ymm+14)^), IntToStr(PInt8(@ymm+15)^)
|
||||||
]);
|
]);
|
||||||
|
EnableFloatExceptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function XmmToFormat(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat): String;
|
function XmmToFormat(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat): String;
|
||||||
|
|||||||
@ -125,7 +125,7 @@ uses
|
|||||||
FpDbgLoader, FpDbgDisasX86,
|
FpDbgLoader, FpDbgDisasX86,
|
||||||
DbgIntfBaseTypes, DbgIntfDebuggerBase,
|
DbgIntfBaseTypes, DbgIntfDebuggerBase,
|
||||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}, UTF8Process,
|
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}, UTF8Process,
|
||||||
FpDbgCommon, FpdMemoryTools, FpErrorMessages, FpDbgCpuX86;
|
FpDbgCommon, FpdMemoryTools, FpErrorMessages, FpDbgCpuX86, LazDebuggerIntfFloatTypes;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -1790,7 +1790,6 @@ var
|
|||||||
Xmm, Ymm: PM128A;
|
Xmm, Ymm: PM128A;
|
||||||
FeatureLength, FeatureLength2: DWORD;
|
FeatureLength, FeatureLength2: DWORD;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
EM, SEM: TFPUExceptionMask;
|
|
||||||
r: TDbgRegisterValue;
|
r: TDbgRegisterValue;
|
||||||
begin
|
begin
|
||||||
{$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadId('TDbgWinThread.LoadRegisterValues');{$ENDIF}
|
{$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadId('TDbgWinThread.LoadRegisterValues');{$ENDIF}
|
||||||
@ -1800,15 +1799,8 @@ begin
|
|||||||
if not ReadThreadState then
|
if not ReadThreadState then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
EM := GetExceptionMask;
|
DisableFloatExceptions;
|
||||||
{$IF FPC_Fullversion>30202}{$ifNdef cpui386}
|
|
||||||
SEM := softfloat_exception_mask;
|
|
||||||
{$endif}{$ENDIF}
|
|
||||||
try
|
try
|
||||||
SetExceptionMask(EM + [exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
|
|
||||||
{$IF FPC_Fullversion>30202}{$ifNdef cpui386}
|
|
||||||
softfloat_exception_mask := SEM + [exInvalidOp, exDenormalized, exZeroDivide,exOverflow, exUnderflow, exPrecision];
|
|
||||||
{$endif}{$ENDIF}
|
|
||||||
|
|
||||||
{$ifdef cpui386}
|
{$ifdef cpui386}
|
||||||
with FCurrentContext^.def do
|
with FCurrentContext^.def do
|
||||||
@ -2051,10 +2043,7 @@ begin
|
|||||||
|
|
||||||
finally
|
finally
|
||||||
FRegisterValueListValid:=true;
|
FRegisterValueListValid:=true;
|
||||||
SetExceptionMask(EM);
|
EnableFloatExceptions;
|
||||||
{$IF FPC_Fullversion>30202}{$ifNdef cpui386}
|
|
||||||
softfloat_exception_mask := SEM;
|
|
||||||
{$endif}{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ uses
|
|||||||
FpdMemoryTools, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarf,
|
FpdMemoryTools, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarf,
|
||||||
FpDbgClasses,
|
FpDbgClasses,
|
||||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
||||||
LazUTF8, LazClasses;
|
LazUTF8, LazClasses, LazDebuggerIntfFloatTypes;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -1060,7 +1060,9 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
|
|||||||
|
|
||||||
procedure DoFloat;
|
procedure DoFloat;
|
||||||
begin
|
begin
|
||||||
|
DisableFloatExceptions;
|
||||||
APrintedValue := FloatToStr(AValue.AsFloat);
|
APrintedValue := FloatToStr(AValue.AsFloat);
|
||||||
|
EnableFloatExceptions;
|
||||||
if (ppvCreateDbgType in AFlags) then begin
|
if (ppvCreateDbgType in AFlags) then begin
|
||||||
ADBGTypeInfo^ := TDBGType.Create(skSimple, ResTypeName);
|
ADBGTypeInfo^ := TDBGType.Create(skSimple, ResTypeName);
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user