https://gcc.gnu.org/g:d9b76deb580eb4fc5046d6c0263f420acaa444c9

commit r15-4147-gd9b76deb580eb4fc5046d6c0263f420acaa444c9
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Fri Sep 6 10:05:58 2024 +0200

    ada: Print the load address in symbolic backtraces
    
    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.

Diff:
---
 gcc/ada/libgnat/s-trasym__dwarf.adb | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/libgnat/s-trasym__dwarf.adb 
b/gcc/ada/libgnat/s-trasym__dwarf.adb
index 1b3680407280..6182316da554 100644
--- a/gcc/ada/libgnat/s-trasym__dwarf.adb
+++ b/gcc/ada/libgnat/s-trasym__dwarf.adb
@@ -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;

Reply via email to