diff options
author | Gerolf Hoflehner <ghoflehner@apple.com> | 2016-05-25 05:51:05 +0000 |
---|---|---|
committer | Gerolf Hoflehner <ghoflehner@apple.com> | 2016-05-25 05:51:05 +0000 |
commit | 7c1841a55ed33792f14f96eb2a2f4dc030bd99c2 (patch) | |
tree | 7ad5796de13610aa0af946d1ce56e74c37653ed9 /llvm/lib/Support/Unix | |
parent | d3076ab36ff43a8847df3512926ad5e2ef0494d2 (diff) | |
download | bcm5719-llvm-7c1841a55ed33792f14f96eb2a2f4dc030bd99c2.tar.gz bcm5719-llvm-7c1841a55ed33792f14f96eb2a2f4dc030bd99c2.zip |
[Support] revert previous commit r270643
llvm-svn: 270670
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r-- | llvm/lib/Support/Unix/Signals.inc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index b49b8aae4ff..8e0d2057c76 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -490,3 +490,42 @@ void llvm::sys::PrintStackTraceOnErrorSignal(bool DisableCrashReporting) { } #endif } + + +/***/ + +// On Darwin, raise sends a signal to the main thread instead of the current +// thread. This has the unfortunate effect that assert() and abort() will end up +// bypassing our crash recovery attempts. We work around this for anything in +// the same linkage unit by just defining our own versions of the assert handler +// and abort. + +#if defined(__APPLE__) && defined(ENABLE_CRASH_OVERRIDES) + +#include <signal.h> +#include <pthread.h> + +int raise(int sig) { + return pthread_kill(pthread_self(), sig); +} + +void __assert_rtn(const char *func, + const char *file, + int line, + const char *expr) { + if (func) + fprintf(stderr, "Assertion failed: (%s), function %s, file %s, line %d.\n", + expr, func, file, line); + else + fprintf(stderr, "Assertion failed: (%s), file %s, line %d.\n", + expr, file, line); + abort(); +} + +void abort() { + raise(SIGABRT); + usleep(1000); + __builtin_trap(); +} + +#endif |