-- Start of processing for Expand_Nonbinary_Modular_Op
begin
- -- No action needed if we are not generating C code for a nonbinary
- -- modular operand.
+ -- No action needed if front-end expansion is not required or if we
+ -- have a binary modular operand.
- if not Modify_Tree_For_C
+ if not Expand_Nonbinary_Modular_Ops
or else not Non_Binary_Modulus (Typ)
then
return;
Check_Float_Op_Overflow (N);
- -- When generating C code, convert nonbinary modular additions into code
- -- that relies on the front-end expansion of operator Mod.
-
- if Modify_Tree_For_C then
- Expand_Nonbinary_Modular_Op (N);
- end if;
+ Expand_Nonbinary_Modular_Op (N);
end Expand_N_Op_Add;
---------------------
Expand_Intrinsic_Call (N, Entity (N));
end if;
- -- When generating C code, convert nonbinary modular operators into code
- -- that relies on the front-end expansion of operator Mod.
-
- if Modify_Tree_For_C then
- Expand_Nonbinary_Modular_Op (N);
- end if;
+ Expand_Nonbinary_Modular_Op (N);
end Expand_N_Op_And;
------------------------
Check_Float_Op_Overflow (N);
- -- When generating C code, convert nonbinary modular divisions into code
- -- that relies on the front-end expansion of operator Mod.
-
- if Modify_Tree_For_C then
- Expand_Nonbinary_Modular_Op (N);
- end if;
+ Expand_Nonbinary_Modular_Op (N);
end Expand_N_Op_Divide;
--------------------
Analyze_And_Resolve (N, Typ);
end if;
- -- When generating C code, convert nonbinary modular minus into code
- -- that relies on the front-end expansion of operator Mod.
-
- if Modify_Tree_For_C then
- Expand_Nonbinary_Modular_Op (N);
- end if;
+ Expand_Nonbinary_Modular_Op (N);
end Expand_N_Op_Minus;
---------------------
Check_Float_Op_Overflow (N);
- -- When generating C code, convert nonbinary modular multiplications
- -- into code that relies on the front-end expansion of operator Mod.
-
- if Modify_Tree_For_C then
- Expand_Nonbinary_Modular_Op (N);
- end if;
+ Expand_Nonbinary_Modular_Op (N);
end Expand_N_Op_Multiply;
--------------------
Expand_Intrinsic_Call (N, Entity (N));
end if;
- -- When generating C code, convert nonbinary modular operators into code
- -- that relies on the front-end expansion of operator Mod.
-
- if Modify_Tree_For_C then
- Expand_Nonbinary_Modular_Op (N);
- end if;
+ Expand_Nonbinary_Modular_Op (N);
end Expand_N_Op_Or;
----------------------
Check_Float_Op_Overflow (N);
- -- When generating C code, convert nonbinary modular subtractions into
- -- code that relies on the front-end expansion of operator Mod.
-
- if Modify_Tree_For_C then
- Expand_Nonbinary_Modular_Op (N);
- end if;
+ Expand_Nonbinary_Modular_Op (N);
end Expand_N_Op_Subtract;
---------------------
elsif Is_Intrinsic_Subprogram (Entity (N)) then
Expand_Intrinsic_Call (N, Entity (N));
-
end if;
end Expand_N_Op_Xor;
-- --
-- B o d y --
-- --
--- Copyright (C) 2002-2014, AdaCore --
+-- Copyright (C) 2002-2017, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
procedure VxAddr2Line is
- package Unsigned_32_IO is new Modular_IO (Unsigned_32);
+ package Unsigned_64_IO is new Modular_IO (Unsigned_64);
-- Instantiate Modular_IO to have Put
Ref_Symbol : constant String := "adainit";
-- All supported architectures
type Architecture is
- (DEC_ALPHA,
+ (LINUX_AARCH64,
+ LINUX_ARM,
LINUX_E500V2,
LINUX_I586,
LINUX_POWERPC,
+ LINUX_POWERPC64,
+ LINUX_X86_64,
+ WINDOWS_AARCH64,
+ WINDOWS_ARM,
WINDOWS_E500V2,
WINDOWS_I586,
- WINDOWS_M68K,
WINDOWS_POWERPC,
- SOLARIS_E500V2,
- SOLARIS_I586,
- SOLARIS_POWERPC);
+ WINDOWS_POWERPC64,
+ WINDOWS_X86_64);
type Arch_Record is record
Addr2line_Binary : String_Access;
-- which will avoid computational overflows. Typically only useful when
-- 64bit addresses are provided.
- Bt_Offset_From_Call : Unsigned_32;
+ Bt_Offset_From_Call : Unsigned_64;
-- Offset from a backtrace address to the address of the corresponding
-- call instruction. This should always be 0, except on platforms where
-- the backtrace addresses actually correspond to return and not call
-- Configuration for each of the architectures
Arch_List : array (Architecture'Range) of Arch_Record :=
- (DEC_ALPHA =>
+ (LINUX_AARCH64 =>
(Addr2line_Binary => null,
Nm_Binary => null,
- Addr_Digits_To_Skip => 8,
- Bt_Offset_From_Call => 0),
+ Addr_Digits_To_Skip => 0,
+ Bt_Offset_From_Call => -2),
+ LINUX_ARM =>
+ (Addr2line_Binary => null,
+ Nm_Binary => null,
+ Addr_Digits_To_Skip => 0,
+ Bt_Offset_From_Call => -2),
LINUX_E500V2 =>
(Addr2line_Binary => null,
Nm_Binary => null,
Nm_Binary => null,
Addr_Digits_To_Skip => 0,
Bt_Offset_From_Call => -4),
- SOLARIS_E500V2 =>
+ LINUX_POWERPC64 =>
(Addr2line_Binary => null,
Nm_Binary => null,
Addr_Digits_To_Skip => 0,
Bt_Offset_From_Call => -4),
- SOLARIS_I586 =>
+ LINUX_X86_64 =>
(Addr2line_Binary => null,
Nm_Binary => null,
Addr_Digits_To_Skip => 0,
Bt_Offset_From_Call => -2),
- SOLARIS_POWERPC =>
+ WINDOWS_AARCH64 =>
(Addr2line_Binary => null,
Nm_Binary => null,
Addr_Digits_To_Skip => 0,
- Bt_Offset_From_Call => -4),
+ Bt_Offset_From_Call => -2),
+ WINDOWS_ARM =>
+ (Addr2line_Binary => null,
+ Nm_Binary => null,
+ Addr_Digits_To_Skip => 0,
+ Bt_Offset_From_Call => -2),
WINDOWS_E500V2 =>
(Addr2line_Binary => null,
Nm_Binary => null,
Nm_Binary => null,
Addr_Digits_To_Skip => 0,
Bt_Offset_From_Call => -2),
- WINDOWS_M68K =>
+ WINDOWS_POWERPC =>
(Addr2line_Binary => null,
Nm_Binary => null,
Addr_Digits_To_Skip => 0,
Bt_Offset_From_Call => -4),
- WINDOWS_POWERPC =>
+ WINDOWS_POWERPC64 =>
+ (Addr2line_Binary => null,
+ Nm_Binary => null,
+ Addr_Digits_To_Skip => 0,
+ Bt_Offset_From_Call => -4),
+ WINDOWS_X86_64 =>
(Addr2line_Binary => null,
Nm_Binary => null,
Addr_Digits_To_Skip => 0,
- Bt_Offset_From_Call => -4)
+ Bt_Offset_From_Call => -2)
);
-- Current architecture
procedure Usage;
-- Displays the short help message and then terminates the program
- function Get_Reference_Offset return Unsigned_32;
+ function Get_Reference_Offset return Unsigned_64;
-- Computes the static offset of the reference symbol by calling nm
- function Get_Value_From_Hex_Arg (Arg : Natural) return Unsigned_32;
+ function Get_Value_From_Hex_Arg (Arg : Natural) return Unsigned_64;
-- Threats the argument number Arg as a C-style hexadecimal literal
-- and returns its integer value
- function Hex_Image (Value : Unsigned_32) return String_Access;
+ function Hex_Image (Value : Unsigned_64) return String_Access;
-- Returns access to a string that contains hexadecimal image of Value
-- Separate functions that provide build-time customization:
return;
end if;
- if Proc = "alpha" then
- Cur_Arch := DEC_ALPHA;
+ -- Let's detect a Linux or Windows host.
+ if Directory_Separator = '/' then
+ Cur_Arch := Architecture'Value ("linux_" & Proc);
else
- -- Let's detect the host.
- -- ??? A naive implementation that can't distinguish between Unixes
- if Directory_Separator = '/' then
- Cur_Arch := Architecture'Value ("solaris_" & Proc);
- else
- Cur_Arch := Architecture'Value ("windows_" & Proc);
- end if;
+ Cur_Arch := Architecture'Value ("windows_" & Proc);
end if;
if Arch_List (Cur_Arch).Addr2line_Binary = null then
-- Get_Reference_Offset --
--------------------------
- function Get_Reference_Offset return Unsigned_32 is
+ function Get_Reference_Offset return Unsigned_64 is
Nm_Cmd : constant String_Access :=
Locate_Exec_On_Path (Arch_List (Cur_Arch).Nm_Binary.all);
declare
Match_String : constant String := Expect_Out_Match (Pd);
Matches : Match_Array (0 .. 1);
- Value : Unsigned_32;
+ Value : Unsigned_64;
begin
Match (Reference, Match_String, Matches);
- Value := Unsigned_32'Value
+ Value := Unsigned_64'Value
("16#"
& Match_String (Matches (1).First .. Matches (1).Last) & "#");
-- Get_Value_From_Hex_Arg --
----------------------------
- function Get_Value_From_Hex_Arg (Arg : Natural) return Unsigned_32 is
+ function Get_Value_From_Hex_Arg (Arg : Natural) return Unsigned_64 is
Cur_Arg : constant String := Argument (Arg);
Offset : Natural;
-- Convert to value
- return Unsigned_32'Value
+ return Unsigned_64'Value
("16#" & Cur_Arg (Offset .. Cur_Arg'Last) & "#");
exception
-- Hex_Image --
---------------
- function Hex_Image (Value : Unsigned_32) return String_Access is
+ function Hex_Image (Value : Unsigned_64) return String_Access is
Result : String (1 .. 20);
Start_Pos : Natural;
begin
- Unsigned_32_IO.Put (Result, Value, 16);
+ Unsigned_64_IO.Put (Result, Value, 16);
Start_Pos := Index (Result, "16#") + 3;
return new String'(Result (Start_Pos .. Result'Last - 1));
end Hex_Image;
OS_Exit (1);
end Usage;
- Ref_Static_Offset, Ref_Runtime_Address, Bt_Address : Unsigned_32;
+ Ref_Static_Offset, Ref_Runtime_Address, Bt_Address : Unsigned_64;
Addr2line_Cmd : String_Access;