[cfe-commits] [libcxxabi] r147547 - in /libcxxabi/trunk/src: cxa_exception.cpp cxa_personality.cpp
Howard Hinnant
hhinnant at apple.com
Wed Jan 4 12:49:43 PST 2012
Author: hhinnant
Date: Wed Jan 4 14:49:43 2012
New Revision: 147547
URL: http://llvm.org/viewvc/llvm-project?rev=147547&view=rev
Log:
Just getting started on the personality routine. This is just a skeleton. Still learning how to fill it in...
Added:
libcxxabi/trunk/src/cxa_personality.cpp
Modified:
libcxxabi/trunk/src/cxa_exception.cpp
Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=147547&r1=147546&r2=147547&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Jan 4 14:49:43 2012
@@ -451,12 +451,6 @@
// If we return client will call terminate()
}
-_Unwind_Reason_Code
-__gxx_personality_v0(int version, _Unwind_Action actions, uint64_t exceptionClass,
- _Unwind_Exception* exceptionObject, _Unwind_Context* context)
-{
-}
-
} // extern "C"
} // abi
Added: libcxxabi/trunk/src/cxa_personality.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_personality.cpp?rev=147547&view=auto
==============================================================================
--- libcxxabi/trunk/src/cxa_personality.cpp (added)
+++ libcxxabi/trunk/src/cxa_personality.cpp Wed Jan 4 14:49:43 2012
@@ -0,0 +1,107 @@
+//===------------------------- cxa_exception.cpp --------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//
+// This file implements the "Exception Handling APIs"
+// http://www.codesourcery.com/public/cxx-abi/abi-eh.html
+//
+//===----------------------------------------------------------------------===//
+
+#include "unwind.h"
+
+namespace __cxxabiv1
+{
+
+extern "C"
+{
+
+// private API
+
+// Return true if there is a handler and false otherwise
+// cache handlerSwitchValue, actionRecord, languageSpecificData,
+// catchTemp and adjustedPtr here.
+static
+bool
+contains_handler(_Unwind_Exception* exceptionObject, _Unwind_Context* context)
+{
+}
+
+// return _URC_INSTALL_CONTEXT or _URC_FATAL_PHASE2_ERROR
+static
+_Unwind_Reason_Code
+transfer_control_to_landing_pad(_Unwind_Context* context)
+{
+}
+
+// return _URC_CONTINUE_UNWIND or _URC_FATAL_PHASE2_ERROR
+static
+_Unwind_Reason_Code
+perform_cleanup(_Unwind_Context* context)
+{
+}
+
+// public API
+
+// Requires: version == 1
+// actions == _UA_SEARCH_PHASE, or
+// == _UA_CLEANUP_PHASE, or
+// == _UA_CLEANUP_PHASE | _UA_HANDLER_FRAME, or
+// == _UA_CLEANUP_PHASE | _UA_FORCE_UNWIND
+// exceptionObject != nullptr
+// context != nullptr
+_Unwind_Reason_Code
+__gxx_personality_v0(int version, _Unwind_Action actions, uint64_t exceptionClass,
+ _Unwind_Exception* exceptionObject, _Unwind_Context* context)
+{
+ if (version == 1 && exceptionObject != 0 && context != 0)
+ {
+ bool native_exception = (exceptionClass & 0xFFF0) == 0x432B2B00;
+ bool force_unwind = actions & _UA_FORCE_UNWIND;
+ if (native_exception && !force_unwind)
+ {
+ if (actions & _UA_SEARCH_PHASE)
+ {
+ if (actions & _UA_CLEANUP_PHASE)
+ return _URC_FATAL_PHASE1_ERROR;
+ if (contains_handler(exceptionObject, context))
+ return _URC_HANDLER_FOUND
+ return _URC_CONTINUE_UNWIND;
+ }
+ if (actions & _UA_CLEANUP_PHASE)
+ {
+ if (actions & _UA_HANDLER_FRAME)
+ {
+ // return _URC_INSTALL_CONTEXT or _URC_FATAL_PHASE2_ERROR
+ return transfer_control_to_landing_pad(context);
+ }
+ // return _URC_CONTINUE_UNWIND or _URC_FATAL_PHASE2_ERROR
+ return perform_cleanup();
+ }
+ }
+ else // foreign exception or force_unwind
+ {
+ if (actions & _UA_SEARCH_PHASE)
+ {
+ if (actions & _UA_CLEANUP_PHASE)
+ return _URC_FATAL_PHASE1_ERROR;
+ return _URC_CONTINUE_UNWIND;
+ }
+ if (actions & _UA_CLEANUP_PHASE)
+ {
+ if (actions & _UA_HANDLER_FRAME)
+ return _URC_FATAL_PHASE2_ERROR;
+ // return _URC_CONTINUE_UNWIND or _URC_FATAL_PHASE2_ERROR
+ return perform_cleanup();
+ }
+ }
+ }
+ return _URC_FATAL_PHASE1_ERROR;
+}
+
+} // extern "C"
+
+} // __cxxabiv1
More information about the cfe-commits
mailing list