summaryrefslogtreecommitdiff
path: root/libcxxabi/src
diff options
context:
space:
mode:
authorMuiez Ahmed <muiez@ibm.com>2022-06-28 20:59:49 +0300
committerMuiez Ahmed <muiez@ibm.com>2022-06-28 21:01:25 +0300
commit85593e7bb5a8bfde80aaf4eb4e15f982aebe2282 (patch)
tree8e09941861f51d7cb6b80f898d9fdcd94e2e0192 /libcxxabi/src
parentcfd474e0d036877ee6c83d236df71aa8fe0729bf (diff)
downloadllvm-85593e7bb5a8bfde80aaf4eb4e15f982aebe2282.tar.gz
[SystemZ][z/OS] Modify cxxabi to be compatible with existing z/OS runtime
This patch is to enable exception handling on the z/OS platform that is compatible with the existing z/OS runtime. No functionality of libcxxabi has been changed for other platforms. With this patch the hope is we can add z/OS as a platform to perform testing on any C++ ABI changes. There is a primary difference for the z/OS implementation. On z/OS the thrown object is added to a linked list of caught and uncaught exceptions. The unwinder uses the top one as the current exception it is trying to find the landing pad for. We have to pop the top exception after we get it’s landing pad for our unwinder to correctly get any subsequent rethrows or nested exception calls. Differential Revision: https://reviews.llvm.org/D99913
Diffstat (limited to 'libcxxabi/src')
-rw-r--r--libcxxabi/src/cxa_exception.cpp8
-rw-r--r--libcxxabi/src/cxa_personality.cpp6
2 files changed, 12 insertions, 2 deletions
diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp
index b17c79eea303..9cb2bf888811 100644
--- a/libcxxabi/src/cxa_exception.cpp
+++ b/libcxxabi/src/cxa_exception.cpp
@@ -444,6 +444,14 @@ __cxa_begin_catch(void* unwind_arg) throw()
(
static_cast<_Unwind_Exception*>(unwind_exception)
);
+
+#if defined(__MVS__)
+ // Remove the exception object from the linked list of exceptions that the z/OS unwinder
+ // maintains before adding it to the libc++abi list of caught exceptions.
+ // The libc++abi will manage the lifetime of the exception from this point forward.
+ _UnwindZOS_PopException();
+#endif
+
if (native_exception)
{
// Increment the handler count, removing the flag about being rethrown
diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp
index f58d4de774e1..b28c58df6a2f 100644
--- a/libcxxabi/src/cxa_personality.cpp
+++ b/libcxxabi/src/cxa_personality.cpp
@@ -622,7 +622,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
results.reason = _URC_FATAL_PHASE1_ERROR;
return;
}
- // Start scan by getting exception table address
+ // Start scan by getting exception table address.
const uint8_t *lsda = (const uint8_t *)_Unwind_GetLanguageSpecificData(context);
if (lsda == 0)
{
@@ -912,6 +912,8 @@ static _Unwind_Reason_Code __gxx_personality_imp
_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
#ifdef __USING_SJLJ_EXCEPTIONS__
__gxx_personality_sj0
+#elif defined(__MVS__)
+__zos_cxx_personality_v2
#else
__gxx_personality_v0
#endif
@@ -1121,7 +1123,7 @@ __gxx_personality_v0(_Unwind_State state,
}
// Either we didn't do a phase 1 search (due to forced unwinding), or
- // phase 1 reported no catching-handlers.
+ // phase 1 reported no catching-handlers.
// Search for a (non-catching) cleanup
if (is_force_unwinding)
scan_eh_tab(