mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-04 18:17:13 +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,
|
||||
FpErrorMessages,
|
||||
FpImgReaderBase,
|
||||
FpDbgCpuX86;
|
||||
FpDbgCpuX86, LazDebuggerIntfFloatTypes;
|
||||
|
||||
type
|
||||
user_regs_struct64 = record
|
||||
@ -854,6 +854,7 @@ begin
|
||||
FRegisterValueList.DbgRegisterAutoCreate['gs'].SetValue(FUserRegs.regs64[gs], IntToStr(FUserRegs.regs64[gs]),8,47);
|
||||
|
||||
if FFpRegsAvail then begin
|
||||
DisableFloatExceptions;
|
||||
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['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);
|
||||
|
||||
EnableFloatExceptions;
|
||||
end;
|
||||
end;
|
||||
FRegisterValueListValid:=true;
|
||||
|
||||
@ -43,7 +43,7 @@ uses
|
||||
{$IFDEF WINDOWS} Windows, {$ENDIF}
|
||||
Classes, SysUtils, fgl, math, LazUTF8, lazCollections, UTF8Process,
|
||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
||||
DbgIntfDebuggerBase, FpdMemoryTools, LazDebuggerUtils, syncobjs;
|
||||
DbgIntfDebuggerBase, FpdMemoryTools, LazDebuggerUtils, LazDebuggerIntfFloatTypes, syncobjs;
|
||||
|
||||
type
|
||||
TFPDMode = (dm32, dm64);
|
||||
@ -470,6 +470,7 @@ end;
|
||||
|
||||
function XmmToString(const xmm: M128A): String;
|
||||
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]}', [
|
||||
FloatToStr(PDouble(@xmm+0)^), FloatToStr(PDouble(@xmm+8)^),
|
||||
|
||||
@ -495,10 +496,12 @@ begin
|
||||
IntToStr(PInt8(@xmm+12)^), IntToStr(PInt8(@xmm+13)^),
|
||||
IntToStr(PInt8(@xmm+14)^), IntToStr(PInt8(@xmm+15)^)
|
||||
]);
|
||||
EnableFloatExceptions;
|
||||
end;
|
||||
|
||||
function YmmToString(const Xmm, Ymm: M128A): String;
|
||||
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]}', [
|
||||
FloatToStr(PDouble(@xmm+0)^), FloatToStr(PDouble(@xmm+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+14)^), IntToStr(PInt8(@ymm+15)^)
|
||||
]);
|
||||
|
||||
EnableFloatExceptions;
|
||||
end;
|
||||
|
||||
function XmmToFormat(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat): String;
|
||||
|
||||
@ -125,7 +125,7 @@ uses
|
||||
FpDbgLoader, FpDbgDisasX86,
|
||||
DbgIntfBaseTypes, DbgIntfDebuggerBase,
|
||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}, UTF8Process,
|
||||
FpDbgCommon, FpdMemoryTools, FpErrorMessages, FpDbgCpuX86;
|
||||
FpDbgCommon, FpdMemoryTools, FpErrorMessages, FpDbgCpuX86, LazDebuggerIntfFloatTypes;
|
||||
|
||||
type
|
||||
|
||||
@ -1790,7 +1790,6 @@ var
|
||||
Xmm, Ymm: PM128A;
|
||||
FeatureLength, FeatureLength2: DWORD;
|
||||
i: Integer;
|
||||
EM, SEM: TFPUExceptionMask;
|
||||
r: TDbgRegisterValue;
|
||||
begin
|
||||
{$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadId('TDbgWinThread.LoadRegisterValues');{$ENDIF}
|
||||
@ -1800,15 +1799,8 @@ begin
|
||||
if not ReadThreadState then
|
||||
exit;
|
||||
|
||||
EM := GetExceptionMask;
|
||||
{$IF FPC_Fullversion>30202}{$ifNdef cpui386}
|
||||
SEM := softfloat_exception_mask;
|
||||
{$endif}{$ENDIF}
|
||||
DisableFloatExceptions;
|
||||
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}
|
||||
with FCurrentContext^.def do
|
||||
@ -2051,10 +2043,7 @@ begin
|
||||
|
||||
finally
|
||||
FRegisterValueListValid:=true;
|
||||
SetExceptionMask(EM);
|
||||
{$IF FPC_Fullversion>30202}{$ifNdef cpui386}
|
||||
softfloat_exception_mask := SEM;
|
||||
{$endif}{$ENDIF}
|
||||
EnableFloatExceptions;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ uses
|
||||
FpdMemoryTools, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarf,
|
||||
FpDbgClasses,
|
||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
||||
LazUTF8, LazClasses;
|
||||
LazUTF8, LazClasses, LazDebuggerIntfFloatTypes;
|
||||
|
||||
type
|
||||
|
||||
@ -1060,7 +1060,9 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
|
||||
|
||||
procedure DoFloat;
|
||||
begin
|
||||
DisableFloatExceptions;
|
||||
APrintedValue := FloatToStr(AValue.AsFloat);
|
||||
EnableFloatExceptions;
|
||||
if (ppvCreateDbgType in AFlags) then begin
|
||||
ADBGTypeInfo^ := TDBGType.Create(skSimple, ResTypeName);
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user