summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix/Signals.inc
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
commitf14d94637985cf99457c1522b6c18c1cd2d6ea77 (patch)
tree2fb7ff4c6e3b9106437f85b1c11af66ba3464a48 /llvm/lib/System/Unix/Signals.inc
parent3323651ec75a33109f5ace6e0ab318d6207e0b76 (diff)
downloadbcm5719-llvm-f14d94637985cf99457c1522b6c18c1cd2d6ea77.tar.gz
bcm5719-llvm-f14d94637985cf99457c1522b6c18c1cd2d6ea77.zip
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. llvm-svn: 111583
Diffstat (limited to 'llvm/lib/System/Unix/Signals.inc')
-rw-r--r--llvm/lib/System/Unix/Signals.inc34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/System/Unix/Signals.inc b/llvm/lib/System/Unix/Signals.inc
index 1e74647e5fd..3e0de66b5d7 100644
--- a/llvm/lib/System/Unix/Signals.inc
+++ b/llvm/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
OpenPOWER on IntegriCloud