mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 03:49:30 +02:00
FpDebug: Fix reading DWARF-5, use correct HeaderSize when resolving references.
(cherry picked from commit 79bed04544
)
This commit is contained in:
parent
c7825f845b
commit
c59185d149
@ -665,6 +665,7 @@ type
|
|||||||
// --- Header ---
|
// --- Header ---
|
||||||
FLength: QWord; // length of info
|
FLength: QWord; // length of info
|
||||||
FVersion: Word;
|
FVersion: Word;
|
||||||
|
FHeaderSize: Integer;
|
||||||
FAbbrevOffset: QWord;
|
FAbbrevOffset: QWord;
|
||||||
FAddressSize: Byte; // the address size of the target in bytes
|
FAddressSize: Byte; // the address size of the target in bytes
|
||||||
FIsDwarf64: Boolean; // Set if the dwarf info in this unit is 64bit
|
FIsDwarf64: Boolean; // Set if the dwarf info in this unit is 64bit
|
||||||
@ -792,6 +793,7 @@ type
|
|||||||
property FirstScope: TDwarfScopeInfo read GetFirstScope;
|
property FirstScope: TDwarfScopeInfo read GetFirstScope;
|
||||||
|
|
||||||
// public for FpDbgDwarfVerbosePrinter
|
// public for FpDbgDwarfVerbosePrinter
|
||||||
|
property HeaderSize: Integer read FHeaderSize;
|
||||||
property InfoData: Pointer read FInfoData;
|
property InfoData: Pointer read FInfoData;
|
||||||
property InfoDataLength: QWord read FLength; // length of info
|
property InfoDataLength: QWord read FLength; // length of info
|
||||||
property AddressMap: TMap read GetAddressMap;
|
property AddressMap: TMap read GetAddressMap;
|
||||||
@ -3337,8 +3339,6 @@ end;
|
|||||||
function TDwarfInformationEntry.DoReadReference(
|
function TDwarfInformationEntry.DoReadReference(
|
||||||
InfoIdx: Integer; InfoData: pointer; out AValue: Pointer; out
|
InfoIdx: Integer; InfoData: pointer; out AValue: Pointer; out
|
||||||
ACompUnit: TDwarfCompilationUnit): Boolean;
|
ACompUnit: TDwarfCompilationUnit): Boolean;
|
||||||
const
|
|
||||||
CU_HEADER_SIZE: array [boolean] of QWord = (SizeOf(TDwarfCUHeader32), SizeOf(TDwarfCUHeader64));
|
|
||||||
var
|
var
|
||||||
Form: Cardinal;
|
Form: Cardinal;
|
||||||
Offs: QWord;
|
Offs: QWord;
|
||||||
@ -3362,7 +3362,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
ACompUnit := FCompUnit;
|
ACompUnit := FCompUnit;
|
||||||
{$PUSH}{$R-}
|
{$PUSH}{$R-}
|
||||||
AValue := ACompUnit.FirstScope.Entry - CU_HEADER_SIZE[ACompUnit.FIsDwarf64] + Offs;
|
AValue := ACompUnit.FirstScope.Entry - ACompUnit.HeaderSize + Offs;
|
||||||
{$POP}
|
{$POP}
|
||||||
if (AValue < ACompUnit.FInfoData) or (AValue >= ACompUnit.FInfoData + ACompUnit.FLength) then begin
|
if (AValue < ACompUnit.FInfoData) or (AValue >= ACompUnit.FInfoData + ACompUnit.FLength) then begin
|
||||||
DebugLn(FPDBG_DWARF_ERRORS, 'Error: Reference to invalid location. Offset %d is outsize the CU of size %d', [Offs, ACompUnit.FLength]);
|
DebugLn(FPDBG_DWARF_ERRORS, 'Error: Reference to invalid location. Offset %d is outsize the CU of size %d', [Offs, ACompUnit.FLength]);
|
||||||
@ -5304,6 +5304,18 @@ begin
|
|||||||
FLength := ALength;
|
FLength := ALength;
|
||||||
FVersion := AVersion;
|
FVersion := AVersion;
|
||||||
FAbbrevOffset := AAbbrevOffset;
|
FAbbrevOffset := AAbbrevOffset;
|
||||||
|
|
||||||
|
case AIsDwarf64 of
|
||||||
|
True: case AVersion of
|
||||||
|
0..4: FHeaderSize := SizeOf(TDwarfCUHeader64);
|
||||||
|
else FHeaderSize := SizeOf(TDwarfCUHeader64v5);
|
||||||
|
end;
|
||||||
|
False: case AVersion of
|
||||||
|
0..4: FHeaderSize := SizeOf(TDwarfCUHeader32);
|
||||||
|
else FHeaderSize := SizeOf(TDwarfCUHeader32v5);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// check for address as offset
|
// check for address as offset
|
||||||
if FAbbrevOffset > ADebugFile^.Sections[dsAbbrev].Size
|
if FAbbrevOffset > ADebugFile^.Sections[dsAbbrev].Size
|
||||||
then begin
|
then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user