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   <si...@pushface.org>

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..a83d688880f 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;



Reply via email to