summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/PrettyStackTrace.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-08-07 17:47:03 +0000
committerNico Weber <nicolasweber@gmx.de>2015-08-07 17:47:03 +0000
commitaf3f242016130387f45798b165399bfcaa7ca0b8 (patch)
tree3ebf882eb7dc602a9e4861c7042a3d1a21e7a628 /llvm/lib/Support/PrettyStackTrace.cpp
parent2692811d00284bae0d8e346b59b7ef410292f8d0 (diff)
downloadbcm5719-llvm-af3f242016130387f45798b165399bfcaa7ca0b8.tar.gz
bcm5719-llvm-af3f242016130387f45798b165399bfcaa7ca0b8.zip
Add functions to save and restore the PrettyStackTrace state.
PrettyStackTraceHead is a LLVM_THREAD_LOCAL, which means it's just a global in LLVM_ENABLE_THREADS=NO builds. If a CrashRecoveryContext is used with code that uses PrettyStackEntries, and a crash happens, PrettyStackTraceHead is currently not reset to its pre-crash value. These functions make it possible to add a cleanup to such code that does this. (Not reseting the value then causes the assert in ~PrettyStackTraceEntry() to fire if the code outside of the CrashRecoveryContext also uses PrettyStackEntries -- for example, clang when building a module.) Part of PR11974. llvm-svn: 244338
Diffstat (limited to 'llvm/lib/Support/PrettyStackTrace.cpp')
-rw-r--r--llvm/lib/Support/PrettyStackTrace.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Support/PrettyStackTrace.cpp b/llvm/lib/Support/PrettyStackTrace.cpp
index f9f8cab9d93..d6782a70e1a 100644
--- a/llvm/lib/Support/PrettyStackTrace.cpp
+++ b/llvm/lib/Support/PrettyStackTrace.cpp
@@ -154,6 +154,20 @@ void llvm::EnablePrettyStackTrace() {
#endif
}
+const void* llvm::SavePrettyStackState() {
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
+ return PrettyStackTraceHead;
+#else
+ return nullptr;
+#endif
+}
+
+void llvm::RestorePrettyStackState(const void* Top) {
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
+ PrettyStackTraceHead = (const PrettyStackTraceEntry*)Top;
+#endif
+}
+
void LLVMEnablePrettyStackTrace() {
EnablePrettyStackTrace();
}
OpenPOWER on IntegriCloud