summaryrefslogtreecommitdiff
path: root/lib/System
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-08-19 23:45:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-08-19 23:45:39 +0000
commitb08ceb8135daf015dc38f9d9048cb075215da383 (patch)
tree2702b88a9d027d30a65d6a83a28e483a91dc73f3 /lib/System
parent7c73b8b180e4dfb82cb508368c7ee43279fb9bc4 (diff)
downloadllvm-b08ceb8135daf015dc38f9d9048cb075215da383.tar.gz
llvm-b08ceb8135daf015dc38f9d9048cb075215da383.tar.bz2
llvm-b08ceb8135daf015dc38f9d9048cb075215da383.tar.xz
CrashRecovery/Darwin: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/Unix/Signals.inc34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/System/Unix/Signals.inc b/lib/System/Unix/Signals.inc
index 1e74647e5f..3e0de66b5d 100644
--- a/lib/System/Unix/Signals.inc
+++ b/lib/System/Unix/Signals.inc
@@ -253,3 +253,37 @@ void llvm::sys::PrintStackTraceOnErrorSignal() {
AddSignalHandler(PrintStackTrace, 0);
}
+
+/***/
+
+// 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.
+
+#ifdef __APPLE__
+
+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();
+}
+
+#include <signal.h>
+#include <pthread.h>
+
+void abort() {
+ pthread_kill(pthread_self(), SIGABRT);
+ usleep(1000);
+ __builtin_trap();
+}
+
+#endif