llvm.org GIT mirror llvm / c0c815e
CrashRecovery: Make CrashRecoveryContext static methods thread safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111307 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
2 changed file(s) with 12 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
4646 CrashRecoveryContext() : Impl(0) {}
4747 ~CrashRecoveryContext();
4848
49 /// \brief Enable crash recovery. This function is not thread safe, clients
50 /// should call it during startup or with a lock held.
49 /// \brief Enable crash recovery.
5150 static void Enable();
5251
53 /// \brief Disable crash recovery. This function is not thread safe, clients
54 /// should call it during startup or with a lock held.
52 /// \brief Disable crash recovery.
5553 static void Disable();
5654
5755 /// \brief Execute the provide callback function (with the given arguments) in
99 #include "llvm/Support/CrashRecoveryContext.h"
1010 #include "llvm/ADT/SmallString.h"
1111 #include "llvm/Config/config.h"
12 #include "llvm/System/Mutex.h"
1213 #include "llvm/System/ThreadLocal.h"
1314 #include
1415 #include
4647
4748 }
4849
50 static sys::Mutex gCrashRecoveryContexMutex;
4951 static bool gCrashRecoveryEnabled = false;
5052
5153 CrashRecoveryContext::~CrashRecoveryContext() {
5860 // FIXME: No real Win32 implementation currently.
5961
6062 void CrashRecoveryContext::Enable() {
63 sys::ScopedLock L(gCrashRecoveryContexMutex);
64
6165 if (gCrashRecoveryEnabled)
6266 return;
6367
6569 }
6670
6771 void CrashRecoveryContext::Disable() {
72 sys::ScopedLock L(gCrashRecoveryContexMutex);
73
6874 if (!gCrashRecoveryEnabled)
6975 return;
7076
120126 }
121127
122128 void CrashRecoveryContext::Enable() {
129 sys::ScopedLock L(gCrashRecoveryContexMutex);
130
123131 if (gCrashRecoveryEnabled)
124132 return;
125133
137145 }
138146
139147 void CrashRecoveryContext::Disable() {
148 sys::ScopedLock L(gCrashRecoveryContexMutex);
149
140150 if (!gCrashRecoveryEnabled)
141151 return;
142152