procedure Read_Aranges_Entry
(C : in out Dwarf_Context;
- Start : out Integer_Address;
+ Start : out Storage_Offset;
Len : out Storage_Count);
-- Read a single .debug_aranges pair
procedure Aranges_Lookup
(C : in out Dwarf_Context;
- Addr : Address;
+ Addr : Storage_Offset;
Info_Offset : out Offset;
Success : out Boolean);
-- Search for Addr in .debug_aranges and return offset Info_Offset in
procedure Symbolic_Address
(C : in out Dwarf_Context;
- Addr : Address;
+ Addr : Storage_Offset;
Dir_Name : out Str_Access;
File_Name : out Str_Access;
Subprg_Name : out String_Ptr_Len;
return;
end if;
for I in Cache'Range loop
- Put (System.Address_Image (C.Low + Storage_Count (Cache (I).First)));
- Put (" - ");
- Put
- (System.Address_Image
- (C.Low + Storage_Count (Cache (I).First + Cache (I).Size)));
- Put (" l@");
- Put
- (System.Address_Image
- (To_Address (Integer_Address (Cache (I).Line))));
- Put (": ");
- S := Read_Symbol (C.Obj.all, Offset (Cache (I).Sym));
- Name := Object_Reader.Name (C.Obj.all, S);
- Put (String (Name.Ptr (1 .. Name.Len)));
- New_Line;
+ declare
+ E : Search_Entry renames Cache (I);
+ Base_Address : constant System.Address :=
+ To_Address (Integer_Address (C.Low + Storage_Count (E.First)));
+ begin
+ Put (System.Address_Image (Base_Address));
+ Put (" - ");
+ Put (System.Address_Image (Base_Address + Storage_Count (E.Size)));
+ Put (" l@");
+ Put (System.Address_Image (To_Address (Integer_Address (E.Line))));
+ Put (": ");
+ S := Read_Symbol (C.Obj.all, Offset (E.Sym));
+ Name := Object_Reader.Name (C.Obj.all, S);
+ Put (String (Name.Ptr (1 .. Name.Len)));
+ New_Line;
+ end;
end loop;
end Dump_Cache;
function Is_Inside (C : Dwarf_Context; Addr : Address) return Boolean is
begin
- return (Addr >= To_Address (To_Integer (C.Low) + C.Load_Address)
- and Addr <= To_Address (To_Integer (C.High) + C.Load_Address));
+ return (Addr >= C.Low + C.Load_Address
+ and then Addr <= C.High + C.Load_Address);
end Is_Inside;
- ---------
- -- Low --
- ---------
+ -----------------
+ -- Low_Address --
+ -----------------
- function Low (C : Dwarf_Context) return Address is
+ function Low_Address (C : Dwarf_Context)
+ return System.Address is
begin
- return C.Low;
- end Low;
+ return C.Load_Address + C.Low;
+ end Low_Address;
----------
-- Open --
-- Get memory bounds
Get_Memory_Bounds (C.Obj.all, Lo, Hi);
- C.Low := Address (Lo);
- C.High := Address (Hi);
+ C.Low := Storage_Offset (Lo);
+ C.High := Storage_Offset (Hi);
-- Create a stream for debug sections
procedure Set_Load_Address (C : in out Dwarf_Context; Addr : Address) is
begin
- C.Load_Address := To_Integer (Addr);
+ C.Load_Address := Addr;
end Set_Load_Address;
------------------
procedure Aranges_Lookup
(C : in out Dwarf_Context;
- Addr : Address;
+ Addr : Storage_Offset;
Info_Offset : out Offset;
Success : out Boolean)
is
loop
declare
- Start : Integer_Address;
+ Start : Storage_Offset;
Len : Storage_Count;
begin
Read_Aranges_Entry (C, Start, Len);
exit when Start = 0 and Len = 0;
- if Addr >= To_Address (Start)
- and then Addr < To_Address (Start) + Len
+ if Addr >= Start
+ and then Addr < Start + Len
then
Success := True;
return;
procedure Read_Aranges_Entry
(C : in out Dwarf_Context;
- Start : out Integer_Address;
+ Start : out Storage_Offset;
Len : out Storage_Count)
is
begin
begin
S := Read (C.Aranges);
L := Read (C.Aranges);
- Start := Integer_Address (S);
+ Start := Storage_Offset (S);
Len := Storage_Count (L);
end;
elsif Address'Size = 64 then
begin
S := Read (C.Aranges);
L := Read (C.Aranges);
- Start := Integer_Address (S);
+ Start := Storage_Offset (S);
Len := Storage_Count (L);
end;
else
Info_Offset : Offset;
Line_Offset : Offset;
Success : Boolean;
- Ar_Start : Integer_Address;
+ Ar_Start : Storage_Offset;
Ar_Len : Storage_Count;
Start, Len : uint32;
First, Last : Natural;
exit when Ar_Start = 0 and Ar_Len = 0;
Len := uint32 (Ar_Len);
- Start := uint32 (Ar_Start - To_Integer (C.Low));
+ Start := uint32 (Ar_Start - C.Low);
-- Search START in the array
First := Cache'First;
procedure Symbolic_Address
(C : in out Dwarf_Context;
- Addr : Address;
+ Addr : Storage_Offset;
Dir_Name : out Str_Access;
File_Name : out Str_Access;
Subprg_Name : out String_Ptr_Len;
Line_Num := Natural (Match.Line);
end Set_Result;
- Addr_Int : constant Integer_Address := To_Integer (Addr);
+ Addr_Int : constant uint64 := uint64 (Addr);
Previous_Row : Line_Info_Registers;
Info_Offset : Offset;
Line_Offset : Offset;
-- Search symbol
S := First_Symbol (C.Obj.all);
while S /= Null_Symbol loop
- if Spans (S, uint64 (Addr_Int)) then
+ if Spans (S, Addr_Int) then
Subprg_Name := Object_Reader.Name (C.Obj.all, S);
exit;
end if;
if C.Registers.Is_Row then
if not Previous_Row.End_Sequence
- and then Addr_Int >= Integer_Address (Previous_Row.Address)
- and then Addr_Int < Integer_Address (C.Registers.Address)
+ and then Addr_Int >= Previous_Row.Address
+ and then Addr_Int < C.Registers.Address
then
Set_Result (Previous_Row);
return;
- elsif Addr_Int = Integer_Address (C.Registers.Address) then
+ elsif Addr_Int = C.Registers.Address then
Set_Result (C.Registers);
return;
end if;
C : Dwarf_Context := Cin;
Addr_In_Traceback : Address;
- Addr_To_Lookup : Address;
+ Offset_To_Lookup : Storage_Offset;
Dir_Name : Str_Access;
File_Name : Str_Access;
Addr_In_Traceback := PC_For (Traceback (J));
- Addr_To_Lookup := To_Address
- (To_Integer (Addr_In_Traceback) - C.Load_Address);
+ Offset_To_Lookup := Addr_In_Traceback - C.Load_Address;
Symbolic_Address
(C,
- Addr_To_Lookup,
+ Offset_To_Lookup,
Dir_Name,
File_Name,
Subprg_Name,
pragma Inline (Is_Inside);
-- Return true iff a run-time address Addr is within the module
- function Low (C : Dwarf_Context) return Address;
- pragma Inline (Low);
- -- Return the lowest address of C, from the module object file
+ function Low_Address (C : Dwarf_Context)
+ return System.Address;
+ pragma Inline (Low_Address);
+ -- Return the lowest address of C, accounting for the module load address
procedure Dump (C : in out Dwarf_Context);
-- Dump each row found in the object's .debug_lines section to standard out
type Search_Array_Access is access Search_Array;
type Dwarf_Context (In_Exception : Boolean := False) is record
- Load_Address : System.Storage_Elements.Integer_Address := 0;
- Low, High : Address;
+ Low, High : System.Storage_Elements.Storage_Offset;
-- Bounds of the module, per the module object file
Obj : SOR.Object_File_Access;
-- The object file containing dwarf sections
+ Load_Address : System.Address := System.Null_Address;
+ -- The address at which the object file was loaded at run time
+
Has_Debug : Boolean;
-- True if all debug sections are available