summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CrashRecoveryContext.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-08-17 22:32:37 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-08-17 22:32:37 +0000
commitb30266ed205edf64b990c5cda85b8336939e40d9 (patch)
treed79a11e9a382c668f48d8120ca0cf1ce22bfae48 /llvm/lib/Support/CrashRecoveryContext.cpp
parentff329942cd7af409e923c55f34c646736b0c275f (diff)
downloadbcm5719-llvm-b30266ed205edf64b990c5cda85b8336939e40d9.tar.gz
bcm5719-llvm-b30266ed205edf64b990c5cda85b8336939e40d9.zip
CrashRecovery: Add CrashRecoveryContext::GetCurrent(), so clients can find the active context from anywhere.
llvm-svn: 111308
Diffstat (limited to 'llvm/lib/Support/CrashRecoveryContext.cpp')
-rw-r--r--llvm/lib/Support/CrashRecoveryContext.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp
index d1ecbb74dac..296cc3e8f3b 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -23,12 +23,14 @@ struct CrashRecoveryContextImpl;
static sys::ThreadLocal<const CrashRecoveryContextImpl> CurrentContext;
struct CrashRecoveryContextImpl {
+ CrashRecoveryContext *CRC;
std::string Backtrace;
::jmp_buf JumpBuffer;
volatile unsigned Failed : 1;
public:
- CrashRecoveryContextImpl() : Failed(false) {
+ CrashRecoveryContextImpl(CrashRecoveryContext *CRC) : CRC(CRC),
+ Failed(false) {
CurrentContext.set(this);
}
~CrashRecoveryContextImpl() {
@@ -56,6 +58,14 @@ CrashRecoveryContext::~CrashRecoveryContext() {
delete CRCI;
}
+CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
+ const CrashRecoveryContextImpl *CRCI = CurrentContext.get();
+ if (!CRCI)
+ return 0;
+
+ return CRCI->CRC;
+}
+
#ifdef LLVM_ON_WIN32
// FIXME: No real Win32 implementation currently.
@@ -164,7 +174,7 @@ bool CrashRecoveryContext::RunSafely(void (*Fn)(void*), void *UserData) {
// If crash recovery is disabled, do nothing.
if (gCrashRecoveryEnabled) {
assert(!Impl && "Crash recovery context already initialized!");
- CrashRecoveryContextImpl *CRCI = new CrashRecoveryContextImpl;
+ CrashRecoveryContextImpl *CRCI = new CrashRecoveryContextImpl(this);
Impl = CRCI;
if (setjmp(CRCI->JumpBuffer) != 0) {
OpenPOWER on IntegriCloud