https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117538

            Bug ID: 117538
           Summary: Tracebacks don’t include the load address of PIE
                    executables
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon at pushface dot org
  Target Milestone: ---

MacOS can only create position-independent executables (PIE). Other OSs may 
be able to.

When an unhandled exception occurs, the traceback report includes the load 
address, which is necessary in order to decode the error. On the other hand,
the
report output by GNAT.Traceback.Symbolic (a renaming of
System.Traceback.Symbolic)
doesn’t, as this test program shows:

with Ada.Exceptions;
with Ada.Exceptions.Traceback;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Traceback.Symbolic;
procedure Traceback is
begin
   raise Constraint_Error;
exception
   when E : others =>
      Put_Line ("--- Ada.Exceptions.Exception_Information ---");
      Put_Line (Ada.Exceptions.Exception_Information (E));
      Put_Line ("--- GNAT.Traceback.Symbolic.Symbolic_Traceback ---");
      Put_Line
        (GNAT.Traceback.Symbolic.Symbolic_Traceback
           (Ada.Exceptions.Traceback.Tracebacks (E)));
end Traceback;

$ ./traceback 
--- Ada.Exceptions.Exception_Information ---
raised CONSTRAINT_ERROR : traceback.adb:7 explicit raise
Load address: 0x1045e4000
Call stack traceback locations:
0x1045e5dcd 0x1045e5d41

--- GNAT.Traceback.Symbolic.Symbolic_Traceback ---
0x00000001045E5DCD 0x00000001045E5D41

I have a patch for this, which I’ll post to gcc-patches.

With the patch (on a different run, of course, so the addresses are 
different), the output is

--- Ada.Exceptions.Exception_Information ---
raised CONSTRAINT_ERROR : traceback.adb:7 explicit raise
Load address: 0x10ff88000
Call stack traceback locations:
0x10ff8ab0f 0x10ff8b267

--- GNAT.Traceback.Symbolic.Symbolic_Traceback ---
Load address: 0x10FF88000
0x10FF8AB0F 0x10FF8B267

Further tests at https://github.com/simonjwright/traceback .

Reply via email to