Re: [PATCH v3] ada: PR target/117538 Traceback includes load address if executable is PIE.

2024-12-18 Thread Simon Wright
On 18 Dec 2024, at 20:33, Eric Botcazou  wrote:
> 
>> Bootstrapped and regtested (ada onlyj) on x86_64-apple-darwin.
>> 
>> * gcc/ada/libgnat/s-trasym.adb: Returns the traceback in the required
>> form, using __gnat_get_executable_load_address to get the address
>> (or null, if not present).
>> 
>> 2024-12-17  Simon Wright   
>> 
>> gcc/ada/Changelog:
>> 
>> PR target/117538
>> * libgnat/s-trasym.adb: Returns the traceback, with the program load address
>> if available.
> 
> This is OK, thanks.  Do you want me to apply it?

Yes, thank you.

> 
> -- 
> Eric Botcazou
> 
> 



Re: [PATCH v3] ada: PR target/117538 Traceback includes load address if executable is PIE.

2024-12-18 Thread Eric Botcazou
> Bootstrapped and regtested (ada onlyj) on x86_64-apple-darwin.
> 
> * gcc/ada/libgnat/s-trasym.adb: Returns the traceback in the required
> form, using __gnat_get_executable_load_address to get the address
> (or null, if not present).
> 
> 2024-12-17  Simon Wright   
> 
> gcc/ada/Changelog:
> 
> PR target/117538
> * libgnat/s-trasym.adb: Returns the traceback, with the program load address
> if available.

This is OK, thanks.  Do you want me to apply it?

-- 
Eric Botcazou




[PATCH v3] ada: PR target/117538 Traceback includes load address if executable is PIE.

2024-12-17 Thread Simon Wright
If s-trasym.adb (System.Traceback.Symbolic, used as a renaming by
GNAT.Traceback.Symbolic) is given a traceback from a
position-independent executable, it does not include the executable's
load address in the report. This is necessary in order to decode the
traceback report.

This version of the patch is considerably simplified, as requested.

Bootstrapped and regtested (ada onlyj) on x86_64-apple-darwin.

* gcc/ada/libgnat/s-trasym.adb: Returns the traceback in the required
form, using __gnat_get_executable_load_address to get the address
(or null, if not present).

2024-12-17  Simon Wright   

gcc/ada/Changelog:

PR target/117538
* libgnat/s-trasym.adb: Returns the traceback, with the program load address 
if available.

—
diff --git a/gcc/ada/libgnat/s-trasym.adb b/gcc/ada/libgnat/s-trasym.adb
index 894fcf37ffd..a83d60f 100644
--- a/gcc/ada/libgnat/s-trasym.adb
+++ b/gcc/ada/libgnat/s-trasym.adb
@@ -69,7 +69,24 @@ package body System.Traceback.Symbolic is
 end loop;
   Result (Last) := ASCII.LF;
-return Result (1 .. Last);
+declare
+   function Executable_Load_Address return System.Address;
+   pragma Import
+ (C, Executable_Load_Address,
+  "__gnat_get_executable_load_address");
+
+   Load_Address : constant System.Address :=
+ Executable_Load_Address;
+begin
+   if Load_Address = System.Null_Address then
+  return Result (1 .. Last);
+   else
+  return "Load address: 0x"
+& System.Address_Image (Load_Address)
+  & ASCII.LF
+  & Result (1 .. Last);
+   end if;
+end;
  end;
   end if;
end Symbolic_Traceback;