This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ADA PATCH] Fix Unwind_Exception struct layout on 64-bit


Hello,

switching Ada to DWARF-2 exceptions on s390x caused hundreds of ACATS
failures; this turned out to be caused by a structure definition mismatch
between the Ada and the C side.

C defines

typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
struct _Unwind_Exception
{
  _Unwind_Exception_Class exception_class;
  _Unwind_Exception_Cleanup_Fn exception_cleanup;
  _Unwind_Word private_1;
  _Unwind_Word private_2;
};

while Ada defines

   type Unwind_Exception is record
      Class    : Exception_Class := GNAT_Exception_Class;
      Cleanup  : System.Address  := System.Null_Address;
      Private1 : Integer;
      Private2 : Integer;
   end record;

On 64-bit platforms this doesn't match: _Unwind_Word is 64 bits, 
while Integer is 32 bits.

The patch below attempt to fix this by defining an Unwind_Word
data type of size System.Word_Size, which should correspond to
the size of word_mode as far as I can see.

While debugging this, I noted that one of the printfs used
with EH_DEBUG debugging mode was incorrect; the patch fixes
this as well.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
OK?

Bye,
Ulrich


ChangeLog:

	* a-exexpr.adb (Unwind_Word): New data type.
	(Unwind_Exception): Use it as type of Private1 and Private2.

	* raise.c (db_action_for): Fix debug printf.


Index: gcc/ada/a-exexpr.adb
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/a-exexpr.adb,v
retrieving revision 1.2
diff -c -p -r1.2 a-exexpr.adb
*** gcc/ada/a-exexpr.adb	15 Mar 2004 14:50:55 -0000	1.2
--- gcc/ada/a-exexpr.adb	28 Apr 2004 00:05:22 -0000
*************** package body Exception_Propagation is
*** 102,112 ****
     GNAT_Exception_Class : constant Exception_Class := 16#474e552d41646100#;
     --  "GNU-Ada\0"
  
     type Unwind_Exception is record
        Class    : Exception_Class := GNAT_Exception_Class;
        Cleanup  : System.Address  := System.Null_Address;
!       Private1 : Integer;
!       Private2 : Integer;
     end record;
  
     pragma Convention (C, Unwind_Exception);
--- 102,115 ----
     GNAT_Exception_Class : constant Exception_Class := 16#474e552d41646100#;
     --  "GNU-Ada\0"
  
+    type Unwind_Word is mod 2**System.Word_Size;
+    for Unwind_Word'Size use System.Word_Size;
+ 
     type Unwind_Exception is record
        Class    : Exception_Class := GNAT_Exception_Class;
        Cleanup  : System.Address  := System.Null_Address;
!       Private1 : Unwind_Word;
!       Private2 : Unwind_Word;
     end record;
  
     pragma Convention (C, Unwind_Exception);
Index: gcc/ada/raise.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/raise.c,v
retrieving revision 1.12
diff -c -p -r1.12 raise.c
*** gcc/ada/raise.c	15 Mar 2004 14:50:59 -0000	1.12
--- gcc/ada/raise.c	28 Apr 2004 00:05:23 -0000
*************** db_action_for (action_descriptor *action
*** 671,677 ****
       {
       case unknown:
         db (DB_ACTIONS, "lpad @ 0x%x, record @ 0x%x\n",
! 	   ip, action->landing_pad, action->table_entry);
         break;
  
       case nothing:
--- 671,677 ----
       {
       case unknown:
         db (DB_ACTIONS, "lpad @ 0x%x, record @ 0x%x\n",
! 	   action->landing_pad, action->table_entry);
         break;
  
       case nothing:
-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]