1 //===------------------------- abort_message.cpp --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
13 #include "abort_message.h"
16 #include <android/set_abort_message.h>
20 #pragma GCC visibility push(hidden)
23 # if defined(__has_include) && __has_include(<CrashReporterClient.h>)
24 # define HAVE_CRASHREPORTERCLIENT_H 1
25 # include <CrashReporterClient.h>
29 __attribute__((visibility("hidden"), noreturn))
30 void abort_message(const char* format, ...)
32 // write message to stderr
34 fprintf(stderr, "libc++abi.dylib: ");
37 va_start(list, format);
38 vfprintf(stderr, format, list);
40 fprintf(stderr, "\n");
42 #if __APPLE__ && HAVE_CRASHREPORTERCLIENT_H
43 // record message in crash report
46 va_start(list2, format);
47 vasprintf(&buffer, format, list2);
49 CRSetCrashLogMessage(buffer);
53 va_start(list2, format);
54 vasprintf(&buffer, format, list2);
57 // Show error in tombstone.
58 android_set_abort_message(buffer);
60 // Show error in logcat.
61 openlog("libc++abi", 0, 0);
62 syslog(LOG_CRIT, "%s", buffer);
69 #pragma GCC visibility pop