mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 11:30:28 +02:00
FpDebug: Line-Addr-Map, use Hash/Dictionary for filenames
This commit is contained in:
parent
3185572fdf
commit
e98044f52f
@ -44,7 +44,7 @@ unit FpDbgDwarfDataClasses;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, Types, SysUtils, Contnrs, Math, fgl,
|
Classes, Types, SysUtils, Contnrs, Math, fgl, Generics.Collections,
|
||||||
// LazUtils
|
// LazUtils
|
||||||
Maps, LazClasses, LazFileUtils, LazUTF8, LazCollections,
|
Maps, LazClasses, LazFileUtils, LazUTF8, LazCollections,
|
||||||
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
|
||||||
@ -808,7 +808,7 @@ type
|
|||||||
property KnownNameHashes: PKnownNameHashesArray read GetKnownNameHashes; // Only for TOP-LEVEL entries
|
property KnownNameHashes: PKnownNameHashesArray read GetKnownNameHashes; // Only for TOP-LEVEL entries
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TLineNumberFileMap = specialize TFPGMap<AnsiString, PDWarfLineMap>;
|
TLineNumberFileMap = specialize TDictionary<AnsiString, PDWarfLineMap>;
|
||||||
|
|
||||||
{ TFpDwarfInfo }
|
{ TFpDwarfInfo }
|
||||||
|
|
||||||
@ -3852,13 +3852,11 @@ end;
|
|||||||
destructor TFpDwarfInfo.Destroy;
|
destructor TFpDwarfInfo.Destroy;
|
||||||
procedure FreeLineNumberMap;
|
procedure FreeLineNumberMap;
|
||||||
var
|
var
|
||||||
n: Integer;
|
|
||||||
m: PDWarfLineMap;
|
m: PDWarfLineMap;
|
||||||
begin
|
begin
|
||||||
if FLineNumberMap = nil then
|
if FLineNumberMap = nil then
|
||||||
exit;
|
exit;
|
||||||
for n := 0 to FLineNumberMap.Count - 1 do begin
|
for m in FLineNumberMap.Values do begin
|
||||||
m := FLineNumberMap.Data[n];
|
|
||||||
m^.Free;
|
m^.Free;
|
||||||
Dispose(m);
|
Dispose(m);
|
||||||
end;
|
end;
|
||||||
@ -4147,29 +4145,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TFpDwarfInfo.GetLineAddressMap(const AFileName: String): PDWarfLineMap;
|
function TFpDwarfInfo.GetLineAddressMap(const AFileName: String): PDWarfLineMap;
|
||||||
|
|
||||||
|
|
||||||
function FindIndex: Integer;
|
|
||||||
var
|
|
||||||
Name: String;
|
|
||||||
begin
|
|
||||||
// try fullname first
|
|
||||||
Result := FLineNumberMap.IndexOf(AFileName);
|
|
||||||
if Result <> -1 then Exit;
|
|
||||||
|
|
||||||
Name := ExtractFileName(AFileName);
|
|
||||||
Result := FLineNumberMap.IndexOf(Name);
|
|
||||||
if Result <> -1 then Exit;
|
|
||||||
|
|
||||||
for Result := 0 to FLineNumberMap.Count - 1 do
|
|
||||||
if AnsiCompareText(Name, ExtractFileName(FLineNumberMap.Keys[Result])) = 0 then
|
|
||||||
Exit;
|
|
||||||
Result := -1;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
n, idx: Integer;
|
n: Integer;
|
||||||
CU: TDwarfCompilationUnit;
|
CU: TDwarfCompilationUnit;
|
||||||
|
BaseName, k: String;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
if FLineNumberMap = nil then Exit;
|
if FLineNumberMap = nil then Exit;
|
||||||
@ -4186,10 +4165,21 @@ begin
|
|||||||
FLineNumberMapDone := True;
|
FLineNumberMapDone := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
idx := FindIndex;
|
if FLineNumberMap.TryGetValue(AFileName, Result) then
|
||||||
if idx = -1 then Exit;
|
exit;
|
||||||
|
|
||||||
Result := FLineNumberMap.Data[idx];
|
BaseName := ExtractFileName(AFileName);
|
||||||
|
if FLineNumberMap.TryGetValue(BaseName, Result) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
for k in FLineNumberMap.Keys do begin
|
||||||
|
if AnsiCompareText(BaseName, ExtractFileName(k)) = 0 then begin
|
||||||
|
Result := FLineNumberMap[k];
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFpDwarfInfo.LoadCallFrameInstructions;
|
procedure TFpDwarfInfo.LoadCallFrameInstructions;
|
||||||
@ -5019,7 +5009,6 @@ procedure TDwarfCompilationUnit.BuildLineInfo(AAddressInfo: PDwarfAddressInfo; A
|
|||||||
var
|
var
|
||||||
Iter: TMapIterator;
|
Iter: TMapIterator;
|
||||||
Info, NextInfo: PDwarfAddressInfo;
|
Info, NextInfo: PDwarfAddressInfo;
|
||||||
idx: Integer;
|
|
||||||
LineMap: PDWarfLineMap;
|
LineMap: PDWarfLineMap;
|
||||||
Line: Cardinal;
|
Line: Cardinal;
|
||||||
CurrentFileName: String;
|
CurrentFileName: String;
|
||||||
@ -5035,7 +5024,7 @@ begin
|
|||||||
|
|
||||||
BuildAddressMap;
|
BuildAddressMap;
|
||||||
Iter := TMapIterator.Create(FAddressMap);
|
Iter := TMapIterator.Create(FAddressMap);
|
||||||
idx := -1;
|
CurrentFileName := '';
|
||||||
Info := nil;
|
Info := nil;
|
||||||
NextInfo := nil;
|
NextInfo := nil;
|
||||||
|
|
||||||
@ -5044,18 +5033,15 @@ begin
|
|||||||
begin
|
begin
|
||||||
Line := FLineInfo.StateMachine.Line;
|
Line := FLineInfo.StateMachine.Line;
|
||||||
|
|
||||||
if (idx < 0) or (CurrentFileName <> FLineInfo.StateMachine.FileName) then begin
|
if (CurrentFileName = '') or (CurrentFileName <> FLineInfo.StateMachine.FileName) then begin
|
||||||
idx := FOwner.FLineNumberMap.IndexOf(FLineInfo.StateMachine.FileName);
|
CurrentFileName := FLineInfo.StateMachine.FileName;
|
||||||
if idx = -1
|
if CurrentFileName = '' then
|
||||||
then begin
|
Continue;
|
||||||
|
if not FOwner.FLineNumberMap.TryGetValue(CurrentFileName, LineMap) then begin
|
||||||
LineMap := New(PDWarfLineMap);
|
LineMap := New(PDWarfLineMap);
|
||||||
LineMap^.Init;
|
LineMap^.Init;
|
||||||
FOwner.FLineNumberMap.Add(FLineInfo.StateMachine.FileName, LineMap);
|
FOwner.FLineNumberMap.Add(CurrentFileName, LineMap);
|
||||||
end
|
|
||||||
else begin
|
|
||||||
LineMap := FOwner.FLineNumberMap.Data[idx];
|
|
||||||
end;
|
end;
|
||||||
CurrentFileName := FLineInfo.StateMachine.FileName;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addr := FLineInfo.StateMachine.Address;
|
addr := FLineInfo.StateMachine.Address;
|
||||||
|
Loading…
Reference in New Issue
Block a user