Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2012-01-24 23:58:25 +0400
committerHoward Hinnant <hhinnant@apple.com>2012-01-24 23:58:25 +0400
commit0d517a42789eac15dfaeeb9c50e96de49a74c131 (patch)
tree2f4e0eec14302cfb729ec2070c0e238b2f1482ae /libcxxabi/src/abort_message.cpp
parent9ce58bd7578b494aab0abbef8e015722f720f6f2 (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).
llvm-svn: 148851
Diffstat (limited to 'libcxxabi/src/abort_message.cpp')
-rw-r--r--libcxxabi/src/abort_message.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/libcxxabi/src/abort_message.cpp b/libcxxabi/src/abort_message.cpp
index 5fa7d7ff9365..672649835386 100644
--- a/libcxxabi/src/abort_message.cpp
+++ b/libcxxabi/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();
}
-