aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/CrashRecoveryContext.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-21 18:38:03 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-21 18:38:03 +0000
commitab1a242ead80c39f32fafc297263a22365aa203d (patch)
tree9ff0ce7f62501ecc5d18539acbeccad0823974a0 /llvm/lib/Support/CrashRecoveryContext.cpp
parent531d9f816fa13fbbae5d16bc4c29a313bc59dd56 (diff)
downloadllvm-ab1a242ead80c39f32fafc297263a22365aa203d.zip
llvm-ab1a242ead80c39f32fafc297263a22365aa203d.tar.gz
llvm-ab1a242ead80c39f32fafc297263a22365aa203d.tar.bz2
Provide a means for CrashRecovery clients to determine if code is currently running while crash recovery cleanups are being processed.
llvm-svn: 128008
Diffstat (limited to 'llvm/lib/Support/CrashRecoveryContext.cpp')
-rw-r--r--llvm/lib/Support/CrashRecoveryContext.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp
index e558662..899c389 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/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;