From 5a1d892e6924b714e6844d69c3bfa31bc389e1cd Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 30 Dec 2023 20:04:08 +0100 Subject: [PATCH] FpDebug: prevent div-by-zero in the debugger (in the IDE) while evaluating watches. --- components/fpdebug/fppascalparser.pas | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/fpdebug/fppascalparser.pas b/components/fpdebug/fppascalparser.pas index 0ff8c42080..24bdc26fe3 100644 --- a/components/fpdebug/fppascalparser.pas +++ b/components/fpdebug/fppascalparser.pas @@ -28,6 +28,7 @@ unit FpPascalParser; {$IFDEF INLINE_OFF}{$INLINE OFF}{$ENDIF} {$IF FPC_Fullversion=30202}{$Optimization NOPEEPHOLE}{$ENDIF} {$TYPEDADDRESS on} +{$SafeFPUExceptions off} interface @@ -79,6 +80,7 @@ type FTextExpression: String; FExpressionPart: TFpPascalExpressionPart; FValid: Boolean; + FFpuMask: TFPUExceptionMask; function GetResultValue: TFpValue; function GetValid: Boolean; procedure SetError(AMsg: String); // deprecated; @@ -3197,6 +3199,8 @@ end; constructor TFpPascalExpression.Create(ATextExpression: String; AContext: TFpDbgSymbolScope; ASkipParse: Boolean); begin + FFpuMask := GetExceptionMask; + SetExceptionMask([low(TFPUExceptionMask)..high(TFPUExceptionMask)]); FContext := AContext; FContext.AddReference; FTextExpression := ATextExpression; @@ -3211,6 +3215,8 @@ begin FreeAndNil(FExpressionPart); FContext.ReleaseReference; inherited Destroy; + ClearExceptions(False); + SetExceptionMask(FFpuMask); end; function TFpPascalExpression.DebugDump(AWithResults: Boolean): String;