Go to the documentation of this file.
9 #ifndef LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H
10 #define LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H
15 class CrashRecoveryContextCleanup;
83 return RunSafely([&]() { Fn(UserData); });
96 unsigned RequestedStackSize = 0) {
159 template<
typename Derived,
typename T>
181 template <
typename T>
196 template <
typename T>
208 template <
typename T>
251 template <
typename T,
typename Cleanup = CrashRecoveryContextDeleteCleanup<T> >
272 #endif // LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H
static void Enable()
Enable crash recovery.
void recoverResources() override
This is an optimization pass for GlobalISel generic memory operations.
void recoverResources() override
static bool throwIfCrash(int RetCode)
Throw again a signal or an exception, after it was catched once by a CrashRecoveryContext.
CrashRecoveryContextDestructorCleanup(CrashRecoveryContext *context, T *resource)
CrashRecoveryContext * getContext() const
bool RunSafely(void(*Fn)(void *), void *UserData)
~CrashRecoveryContextCleanupRegistrar()
Cleanup handler that reclaims resource by calling destructor on it.
CrashRecoveryContextCleanupBase(CrashRecoveryContext *context, T *resource)
int RetCode
In case of a crash, this is the crash identifier.
Base class of cleanup handler that controls recovery of resources of the given type.
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
void registerCleanup(CrashRecoveryContextCleanup *cleanup)
Register cleanup handler, which is used when the recovery context is finished.
bool RunSafelyOnThread(function_ref< void()>, unsigned RequestedStackSize=0)
Execute the provide callback function (with the given arguments) in a protected context which is run ...
virtual void recoverResources()=0
CrashRecoveryContextDeleteCleanup(CrashRecoveryContext *context, T *resource)
bool RunSafely(function_ref< void()> Fn)
Execute the provided callback function (with the given arguments) in a protected context.
static void Disable()
Disable crash recovery.
static bool isRecoveringFromCrash()
Return true if the current thread is recovering from a crash.
CrashRecoveryContextCleanup(CrashRecoveryContext *context)
bool DumpStackAndCleanupOnFailure
Selects whether handling of failures should be done in the same way as for regular crashes.
An efficient, type-erasing, non-owning reference to a callable.
Abstract base class of cleanup handlers.
Cleanup handler that reclaims resource by calling its method 'Release'.
CrashRecoveryContextReleaseRefCleanup(CrashRecoveryContext *context, T *resource)
static const HTTPClientCleanup Cleanup
static CrashRecoveryContext * GetCurrent()
Return the active context, if the code is currently executing in a thread which is in a protected con...
static Derived * create(T *x)
Creates cleanup handler.
void HandleExit(int RetCode)
Explicitly trigger a crash recovery in the current process, and return failure from RunSafely().
CrashRecoveryContextCleanupRegistrar(T *x)
static bool isCrash(int RetCode)
Return true if RetCode indicates that a signal or an exception occurred.
Cleanup handler that reclaims resource by calling 'delete' on it.
Helper class for managing resource cleanups.
void unregisterCleanup(CrashRecoveryContextCleanup *cleanup)
virtual ~CrashRecoveryContextCleanup()
Crash recovery helper object.
bool RunSafelyOnThread(void(*Fn)(void *), void *UserData, unsigned RequestedStackSize=0)
void recoverResources() override
CrashRecoveryContext * context