FpDebug: prevent div-by-zero in the debugger (in the IDE) while evaluating watches.

This commit is contained in:
Martin 2023-12-30 20:04:08 +01:00
parent 5c6662f3e7
commit 5a1d892e69

View File

@ -28,6 +28,7 @@ unit FpPascalParser;
{$IFDEF INLINE_OFF}{$INLINE OFF}{$ENDIF} {$IFDEF INLINE_OFF}{$INLINE OFF}{$ENDIF}
{$IF FPC_Fullversion=30202}{$Optimization NOPEEPHOLE}{$ENDIF} {$IF FPC_Fullversion=30202}{$Optimization NOPEEPHOLE}{$ENDIF}
{$TYPEDADDRESS on} {$TYPEDADDRESS on}
{$SafeFPUExceptions off}
interface interface
@ -79,6 +80,7 @@ type
FTextExpression: String; FTextExpression: String;
FExpressionPart: TFpPascalExpressionPart; FExpressionPart: TFpPascalExpressionPart;
FValid: Boolean; FValid: Boolean;
FFpuMask: TFPUExceptionMask;
function GetResultValue: TFpValue; function GetResultValue: TFpValue;
function GetValid: Boolean; function GetValid: Boolean;
procedure SetError(AMsg: String); // deprecated; procedure SetError(AMsg: String); // deprecated;
@ -3197,6 +3199,8 @@ end;
constructor TFpPascalExpression.Create(ATextExpression: String; constructor TFpPascalExpression.Create(ATextExpression: String;
AContext: TFpDbgSymbolScope; ASkipParse: Boolean); AContext: TFpDbgSymbolScope; ASkipParse: Boolean);
begin begin
FFpuMask := GetExceptionMask;
SetExceptionMask([low(TFPUExceptionMask)..high(TFPUExceptionMask)]);
FContext := AContext; FContext := AContext;
FContext.AddReference; FContext.AddReference;
FTextExpression := ATextExpression; FTextExpression := ATextExpression;
@ -3211,6 +3215,8 @@ begin
FreeAndNil(FExpressionPart); FreeAndNil(FExpressionPart);
FContext.ReleaseReference; FContext.ReleaseReference;
inherited Destroy; inherited Destroy;
ClearExceptions(False);
SetExceptionMask(FFpuMask);
end; end;
function TFpPascalExpression.DebugDump(AWithResults: Boolean): String; function TFpPascalExpression.DebugDump(AWithResults: Boolean): String;