CrashRecoveryContext() : Impl(0) {}
~CrashRecoveryContext();
- /// \brief Enable crash recovery. This function is not thread safe, clients
- /// should call it during startup or with a lock held.
+ /// \brief Enable crash recovery.
static void Enable();
- /// \brief Disable crash recovery. This function is not thread safe, clients
- /// should call it during startup or with a lock held.
+ /// \brief Disable crash recovery.
static void Disable();
+ /// \brief Return the active context, if the code is currently executing in a
+ /// thread which is in a protected context.
+ static CrashRecoveryContext *GetCurrent();
+
/// \brief Execute the provide callback function (with the given arguments) in
/// a protected context.
///
/// the backtrace of the crash on failures.
bool RunSafely(void (*Fn)(void*), void *UserData);
+ /// \brief Execute the provide callback function (with the given arguments) in
+ /// a protected context which is run in another thread (optionally with a
+ /// requested stack size).
+ ///
+ /// See RunSafely() and llvm_execute_on_thread().
+ bool RunSafelyOnThread(void (*Fn)(void*), void *UserData,
+ unsigned RequestedStackSize = 0);
+
/// \brief Explicitly trigger a crash recovery in the current process, and
/// return failure from RunSafely(). This function does not return.
void HandleCrash();