]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Print the load address in symbolic backtraces
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 6 Sep 2024 08:05:58 +0000 (10:05 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 8 Oct 2024 08:37:12 +0000 (10:37 +0200)
The load address of PIE executables is printed in non-symbolic backtraces
(-E binder switch) but it makes sense to print it in symbolic backtraces
(-Es binder switch) too, because symbolic backtraces may degenerate into
non-symbolic ones when the executable is stripped for example.

gcc/ada/ChangeLog:
* libgnat/s-trasym__dwarf.adb (LDAD_Header): New String constant.
(Symbolic_Traceback): Print the load address of the executable at
the beginning if it is not null.

gcc/ada/libgnat/s-trasym__dwarf.adb

index 1b3680407280bd5bb2748029f161b30d4aedebfa..6182316da5543a238b9515229c405fc212b97f52 100644 (file)
@@ -637,14 +637,24 @@ package body System.Traceback.Symbolic is
    -- Symbolic_Traceback --
    ------------------------
 
+   LDAD_Header : constant String := "Load address: ";
+   --  Copied from Ada.Exceptions.Exception_Data
+
    function Symbolic_Traceback
      (Traceback    : Tracebacks_Array;
       Suppress_Hex : Boolean) return String
    is
-      Res : Bounded_String (Max_Length => Max_String_Length);
+      Load_Address : constant Address := Get_Executable_Load_Address;
+      Res          : Bounded_String (Max_Length => Max_String_Length);
+
    begin
       System.Soft_Links.Lock_Task.all;
       Init_Exec_Module;
+      if Load_Address /= Null_Address then
+         Append (Res, LDAD_Header);
+         Append_Address (Res, Load_Address);
+         Append (Res, ASCII.LF);
+      end if;
       Symbolic_Traceback_No_Lock (Traceback, Suppress_Hex, Res);
       System.Soft_Links.Unlock_Task.all;