Crash recovery helper object.
Synopsis
Declared in <llvm/Support/CrashRecoveryContext.h>
class CrashRecoveryContext;
Description
This class implements support for running operations in a safe context so that crashes (memory errors, stack overflow, assertion violations) can be detected and control restored to the crashing thread. Crash detection is purely "best effort", the exact set of failures which can be recovered from is platform dependent.
Clients make use of this code by first calling CrashRecoveryContext::Enable(), and then executing unsafe operations via a CrashRecoveryContext object. For example:
void actual_work(void *);
void foo() {
CrashRecoveryContext CRC;
if (!CRC.RunSafely(actual_work, 0)) {
... a crash was detected, report error to user ...
}
... no crash was detected ...
}
To assist recovery the class allows specifying set of actions that will be executed in any case, whether crash occurs or not. These actions may be used to reclaim resources in the case of crash.
Member Functions
Name |
Description |
|
Create a crash recovery context. |
|
Destroy the crash recovery context and run remaining cleanups. |
|
Explicitly trigger a crash recovery in the current process, and return failure from RunSafely(). This function does not return. |
Execute the provided callback function (with the given arguments) in a protected context. |
|
Execute the provided callback on another thread with an optional stack size, equivalent to |
|
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). |
|
Register cleanup handler, which is used when the recovery context is finished. The recovery context owns the handler. |
|
Unregister a previously registered cleanup handler. |
Static Member Functions
Name |
Description |
Disable crash recovery. |
|
Enable crash recovery. |
|
Return the active context, if the code is currently executing in a thread which is in a protected context. |
|
Return true if RetCode indicates that a signal or an exception occurred. |
|
Return true if the current thread is recovering from a crash. |
|
Throw again a signal or an exception, after it was catched once by a CrashRecoveryContext. |
Data Members
Name |
Description |
Whether failures are handled like regular crashes. |
|
In case of a crash, this is the crash identifier. |
Created with MrDocs