diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-21 18:38:03 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-21 18:38:03 +0000 |
commit | b52fde4185cd724f51aae4018b0f8278732379c7 (patch) | |
tree | 98834506f641740212914dc73ee20eb982bb16fe /lib/Support/CrashRecoveryContext.cpp | |
parent | 47f0f1856f189e9e0d9540bd3f82b26f77088a7d (diff) |
Provide a means for CrashRecovery clients to determine if code is currently running while crash recovery cleanups are being processed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CrashRecoveryContext.cpp')
-rw-r--r-- | lib/Support/CrashRecoveryContext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Support/CrashRecoveryContext.cpp b/lib/Support/CrashRecoveryContext.cpp index e558662611..899c3890d7 100644 --- a/lib/Support/CrashRecoveryContext.cpp +++ b/lib/Support/CrashRecoveryContext.cpp @@ -57,11 +57,15 @@ public: static sys::Mutex gCrashRecoveryContexMutex; static bool gCrashRecoveryEnabled = false; +static sys::ThreadLocal<const CrashRecoveryContextCleanup> + tlIsRecoveringFromCrash; + CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {} CrashRecoveryContext::~CrashRecoveryContext() { // Reclaim registered resources. CrashRecoveryContextCleanup *i = head; + tlIsRecoveringFromCrash.set(head); while (i) { CrashRecoveryContextCleanup *tmp = i; i = tmp->next; @@ -69,11 +73,16 @@ CrashRecoveryContext::~CrashRecoveryContext() { tmp->recoverResources(); delete tmp; } + tlIsRecoveringFromCrash.erase(); CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl; delete CRCI; } +bool CrashRecoveryContext::isRecoveringFromCrash() { + return tlIsRecoveringFromCrash.get() != 0; +} + CrashRecoveryContext *CrashRecoveryContext::GetCurrent() { if (!gCrashRecoveryEnabled) return 0; |