summaryrefslogtreecommitdiff
path: root/src/abort_message.cpp
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2012-01-24 19:58:25 +0000
committerHoward Hinnant <hhinnant@apple.com>2012-01-24 19:58:25 +0000
commitc632c50527eb60090a5c1ba092cf6c9118d80dbe (patch)
tree4ec42fe6b738848f555a169734e5990907b32c56 /src/abort_message.cpp
parent3f034b77daeb3d7ab5a0c5167b2ffece7c9cbd28 (diff)
CrashReporterClient.h is back, but this time protected with __has_include. Thanks for the suggestion Doug. The use is consistent with how the same header is used in llvm/lib/Support/PrettyStackTrace.cpp (though there autoconfig is used instead of __has_include).
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@148851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src/abort_message.cpp')
-rw-r--r--src/abort_message.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/abort_message.cpp b/src/abort_message.cpp
index 5fa7d7f..6726498 100644
--- a/src/abort_message.cpp
+++ b/src/abort_message.cpp
@@ -1,4 +1,4 @@
-//===-------------------------- abort_message.c ---------------------------===//
+//===------------------------- abort_message.cpp --------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,7 +12,24 @@
#include <stdarg.h>
#include "abort_message.h"
-__attribute__((visibility("hidden")))
+#if __APPLE__
+# if defined(__has_include) && __has_include(<CrashReporterClient.h>)
+# define HAVE_CRASHREPORTERCLIENT_H 1
+# include <CrashReporterClient.h>
+
+ // If any clients of llvm try to link to libCrashReporterClient.a themselves,
+ // only one crash info struct will be used.
+ extern "C" {
+ CRASH_REPORTER_CLIENT_HIDDEN
+ struct crashreporter_annotations_t gCRAnnotations
+ __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
+ = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
+ }
+
+# endif
+#endif
+
+__attribute__((visibility("hidden"), noreturn))
void abort_message(const char* format, ...)
{
// write message to stderr
@@ -24,6 +41,16 @@ void abort_message(const char* format, ...)
vfprintf(stderr, format, list);
va_end(list);
fprintf(stderr, "\n");
+
+#if __APPLE__ && HAVE_CRASHREPORTERCLIENT_H
+ // record message in crash report
+ char* buffer;
+ va_list list2;
+ va_start(list2, format);
+ vasprintf(&buffer, format, list2);
+ va_end(list2);
+ CRSetCrashLogMessage(buffer);
+#endif
+
abort();
}
-