FpDbg: faster line info access

git-svn-id: trunk@42852 -
This commit is contained in:
martin 2013-09-18 08:58:56 +00:00
parent e1f9d84e5e
commit 09865a59b5
2 changed files with 40 additions and 10 deletions

View File

@ -297,6 +297,7 @@ type
constructor Create(AOwner: TDbgDwarf; ADataOffset: QWord; ALength: QWord; AVersion: Word; AAbbrevOffset: QWord; AAddressSize: Byte; AIsDwarf64: Boolean); virtual;
destructor Destroy; override;
function GetDefinition(AAbbrev: Cardinal; out ADefinition: TDwarfAbbrev): Boolean;
function GetLineAddressMap(const AFileName: String): TMap;
function GetLineAddress(const AFileName: String; ALine: Cardinal): TDbgPtr;
property FileName: String read FFileName;
property Valid: Boolean read FValid;
@ -411,6 +412,7 @@ type
destructor Destroy; override;
function FindSymbol(AAddress: TDbgPtr): TDbgSymbol; override;
function GetLineAddress(const AFileName: String; ALine: Cardinal): TDbgPtr; override;
function GetLineAddressMap(const AFileName: String): TMap;
function LoadCompilationUnits: Integer;
function PointerFromRVA(ARVA: QWord): Pointer;
function PointerFromVA(ASection: TDwarfSection; AVA: QWord): Pointer;
@ -1115,6 +1117,21 @@ begin
Result := 0;
end;
function TDbgDwarf.GetLineAddressMap(const AFileName: String): TMap;
var
n: Integer;
CU: TDwarfCompilationUnit;
begin
// TODO: Deal with line info split on 2 compilation units?
for n := 0 to FCompilationUnits.Count - 1 do
begin
CU := TDwarfCompilationUnit(FCompilationUnits[n]);
Result := CU.GetLineAddressMap(AFileName);
if Result <> nil then Exit;
end;
Result := nil;
end;
function TDbgDwarf.LoadCompilationUnits: Integer;
var
p: Pointer;
@ -1652,10 +1669,10 @@ begin
Result := FMap.GetData(AAbbrev, ADefinition);
end;
function TDwarfCompilationUnit.GetLineAddress(const AFileName: String; ALine: Cardinal): TDbgPtr;
function FindIndex: Integer;
function TDwarfCompilationUnit.GetLineAddressMap(const AFileName: String): TMap;
var
Name: String;
function FindIndex: Integer;
begin
// try fullname first
Result := FLineNumberMap.IndexOf(AFileName);
@ -1677,7 +1694,7 @@ var
idx: Integer;
Map: TMap;
begin
Result := 0;
Result := nil;
if not Valid then Exit;
// make sure all filenames are there
@ -1685,7 +1702,16 @@ begin
idx := FindIndex;
if idx = -1 then Exit;
Map := TMap(FLineNumberMap.Objects[idx]);
Result := TMap(FLineNumberMap.Objects[idx]);
end;
function TDwarfCompilationUnit.GetLineAddress(const AFileName: String; ALine: Cardinal): TDbgPtr;
var
Map: TMap;
begin
Result := 0;
Map := GetLineAddressMap(AFileName);
if Map = nil then exit;
Map.GetData(ALine, Result);
end;

View File

@ -6,7 +6,7 @@ interface
uses
Classes, sysutils, GDBMIDebugger, BaseDebugManager, Debugger,
GDBMIMiscClasses, FpDbgLoader, FpDbgDwarf, LazLoggerBase;
GDBMIMiscClasses, maps, FpDbgLoader, FpDbgDwarf, LazLoggerBase;
type
@ -98,17 +98,21 @@ begin
end;
function TFpGDBMILineInfo.GetAddress(const AIndex: Integer; const ALine: Integer): TDbgPtr;
var
Map: TMap;
begin
debugln(['TFpGDBMILineInfo.GetAddress ', dbgs(FpDebugger.HasDwarf), ' ', FRequestedSources[AIndex], '(', AIndex,'), ', ALine]);
Result := 0;
if not FpDebugger.HasDwarf then
exit(0);
Result := FpDebugger.FDwarfInfo.GetLineAddress(FRequestedSources[AIndex], ALine);
exit;
//Result := FpDebugger.FDwarfInfo.GetLineAddress(FRequestedSources[AIndex], ALine);
Map := TMap(FRequestedSources.Objects[AIndex]);
if Map <> nil then
Map.GetData(ALine, Result);
end;
function TFpGDBMILineInfo.GetInfo(AAdress: TDbgPtr; out ASource, ALine,
AOffset: Integer): Boolean;
begin
debugln(['TFpGDBMILineInfo.GetInfo ##########################']);
Result := False;
//ASource := '';
//ALine := 0;
@ -124,7 +128,7 @@ end;
procedure TFpGDBMILineInfo.Request(const ASource: String);
begin
FRequestedSources.Add(ASource);
FRequestedSources.AddObject(ASource, FpDebugger.FDwarfInfo.GetLineAddressMap(ASource));
DoChange(ASource);
end;