llvm.org GIT mirror llvm / b52fde4
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 Ted Kremenek 9 years ago
2 changed file(s) with 13 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6161 /// \brief Return the active context, if the code is currently executing in a
6262 /// thread which is in a protected context.
6363 static CrashRecoveryContext *GetCurrent();
64
65 /// \brief Return true if the current thread is recovering from a
66 /// crash.
67 static bool isRecoveringFromCrash();
6468
6569 /// \brief Execute the provide callback function (with the given arguments) in
6670 /// a protected context.
5656 static sys::Mutex gCrashRecoveryContexMutex;
5757 static bool gCrashRecoveryEnabled = false;
5858
59 static sys::ThreadLocal
60 tlIsRecoveringFromCrash;
61
5962 CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
6063
6164 CrashRecoveryContext::~CrashRecoveryContext() {
6265 // Reclaim registered resources.
6366 CrashRecoveryContextCleanup *i = head;
67 tlIsRecoveringFromCrash.set(head);
6468 while (i) {
6569 CrashRecoveryContextCleanup *tmp = i;
6670 i = tmp->next;
6872 tmp->recoverResources();
6973 delete tmp;
7074 }
75 tlIsRecoveringFromCrash.erase();
7176
7277 CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl;
7378 delete CRCI;
79 }
80
81 bool CrashRecoveryContext::isRecoveringFromCrash() {
82 return tlIsRecoveringFromCrash.get() != 0;
7483 }
7584
7685 CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {