From ab1a242ead80c39f32fafc297263a22365aa203d Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 21 Mar 2011 18:38:03 +0000 Subject: Provide a means for CrashRecovery clients to determine if code is currently running while crash recovery cleanups are being processed. llvm-svn: 128008 --- llvm/lib/Support/CrashRecoveryContext.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Support/CrashRecoveryContext.cpp') diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp index e558662611f..899c3890d78 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 + 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; -- cgit v1.2.3