FpDebug: Fix crash on hitting just deleted breakpoint (race condition leads to nil object access)

git-svn-id: trunk@62005 -
This commit is contained in:
martin 2019-10-06 22:00:31 +00:00
parent 71fc709658
commit f6616221d8

View File

@ -1736,42 +1736,44 @@ begin
else else
begin begin
ABreakPoint := TFPBreakpoints(BreakPoints).Find(Breakpoint); ABreakPoint := TFPBreakpoints(BreakPoints).Find(Breakpoint);
if ABreakPoint <> nil then begin
// TODO: parse expression when breakpoin is created / so invalid expressions do not need to be handled here // TODO: parse expression when breakpoin is created / so invalid expressions do not need to be handled here
if ABreakPoint.Expression <> '' then begin if ABreakPoint.Expression <> '' then begin
Context := GetContextForEvaluate(FDbgController.CurrentThreadId, 0); Context := GetContextForEvaluate(FDbgController.CurrentThreadId, 0);
if Context <> nil then begin if Context <> nil then begin
PasExpr := nil; PasExpr := nil;
try try
PasExpr := TFpPascalExpression.Create(ABreakPoint.Expression, Context); PasExpr := TFpPascalExpression.Create(ABreakPoint.Expression, Context);
PasExpr.ResultValue; // trigger full validation PasExpr.ResultValue; // trigger full validation
if PasExpr.Valid and (svfBoolean in PasExpr.ResultValue.FieldFlags) and if PasExpr.Valid and (svfBoolean in PasExpr.ResultValue.FieldFlags) and
(not PasExpr.ResultValue.AsBool) // false => do not pause (not PasExpr.ResultValue.AsBool) // false => do not pause
then then
&continue := True; &continue := True;
finally finally
PasExpr.Free; PasExpr.Free;
Context.ReleaseReference; Context.ReleaseReference;
end;
if &continue then
exit;
end; end;
if &continue then
exit;
end; end;
end;
ALocationAddr := GetLocation; ALocationAddr := GetLocation;
if Assigned(EventLogHandler) then if Assigned(EventLogHandler) then
EventLogHandler.LogEventBreakPointHit(ABreakpoint, ALocationAddr); EventLogHandler.LogEventBreakPointHit(ABreakpoint, ALocationAddr);
if assigned(ABreakPoint) then if assigned(ABreakPoint) then
ABreakPoint.Hit(&continue); ABreakPoint.Hit(&continue);
if (not &continue) and (ABreakPoint.Kind = bpkData) and (OnFeedback <> nil) then begin if (not &continue) and (ABreakPoint.Kind = bpkData) and (OnFeedback <> nil) then begin
// For message use location(Address - 1) // For message use location(Address - 1)
OnFeedback(self, OnFeedback(self,
Format('The Watchpoint for "%1:s" was triggered.%0:s%0:s', // 'Old value: %2:s%0:sNew value: %3:s', Format('The Watchpoint for "%1:s" was triggered.%0:s%0:s', // 'Old value: %2:s%0:sNew value: %3:s',
[LineEnding, ABreakPoint.WatchData{, AOldVal, ANewVal}]), [LineEnding, ABreakPoint.WatchData{, AOldVal, ANewVal}]),
'', ftInformation, [frOk]); '', ftInformation, [frOk]);
end;
end; end;
end; end;
end end