aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/CrashRecoveryContext.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-11-05 07:19:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-11-05 07:19:09 +0000
commitf8254d647352f8f194b4753a25d582758289e497 (patch)
tree588bb4af761100cb8dc79745ea8400695f4c6360 /lib/Support/CrashRecoveryContext.cpp
parent1e92ec688624d17b552c88afc956f61da4948cbb (diff)
CrashRecoveryContext: Add RunSafelyOnThread helper function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CrashRecoveryContext.cpp')
-rw-r--r--lib/Support/CrashRecoveryContext.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Support/CrashRecoveryContext.cpp b/lib/Support/CrashRecoveryContext.cpp
index 93af79bc0f..f24d6bdad8 100644
--- a/lib/Support/CrashRecoveryContext.cpp
+++ b/lib/Support/CrashRecoveryContext.cpp
@@ -205,3 +205,26 @@ const std::string &CrashRecoveryContext::getBacktrace() const {
assert(CRC->Failed && "No crash was detected!");
return CRC->Backtrace;
}
+
+//
+
+namespace {
+struct RunSafelyOnThreadInfo {
+ void (*UserFn)(void*);
+ void *UserData;
+ CrashRecoveryContext *CRC;
+ bool Result;
+};
+}
+
+static void RunSafelyOnThread_Dispatch(void *UserData) {
+ RunSafelyOnThreadInfo *Info =
+ reinterpret_cast<RunSafelyOnThreadInfo*>(UserData);
+ Info->Result = Info->CRC->RunSafely(Info->UserFn, Info->UserData);
+}
+bool CrashRecoveryContext::RunSafelyOnThread(void (*Fn)(void*), void *UserData,
+ unsigned RequestedStackSize) {
+ RunSafelyOnThreadInfo Info = { Fn, UserData, this, false };
+ llvm_execute_on_thread(RunSafelyOnThread_Dispatch, &Info, RequestedStackSize);
+ return Info.Result;
+}