mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 11:19:22 +02:00
FpDebug: fix mem leak. Libraries were not freed on Unload.
This commit is contained in:
parent
1b1dd8f5fa
commit
07e3817870
@ -671,6 +671,7 @@ type
|
||||
function GetConsoleOutput: string; virtual;
|
||||
procedure SendConsoleInput(AString: string); virtual;
|
||||
|
||||
procedure ClearAddedAndRemovedLibraries;
|
||||
function AddThread(AThreadIdentifier: THandle): TDbgThread;
|
||||
function GetThreadArray: TFPDThreadArray;
|
||||
procedure ThreadsBeforeContinue;
|
||||
@ -967,7 +968,11 @@ begin
|
||||
end;
|
||||
|
||||
procedure TLibraryMap.ClearAddedAndRemovedLibraries;
|
||||
var
|
||||
lib: TDbgLibrary;
|
||||
begin
|
||||
for lib in FLibrariesRemoved do
|
||||
lib.Free;
|
||||
FLibrariesAdded := [];
|
||||
FLibrariesRemoved := [];
|
||||
end;
|
||||
@ -1839,6 +1844,7 @@ begin
|
||||
//FreeItemsInMap(FBreakMap);
|
||||
FreeItemsInMap(FThreadMap);
|
||||
FreeItemsInMap(FLibMap);
|
||||
FLibMap.ClearAddedAndRemovedLibraries;
|
||||
|
||||
FreeAndNil(FWatchPointData);
|
||||
FreeAndNil(FBreakMap);
|
||||
@ -2091,6 +2097,12 @@ begin
|
||||
// Do nothing
|
||||
end;
|
||||
|
||||
procedure TDbgProcess.ClearAddedAndRemovedLibraries;
|
||||
begin
|
||||
{$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadIdNotMain('TBreakLocationMap.AddLocotion');{$ENDIF}
|
||||
FLibMap.ClearAddedAndRemovedLibraries;
|
||||
end;
|
||||
|
||||
function TDbgProcess.AddThread(AThreadIdentifier: THandle): TDbgThread;
|
||||
var
|
||||
IsMainThread: boolean;
|
||||
|
@ -1591,6 +1591,8 @@ begin
|
||||
end;
|
||||
|
||||
FreeAndNil(FCommandToBeFreed);
|
||||
FCurrentProcess.ClearAddedAndRemovedLibraries;
|
||||
|
||||
if FCommand <> nil then
|
||||
FCommand.DoBeforeLoopStart;
|
||||
|
||||
|
@ -1391,7 +1391,6 @@ var
|
||||
begin
|
||||
Result := TDbgWinLibrary.Create(Self, HexValue(AInfo.lpBaseOfDll, SizeOf(Pointer), [hvfIncludeHexchar]), AInfo.hFile, TDbgPtr(AInfo.lpBaseOfDll), AInfo);
|
||||
ID := TDbgPtr(AInfo.lpBaseOfDll);
|
||||
FLibMap.ClearAddedAndRemovedLibraries;
|
||||
FLibMap.Add(ID, Result);
|
||||
if (Result.DbgInfo.HasInfo) or (Result.SymbolTableInfo.HasInfo)
|
||||
then FSymInstances.Add(Result);
|
||||
@ -1406,7 +1405,6 @@ begin
|
||||
ID := TDbgPtr(AInfo.lpBaseOfDll);
|
||||
if not FLibMap.GetData(ID, Lib) then Exit;
|
||||
FSymInstances.Remove(Lib);
|
||||
FLibMap.ClearAddedAndRemovedLibraries;
|
||||
FLibMap.Delete(ID);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user