Add functions to save and restore the PrettyStackTrace state.
authorNico Weber <nicolasweber@gmx.de>
Fri, 7 Aug 2015 17:47:03 +0000 (17:47 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 7 Aug 2015 17:47:03 +0000 (17:47 +0000)
commit6d6e4e4c1ba3fbb012ca72fb7706d95d0a425f48
treef7cbe0cb6f3c79c5b05f2dba3bb2004bc23a332a
parent2fe3acd745dc52776e47a82b11ab14b5892f51f5
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244338 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/PrettyStackTrace.h
lib/Support/PrettyStackTrace.cpp