10 #ifndef LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H
11 #define LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H
18 class CrashRecoveryContextCleanup;
78 bool RunSafely(
void (*Fn)(
void*),
void *UserData);
86 unsigned RequestedStackSize = 0);
120 template<
typename DERIVED,
typename T>
130 return new DERIVED(
context, x);
136 template <
typename T>
150 template <
typename T>
163 template <
typename T>
171 T>(context, resource) {}
178 template <
typename T,
typename Cleanup = CrashRecoveryContextDeleteCleanup<T> >
183 : cleanup(Cleanup::create(x)) {
static CrashRecoveryContext * GetCurrent()
Return the active context, if the code is currently executing in a thread which is in a protected con...
bool RunSafelyOnThread(void(*Fn)(void *), void *UserData, unsigned RequestedStackSize=0)
Execute the provide callback function (with the given arguments) in a protected context which is run ...
~CrashRecoveryContextCleanupRegistrar()
virtual void recoverResources()
void HandleCrash()
Explicitly trigger a crash recovery in the current process, and return failure from RunSafely()...
CrashRecoveryContextDeleteCleanup(CrashRecoveryContext *context, T *resource)
const std::string & getBacktrace() const
Return a string containing the backtrace where the crash was detected; or empty if the backtrace wasn...
void unregisterCleanup(CrashRecoveryContextCleanup *cleanup)
virtual ~CrashRecoveryContextCleanup()
static void Enable()
Enable crash recovery.
virtual void recoverResources()
CrashRecoveryContextCleanup(CrashRecoveryContext *context)
ItTy next(ItTy it, Dist n)
void registerCleanup(CrashRecoveryContextCleanup *cleanup)
static DERIVED * create(T *x)
CrashRecoveryContextReleaseRefCleanup(CrashRecoveryContext *context, T *resource)
virtual void recoverResources()=0
CrashRecoveryContext * context
bool RunSafely(void(*Fn)(void *), void *UserData)
Execute the provide callback function (with the given arguments) in a protected context.
Crash recovery helper object.
CrashRecoveryContext * getContext() const
virtual void recoverResources()
CrashRecoveryContextCleanupBase(CrashRecoveryContext *context, T *resource)
static bool isRecoveringFromCrash()
Return true if the current thread is recovering from a crash.
CrashRecoveryContextCleanupRegistrar(T *x)
static void Disable()
Disable crash recovery.
CrashRecoveryContextDestructorCleanup(CrashRecoveryContext *context, T *resource)