aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/CrashRecoveryContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/CrashRecoveryContext.cpp')
-rw-r--r--llvm/lib/Support/CrashRecoveryContext.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp
index e96a9b59d834..f53aea177d61 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -431,7 +431,10 @@ bool CrashRecoveryContext::RunSafely(function_ref<void()> Fn) {
[[noreturn]] void CrashRecoveryContext::HandleExit(int RetCode) {
#if defined(_WIN32)
- // SEH and VEH
+ // Since the exception code is actually of NTSTATUS type, we use the
+ // Microsoft-recommended 0xE prefix, to signify that this is a user error.
+ // This value is a combination of the customer field (bit 29) and severity
+ // field (bits 30-31) in the NTSTATUS specification.
::RaiseException(0xE0000000 | RetCode, 0, 0, NULL);
#else
// On Unix we don't need to raise an exception, we go directly to
@@ -445,10 +448,10 @@ bool CrashRecoveryContext::RunSafely(function_ref<void()> Fn) {
bool CrashRecoveryContext::isCrash(int RetCode) {
#if defined(_WIN32)
- // On Windows, the high bits are reserved for kernel return codes. Values
- // starting with 0x80000000 are reserved for "warnings"; values of 0xC0000000
- // and up are for "errors". In practice, both are interpreted as a
- // non-continuable signal.
+ // On Windows, the code is interpreted as NTSTATUS. The two high bits
+ // represent the severity. Values starting with 0x80000000 are reserved for
+ // "warnings"; values of 0xC0000000 and up are for "errors". In practice, both
+ // are interpreted as a non-continuable signal.
unsigned Code = ((unsigned)RetCode & 0xF0000000) >> 28;
if (Code != 0xC && Code != 8)
return false;