mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 11:20:17 +02:00
FpDebug: MacOs, loading of dwarf symbols missed some global vars
git-svn-id: branches/fixes_2_0@60166 -
This commit is contained in:
parent
7313bea60c
commit
b127ffe142
@ -13,7 +13,7 @@ uses
|
||||
{$endif}
|
||||
fgl, lazfglhash,
|
||||
fpDbgSymTable,
|
||||
Classes, SysUtils, LazUTF8Classes;
|
||||
Classes, SysUtils, LazUTF8Classes, contnrs;
|
||||
|
||||
type
|
||||
TDbgImageSection = record
|
||||
@ -37,8 +37,23 @@ type
|
||||
NewAddr: QWord;
|
||||
class operator =(r1,r2: TDbgAddressMap) : boolean;
|
||||
end;
|
||||
PDbgAddressMap = ^TDbgAddressMap;
|
||||
TDbgAddressMapList = specialize TFPGList<TDbgAddressMap>;
|
||||
TDbgAddressMapHashList = specialize TLazFPGHashTable<TDbgAddressMap>;
|
||||
|
||||
{ TDbgAddressMapHashList }
|
||||
|
||||
TDbgAddressMapHashList = class(specialize TLazFPGHashTable<TDbgAddressMap>)
|
||||
public
|
||||
function ItemFromNode(ANode: THTCustomNode): TDbgAddressMap;
|
||||
function ItemPointerFromNode(ANode: THTCustomNode): PDbgAddressMap;
|
||||
end;
|
||||
|
||||
{ TDbgAddressMapPointerHashList }
|
||||
|
||||
TDbgAddressMapPointerHashList = class(specialize TLazFPGHashTable<PDbgAddressMap>)
|
||||
public
|
||||
function ItemPointerFromNode(ANode: THTCustomNode): PDbgAddressMap;
|
||||
end;
|
||||
|
||||
{ TDbgFileLoader }
|
||||
{$ifdef windows}
|
||||
@ -106,6 +121,28 @@ implementation
|
||||
var
|
||||
RegisteredImageReaderClasses : TFPList;
|
||||
|
||||
{ TDbgAddressMapPointerHashList }
|
||||
|
||||
function TDbgAddressMapPointerHashList.ItemPointerFromNode(ANode: THTCustomNode
|
||||
): PDbgAddressMap;
|
||||
begin
|
||||
Result := THTGNode(ANode).Data;
|
||||
end;
|
||||
|
||||
{ TDbgAddressMapHashList }
|
||||
|
||||
function TDbgAddressMapHashList.ItemFromNode(ANode: THTCustomNode
|
||||
): TDbgAddressMap;
|
||||
begin
|
||||
Result := THTGNode(ANode).Data;
|
||||
end;
|
||||
|
||||
function TDbgAddressMapHashList.ItemPointerFromNode(ANode: THTCustomNode
|
||||
): PDbgAddressMap;
|
||||
begin
|
||||
Result := @THTGNode(ANode).Data;
|
||||
end;
|
||||
|
||||
class operator TDbgAddressMap.=(r1,r2: TDbgAddressMap) : boolean;
|
||||
begin
|
||||
result := (r1.OrgAddr=r2.OrgAddr) and (r1.Length=r2.Length) and (r1.NewAddr=r2.NewAddr);
|
||||
|
@ -599,8 +599,11 @@ var
|
||||
AddressMap: TDbgAddressMap;
|
||||
ProcName: string;
|
||||
DwarfDebugMap: TAppleDwarfDebugMap;
|
||||
FullDwarfDebugMap: TDbgAddressMapPointerHashList;
|
||||
ind: THTCustomNode;
|
||||
begin
|
||||
DwarfDebugMap:=nil;
|
||||
FullDwarfDebugMap := TDbgAddressMapPointerHashList.Create;
|
||||
p := Section[_symbol];
|
||||
ps := Section[_symbolstrings];
|
||||
if assigned(p) and assigned(ps) then
|
||||
@ -643,6 +646,12 @@ begin
|
||||
DwarfDebugMap := TAppleDwarfDebugMap.Create;
|
||||
DwarfDebugMap.Dir := pchar(SymbolStr+StringOffset);
|
||||
state := dtsDir;
|
||||
end
|
||||
else if (SymbolType in [14,15]) then begin
|
||||
ind := FullDwarfDebugMap.Find(pchar(SymbolStr+StringOffset));
|
||||
if (ind <> nil) and (FullDwarfDebugMap.ItemPointerFromNode(ind)^.NewAddr = 0) then begin
|
||||
FullDwarfDebugMap.ItemPointerFromNode(ind)^.NewAddr := SymbolValue;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
dtsDir:
|
||||
@ -670,12 +679,17 @@ begin
|
||||
begin
|
||||
inc(state);
|
||||
end
|
||||
else if (SymbolType = N_STSYM) then
|
||||
else if (SymbolType = N_STSYM) or (SymbolType = N_GSYM) then
|
||||
begin
|
||||
AddressMap.NewAddr:=SymbolValue;
|
||||
AddressMap.OrgAddr:=0;
|
||||
AddressMap.Length:=0;
|
||||
DwarfDebugMap.GlobalList.Add(pchar(SymbolStr+StringOffset), AddressMap);
|
||||
if (SymbolType = N_GSYM) and (SymbolValue = 0) then begin
|
||||
ind := DwarfDebugMap.GlobalList.Find(pchar(SymbolStr+StringOffset));
|
||||
FullDwarfDebugMap.Add(pchar(SymbolStr+StringOffset),
|
||||
DwarfDebugMap.GlobalList.ItemPointerFromNode(ind));
|
||||
end;
|
||||
end
|
||||
else if (SymbolType = N_SO) and (SymbolSect=1) then
|
||||
begin
|
||||
@ -712,6 +726,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
FullDwarfDebugMap.Free;
|
||||
end;
|
||||
|
||||
procedure TDbgMachoDataSource.ParseSubAppleDwarfDataMap(ADebugMap: TObject);
|
||||
@ -767,7 +782,7 @@ begin
|
||||
ind := MainDwarfDebugMap.GlobalList.Find(s);
|
||||
if assigned(ind) then
|
||||
begin
|
||||
AddressMap:=MainDwarfDebugMap.GlobalList.Items[s];
|
||||
AddressMap:=MainDwarfDebugMap.GlobalList.ItemFromNode(ind);
|
||||
AddressMap.OrgAddr:=SymbolValue;
|
||||
AddressMapList.Add(AddressMap);
|
||||
end;
|
||||
@ -778,7 +793,7 @@ begin
|
||||
ind := MainDwarfDebugMap.GlobalList.Find(s);
|
||||
if assigned(ind) then
|
||||
begin
|
||||
AddressMap:=MainDwarfDebugMap.GlobalList.Items[s];
|
||||
AddressMap:=MainDwarfDebugMap.GlobalList.ItemFromNode(ind);
|
||||
AddressMap.OrgAddr:=SymbolValue;
|
||||
AddressMapList.Add(AddressMap);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user