Fix a non-compliance with the unwind ABI.
No pure Ada testcase.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-30  Tristan Gingold  <ging...@adacore.com>

        * raise-gcc.c: Never catch exception if _UA_FORCE_UNWIND flag is set,
        to be compliant with the ABI.

Index: raise-gcc.c
===================================================================
--- raise-gcc.c (revision 178293)
+++ raise-gcc.c (working copy)
@@ -217,7 +217,7 @@
 static void
 db_phases (int phases)
 {
-  phase_descriptor *a = phase_descriptors;
+  const phase_descriptor *a = phase_descriptors;
 
   if (! (db_accepted_codes() & DB_PHASES))
     return;
@@ -901,6 +901,7 @@
 static void
 get_action_description_for (_Unwind_Context *uw_context,
                             _Unwind_Exception *uw_exception,
+                            _Unwind_Action uw_phase,
                             region_descriptor *region,
                             action_descriptor *action)
 {
@@ -965,17 +966,22 @@
          /* Positive filters are for regular handlers.  */
          else if (ar_filter > 0)
            {
-             /* See if the filter we have is for an exception which matches
-                the one we are propagating.  */
-             _Unwind_Ptr choice = get_ttype_entry_for (region, ar_filter);
+              /* Do not catch an exception if the _UA_FORCE_UNWIND flag is
+                 passed (to follow the ABI).  */
+              if (!(uw_phase & _UA_FORCE_UNWIND))
+                {
+                  /* See if the filter we have is for an exception which
+                     matches the one we are propagating.  */
+                  _Unwind_Ptr choice = get_ttype_entry_for (region, ar_filter);
 
-             if (is_handled_by (choice, gnat_exception))
-               {
-                 action->kind = handler;
-                 action->ttype_filter = ar_filter;
-                 action->ttype_entry = choice;
-                 return;
-               }
+                  if (is_handled_by (choice, gnat_exception))
+                    {
+                      action->kind = handler;
+                      action->ttype_filter = ar_filter;
+                      action->ttype_entry = choice;
+                      return;
+                    }
+                }
            }
 
          /* Negative filter values are for C++ exception specifications.
@@ -1128,7 +1134,8 @@
 
   /* Search the call-site and action-record tables for the action associated
      with this IP.  */
-  get_action_description_for (uw_context, uw_exception, &region, &action);
+  get_action_description_for (uw_context, uw_exception, uw_phases,
+                              &region, &action);
   db_action_for (&action, uw_context);
 
   /* Whatever the phase, if there is nothing relevant in this frame,

Reply via email to