From 35c480e02ea666dd5b433a13ef91c93da1804525 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 20 Jun 2018 15:28:04 +0000 Subject: [PATCH] LLDB Debugger: mem leaks git-svn-id: trunk@58353 - --- .../lazdebuggerlldb/lldbdebugger.pas | 21 +++++++------ .../lazdebuggerlldb/lldbinstructions.pas | 31 +++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas b/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas index b6a930fb2a..cbeb80d977 100644 --- a/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas +++ b/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas @@ -348,6 +348,7 @@ var CurThr: Boolean; Arguments: TStringList; addr: TDBGPtr; + te: TThreadEntry; begin CurrentThreads.Clear; for i := 0 to Length(Instr.Res) - 1 do begin @@ -356,16 +357,16 @@ begin if CurThr then CurThrId := TId; - CurrentThreads.Add( - CurrentThreads.CreateEntry( - addr, - Arguments, - func, - filename, '', - line, - TId, name, '' - ) + te := CurrentThreads.CreateEntry( + addr, + Arguments, + func, + filename, '', + line, + TId, name, '' ); + CurrentThreads.Add(te); + te.Free; Arguments.Free; end; @@ -455,6 +456,7 @@ begin e := TCallStackEntry(It.DataPtr^); e.Init(addr, Arguments, func, filename, '', line); end; + Arguments.Free; end; It.Free; @@ -1057,6 +1059,7 @@ begin if ParseFrameLocation(ALine, AnId, AnIsCurrent, AnAddr, AFuncName, AnArgs, AFile, SrcLine, AReminder) then begin + AnArgs.Free; FCurrentLocation.Address := AnAddr; FCurrentLocation.FuncName := AFuncName; FCurrentLocation.SrcFile := AFile; diff --git a/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas b/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas index e3db985454..30a63f965a 100644 --- a/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas +++ b/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas @@ -173,6 +173,7 @@ type procedure SendCommandDataToDbg(); override; public constructor Create(AnAddress: TDBGPtr; ALen: Cardinal); + destructor Destroy; override; property Res: TArrayOfByte read FRes; end; @@ -188,6 +189,7 @@ type procedure SendCommandDataToDbg(); override; public constructor Create(AThread, AFrame: Integer); + destructor Destroy; override; property Res: TStringList read FRes; end; @@ -202,6 +204,7 @@ type function ProcessInputFromDbg(const AData: String): Boolean; override; public constructor Create(); + destructor Destroy; override; property Res: TStringArray read FRes; end; @@ -216,6 +219,7 @@ type function ProcessInputFromDbg(const AData: String): Boolean; override; public constructor Create(FrameCount: Integer; AThread: Integer); + destructor Destroy; override; property Res: TStringArray read FRes; end; @@ -477,6 +481,9 @@ begin if not Result then // if Result=true then self is destroyed; MarkAsSuccess; Result := true; + + //TODO: "error: No breakpoints exist to be deleted." + // prevent from failing other instruction end; constructor TLldbInstructionBreakDelete.Create(AnId: Integer); @@ -644,6 +651,12 @@ begin inherited Create(Format('memory read --force --size 1 --format x --count %u %u', [ALen, AnAddress])); end; +destructor TLldbInstructionMemory.Destroy; +begin + inherited Destroy; + FRes := nil; +end; + { TLldbInstructionRegister } procedure TLldbInstructionRegister.DoFree; @@ -722,6 +735,12 @@ begin inherited Create('register read --all', AThread, AFrame); end; +destructor TLldbInstructionRegister.Destroy; +begin + inherited Destroy; + FRes.Free; +end; + { TLldbInstructionThreadList } procedure TLldbInstructionThreadList.SendCommandDataToDbg(); @@ -773,6 +792,12 @@ begin inherited Create('thread list'); end; +destructor TLldbInstructionThreadList.Destroy; +begin + inherited Destroy; + FRes := nil; +end; + { TLldbInstructionStackTrace } procedure TLldbInstructionStackTrace.SendCommandDataToDbg(); @@ -824,5 +849,11 @@ begin inherited Create(Format('bt %d', [FrameCount]), AThread); end; +destructor TLldbInstructionStackTrace.Destroy; +begin + inherited Destroy; + FRes := nil; +end; + end.