mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 22:18:15 +02:00
LeakView: Use FpDebug to resolve traces without lines
git-svn-id: trunk@61105 -
This commit is contained in:
parent
4544b99ea8
commit
b5f20a389f
@ -11,11 +11,15 @@ uses
|
||||
// CodeTools
|
||||
CodeToolManager, CodeCache,
|
||||
// LazUtils
|
||||
FileUtil, LazFileUtils, LazClasses,
|
||||
FileUtil, LazFileUtils, LazClasses, LazLoggerBase,
|
||||
// IDEIntf
|
||||
TextTools,
|
||||
// LeakView
|
||||
DbgInfoReader, DbgIntfBaseTypes, LldbHelper;
|
||||
{$IFDEF LEAK_RESOLVE_USE_FPC}
|
||||
DbgInfoReader,
|
||||
{$ENDIF}
|
||||
DbgIntfBaseTypes, FpDbgLoader, FpDbgDwarf, FpDbgInfo,
|
||||
LldbHelper;
|
||||
|
||||
type
|
||||
{ TStackLine }
|
||||
@ -862,18 +866,47 @@ begin
|
||||
end;
|
||||
|
||||
function THeapTrcInfo.ResolveLeakInfo(AFileName: string; Traces: TList): Boolean;
|
||||
var
|
||||
DwarfInfo: TFpDwarfInfo;
|
||||
ImageLoaderList: TDbgImageLoaderList;
|
||||
|
||||
procedure UnLoadDwarf;
|
||||
begin
|
||||
FreeAndNil(DwarfInfo);
|
||||
FreeAndNil(ImageLoaderList);
|
||||
end;
|
||||
procedure LoadDwarf;
|
||||
var
|
||||
ImageLoader: TDbgImageLoader;
|
||||
begin
|
||||
ImageLoader := TDbgImageLoader.Create(AFileName);
|
||||
ImageLoaderList := TDbgImageLoaderList.Create(True);
|
||||
ImageLoader.AddToLoaderList(ImageLoaderList);
|
||||
DwarfInfo := TFpDwarfInfo.Create(ImageLoaderList);
|
||||
DwarfInfo.LoadCompilationUnits;
|
||||
end;
|
||||
|
||||
var
|
||||
trace: TStackTrace;
|
||||
i, j, k: Integer;
|
||||
CurLine: TStackLine;
|
||||
{$IFDEF LEAK_RESOLVE_USE_FPC}
|
||||
FuncName, SrcName: shortstring;
|
||||
SrcLine: longint;
|
||||
{$ENDIF}
|
||||
BadAddresses: TStackLines;
|
||||
sym: TFpDbgSymbol;
|
||||
begin
|
||||
Result := False;
|
||||
{$IFDEF LEAK_RESOLVE_USE_FPC}
|
||||
if not OpenSymbolFile(AFileName) then
|
||||
exit;
|
||||
{$ELSE}
|
||||
LoadDwarf;
|
||||
{$ENDIF}
|
||||
BadAddresses := TStackLines.Create;
|
||||
if DwarfInfo = nil then
|
||||
exit;
|
||||
try
|
||||
for i := 0 to Traces.Count - 1 do begin
|
||||
trace := TStackTrace(Traces[i]);
|
||||
@ -884,21 +917,40 @@ begin
|
||||
if k >= 0 then
|
||||
CurLine.Assign(FKnownAddresses.Lines[k])
|
||||
else
|
||||
if BadAddresses.IndexOfAddr(CurLine.Addr) < 0 then begin
|
||||
if (BadAddresses.IndexOfAddr(CurLine.Addr) < 0) and (CurLine.Addr > 0) then begin
|
||||
{$IFDEF LEAK_RESOLVE_USE_FPC}
|
||||
if GetLineInfo(CurLine.Addr, FuncName, SrcName, SrcLine) then begin
|
||||
CurLine.FileName := SrcName;
|
||||
CurLine.LineNum := SrcLine;
|
||||
FKnownAddresses.Add(CurLine);
|
||||
end
|
||||
{$ELSE}
|
||||
if j > 0 then
|
||||
sym := DwarfInfo.FindSymbol(CurLine.Addr - 1 + ImageLoaderList.ImageBase)
|
||||
else
|
||||
sym := DwarfInfo.FindSymbol(CurLine.Addr + ImageLoaderList.ImageBase);
|
||||
if (sym <> nil) and (sym.Line > 0) then begin
|
||||
CurLine.FileName := sym.FileName;
|
||||
CurLine.LineNum := sym.Line;
|
||||
FKnownAddresses.Add(CurLine);
|
||||
end
|
||||
{$ENDIF}
|
||||
else begin
|
||||
BadAddresses.Add(CurLine);
|
||||
end;
|
||||
{$IFnDEF LEAK_RESOLVE_USE_FPC}
|
||||
ReleaseRefAndNil(sym);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
{$IFDEF LEAK_RESOLVE_USE_FPC}
|
||||
CloseSymbolFile;
|
||||
{$ELSE}
|
||||
UnLoadDwarf;
|
||||
{$ENDIF}
|
||||
FreeAndNil(BadAddresses);
|
||||
Result := True;
|
||||
end;
|
||||
|
@ -5,7 +5,7 @@
|
||||
<Name Value="leakview"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<AddToProjectUsesSection Value="True"/>
|
||||
<Author Value="Dmitry 'skalogryz' Boyarintsev"/>
|
||||
<Author Value="Dmitry 'skalogryz' Boyarintsev"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
@ -53,23 +53,25 @@
|
||||
<EnableI18N Value="True"/>
|
||||
<OutDir Value="languages"/>
|
||||
</i18n>
|
||||
<RequiredPkgs Count="3">
|
||||
<RequiredPkgs Count="4">
|
||||
<Item1>
|
||||
<PackageName Value="LazDebuggerLldb"/>
|
||||
<PackageName Value="fpdebug"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="CodeTools"/>
|
||||
<PackageName Value="LazDebuggerLldb"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
<PackageName Value="CodeTools"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item4>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
||||
|
Loading…
Reference in New Issue
Block a user