From fc35f675bc871abfd182faee82d27e2956e0bec8 Mon Sep 17 00:00:00 2001 From: joost Date: Sun, 20 Apr 2014 19:39:35 +0000 Subject: [PATCH] LazDebuggerFp (pure): Resolved problems with freeing breakpoints after the debuggee has ended. git-svn-id: trunk@44771 - --- components/fpdebug/fpdbgclasses.pp | 20 +++++++++++++++++++ components/fpdebug/fpdbgwinclasses.pas | 1 + .../lazdebuggerfp/fpdebugdebugger.pas | 9 +++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/components/fpdebug/fpdbgclasses.pp b/components/fpdebug/fpdbgclasses.pp index 45b3b225e7..9e138cb89e 100644 --- a/components/fpdebug/fpdbgclasses.pp +++ b/components/fpdebug/fpdbgclasses.pp @@ -557,7 +557,23 @@ begin end; destructor TDbgProcess.Destroy; +var + Bp: TDbgBreakpoint; + Iterator: TMapIterator; begin + iterator := TMapIterator.Create(FBreakMap); + try + Iterator.First; + while not Iterator.EOM do + begin + Iterator.GetData(bp); + Bp.Free; + iterator.Next; + end; + finally + Iterator.Free; + end; + FreeAndNil(FBreakMap); FreeAndNil(FThreadMap); FreeAndNil(FLibMap); @@ -917,6 +933,10 @@ end; procedure TDbgBreakpoint.ResetBreak; begin + if FProcess.Handle=0 then + // The process is already exited. + Exit; + if FOrgValue = $CC then Exit; // breakpoint on a hardcoded breakpoint if not FProcess.WriteData(FLocation, 1, FOrgValue) diff --git a/components/fpdebug/fpdbgwinclasses.pas b/components/fpdebug/fpdbgwinclasses.pas index 67ae41b8f3..8e01654219 100644 --- a/components/fpdebug/fpdbgwinclasses.pas +++ b/components/fpdebug/fpdbgwinclasses.pas @@ -225,6 +225,7 @@ end; destructor TDbgWinProcess.Destroy; begin CloseHandle(FInfo.hProcess); + FInfo.hProcess:=0; inherited Destroy; end; diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas index c1f53712ee..8d554cef2c 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas @@ -205,8 +205,8 @@ begin begin TFpDebugDebugger(Debugger).FDbgController.CurrentProcess.RemoveBreak(FInternalBreakpoint.Location); FreeAndNil(FInternalBreakpoint); - FIsSet:=false; end; + FIsSet:=false; end; destructor TFPBreakpoint.Destroy; @@ -229,6 +229,11 @@ begin FResetBreakFlag:=true; Changed; end; + end + else if Debugger.State = dsStop then + begin + FInternalBreakpoint := nil; + FIsSet:=false; end; inherited DoStateChange(AOldState); end; @@ -579,8 +584,8 @@ begin {$PUSH}{$R-} DoDbgEvent(ecProcess, etProcessExit, Format('Process exited with exit-code %d',[AExitCode])); {$POP} - FreeDebugThread; SetState(dsStop); + FreeDebugThread; end; procedure TFpDebugDebugger.FDbgControllerExceptionEvent(var continue: boolean);