diff --git a/components/fpdebug/fpdbgclasses.pp b/components/fpdebug/fpdbgclasses.pp index ee50b07e43..00f3afa27b 100644 --- a/components/fpdebug/fpdbgclasses.pp +++ b/components/fpdebug/fpdbgclasses.pp @@ -259,6 +259,7 @@ type property ProcessID: integer read FProcessID; property ThreadID: integer read FThreadID; property ExitCode: DWord read FExitCode; + property CurrentBreakpoint: TDbgBreakpoint read FCurrentBreakpoint; property LastEventProcessIdentifier: THandle read GetLastEventProcessIdentifier; property OnLog: TOnLog read FOnLog write FOnLog; property MainThread: TDbgThread read FMainThread; diff --git a/components/fpdebug/fpdbgcontroller.pas b/components/fpdebug/fpdbgcontroller.pas index 5f14c00188..f94bcaa4ec 100644 --- a/components/fpdebug/fpdbgcontroller.pas +++ b/components/fpdebug/fpdbgcontroller.pas @@ -15,7 +15,7 @@ uses type TOnCreateProcessEvent = procedure(var continue: boolean) of object; - TOnHitBreakpointEvent = procedure(var continue: boolean) of object; + TOnHitBreakpointEvent = procedure(var continue: boolean; const Breakpoint: TDbgBreakpoint) of object; TOnExceptionEvent = procedure(var continue: boolean) of object; TOnProcessExitEvent = procedure(ExitCode: DWord) of object; @@ -246,7 +246,7 @@ begin debugln('Breakpoint'); continue:=false; if assigned(OnHitBreakpointEvent) then - OnHitBreakpointEvent(continue); + OnHitBreakpointEvent(continue, FCurrentProcess.CurrentBreakpoint); end; deExitProcess: begin diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas index 98c62d9a63..3a8d15b572 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas @@ -45,7 +45,7 @@ type FDbgController: TDbgController; FFpDebugThread: TFpDebugThread; procedure FreeDebugThread; - procedure FDbgControllerHitBreakpointEvent(var continue: boolean); + procedure FDbgControllerHitBreakpointEvent(var continue: boolean; const Breakpoint: FpDbgClasses.TDbgBreakpoint); procedure FDbgControllerCreateProcessEvent(var continue: boolean); procedure FDbgControllerProcessExitEvent(AExitCode: DWord); procedure FDbgControllerExceptionEvent(var continue: boolean); @@ -141,6 +141,13 @@ type public end; + { TFPBreakpoints } + + TFPBreakpoints = class(TDBGBreakPoints) + public + function Find(AIntBReakpoint: FpDbgClasses.TDbgBreakpoint): TDBGBreakPoint; + end; + procedure Register; implementation @@ -154,6 +161,21 @@ begin RegisterDebugger(TFpDebugDebugger); end; +{ TFPBreakpoints } + +function TFPBreakpoints.Find(AIntBReakpoint: FpDbgClasses.TDbgBreakpoint): TDBGBreakPoint; +var + i: integer; +begin + for i := 0 to count-1 do + if TFPBreakpoint(Items[i]).FInternalBreakpoint=AIntBReakpoint then + begin + result := TFPBreakpoint(Items[i]); + Exit; + end; + result := nil; +end; + { TFPBreakpoint } procedure TFPBreakpoint.SetBreak; @@ -173,8 +195,13 @@ end; procedure TFPBreakpoint.ResetBreak; begin - TFpDebugDebugger(Debugger).FDbgController.CurrentProcess.RemoveBreak(FInternalBreakpoint.Location); - FreeAndNil(FInternalBreakpoint); + // If Debugger is not assigned, the Controller's currentprocess is already + // freed. And so are the corresponding InternalBreakpoint's. + if assigned(Debugger) and assigned(FInternalBreakpoint) then + begin + TFpDebugDebugger(Debugger).FDbgController.CurrentProcess.RemoveBreak(FInternalBreakpoint.Location); + FreeAndNil(FInternalBreakpoint); + end; end; destructor TFPBreakpoint.Destroy; @@ -582,7 +609,7 @@ end; function TFpDebugDebugger.CreateBreakPoints: TDBGBreakPoints; begin - Result := TDBGBreakPoints.Create(Self, TFPBreakpoint); + Result := TFPBreakPoints.Create(Self, TFPBreakpoint); end; procedure TFpDebugDebugger.FDbgControllerDebugInfoLoaded(Sender: TObject); @@ -603,9 +630,13 @@ begin FFpDebugThread := nil; end; -procedure TFpDebugDebugger.FDbgControllerHitBreakpointEvent(var continue: boolean); +procedure TFpDebugDebugger.FDbgControllerHitBreakpointEvent(var continue: boolean; const Breakpoint: FpDbgClasses.TDbgBreakpoint); +var + ABreakPoint: TDBGBreakPoint; begin - BreakPoints[0].Hit(continue); + ABreakPoint := TFPBreakpoints(BreakPoints).Find(Breakpoint); + if assigned(ABreakPoint) then + ABreakPoint.Hit(continue); SetState(dsPause); DoCurrent(GetLocation); end;