Fix g++.dg/abi/forced.C for ARM EABI

Joseph S. Myers joseph@codesourcery.com
Mon Jul 7 15:08:00 GMT 2008


This patch fixes

FAIL: g++.dg/abi/forced.C execution test

for arm-none-linux-gnueabi.  The problem was communicating that a
forced unwind is underway to __cxa_type_match so that it can match
against the right type (so resolving the "XXX What to do with forced
unwind?" comment); the solution I used was to fill in the exception
class header for a forced unwind to communicate this information.

Tested with no regressions with cross to arm-none-linux-gnueabi.  OK
to commit?

2008-07-07  Joseph Myers  <joseph@codesourcery.com>

	* libsupc++/unwind-cxx.h (__is_gxx_forced_unwind_class,
	__GXX_INIT_FORCED_UNWIND_CLASS): Define for ARM EABI unwinder.
	* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Call
	__GXX_INIT_FORCED_UNWIND_CLASS for forced unwind with ARM EABI
	unwinder.
	* libsupc++/eh_arm.cc (__cxa_type_match): Use
	__is_gxx_forced_unwind_class to check for forced unwind.

Index: libstdc++-v3/libsupc++/eh_arm.cc
===================================================================
--- libstdc++-v3/libsupc++/eh_arm.cc	(revision 137291)
+++ libstdc++-v3/libsupc++/eh_arm.cc	(working copy)
@@ -46,12 +46,14 @@
 		 bool is_reference __attribute__((__unused__)),
 		 void** thrown_ptr_p)
 {
-  bool foreign_exception = !__is_gxx_exception_class(ue_header->exception_class);
+  bool forced_unwind = __is_gxx_forced_unwind_class(ue_header->exception_class);
+  bool foreign_exception = !forced_unwind && !__is_gxx_exception_class(ue_header->exception_class);
   __cxa_exception* xh = __get_exception_header_from_ue(ue_header);
   const std::type_info* throw_type;
 
-  // XXX What to do with forced unwind?
-  if (foreign_exception)
+  if (forced_unwind)
+    throw_type = &typeid(abi::__forced_unwind);
+  else if (foreign_exception)
     throw_type = &typeid(abi::__foreign_exception);
   else
     throw_type = xh->exceptionType;
Index: libstdc++-v3/libsupc++/unwind-cxx.h
===================================================================
--- libstdc++-v3/libsupc++/unwind-cxx.h	(revision 137291)
+++ libstdc++-v3/libsupc++/unwind-cxx.h	(working copy)
@@ -201,6 +201,32 @@
   c[7] = '\0';
 }
 
+static inline bool
+__is_gxx_forced_unwind_class(_Unwind_Exception_Class c)
+{
+  return c[0] == 'G'
+	 && c[1] == 'N'
+	 && c[2] == 'U'
+	 && c[3] == 'C'
+	 && c[4] == 'F'
+	 && c[5] == 'O'
+	 && c[6] == 'R'
+	 && c[7] == '\0';
+}
+
+static inline void
+__GXX_INIT_FORCED_UNWIND_CLASS(_Unwind_Exception_Class c)
+{
+  c[0] = 'G';
+  c[1] = 'N';
+  c[2] = 'U';
+  c[3] = 'C';
+  c[4] = 'F';
+  c[5] = 'O';
+  c[6] = 'R';
+  c[7] = '\0';
+}
+
 static inline void*
 __gxx_caught_object(_Unwind_Exception* eo)
 {
Index: libstdc++-v3/libsupc++/eh_personality.cc
===================================================================
--- libstdc++-v3/libsupc++/eh_personality.cc	(revision 137291)
+++ libstdc++-v3/libsupc++/eh_personality.cc	(working copy)
@@ -544,8 +544,12 @@
 
 #ifdef __ARM_EABI_UNWINDER__
       throw_type = ue_header;
-      if ((actions & _UA_FORCE_UNWIND)
-	  || foreign_exception)
+      if (actions & _UA_FORCE_UNWIND)
+	{
+	  __GXX_INIT_FORCED_UNWIND_CLASS(ue_header->exception_class);
+	  thrown_ptr = 0;
+	}
+      else if (foreign_exception)
 	thrown_ptr = 0;
 #else
       // During forced unwinding, match a magic exception type.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list