Skip to content

Commit bfbf700

Browse files
author
Howard Hinnant
committed
I renamed abort_message to be a C++ file to simplify my simplistic build script which I'm still working on. I also added a struct for the crash reporter on __APPLE__.
llvm-svn: 148752
1 parent eba7d3d commit bfbf700

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

libcxxabi/src/abort_message.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//===-------------------------- abort_message.c ---------------------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is dual licensed under the MIT and the University of Illinois Open
6+
// Source Licenses. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include <stdlib.h>
11+
#include <stdio.h>
12+
#include <stdarg.h>
13+
14+
#if __APPLE__
15+
#include <Availability.h>
16+
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
17+
#include <CrashReporterClient.h>
18+
19+
// If any clients of llvm try to link to libCrashReporterClient.a themselves,
20+
// only one crash info struct will be used.
21+
extern "C" {
22+
CRASH_REPORTER_CLIENT_HIDDEN
23+
struct crashreporter_annotations_t gCRAnnotations
24+
__attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
25+
= { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
26+
}
27+
28+
#endif
29+
#endif
30+
31+
#include "abort_message.h"
32+
33+
__attribute__((visibility("hidden")))
34+
void abort_message(const char* format, ...)
35+
{
36+
// write message to stderr
37+
#if __APPLE__
38+
fprintf(stderr, "libc++abi.dylib: ");
39+
#endif
40+
va_list list;
41+
va_start(list, format);
42+
vfprintf(stderr, format, list);
43+
va_end(list);
44+
fprintf(stderr, "\n");
45+
46+
#if __APPLE__ && (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
47+
// record message in crash report
48+
char* buffer;
49+
va_list list2;
50+
va_start(list2, format);
51+
vasprintf(&buffer, format, list2);
52+
va_end(list2);
53+
CRSetCrashLogMessage(buffer);
54+
#endif
55+
56+
abort();
57+
}
58+

0 commit comments

Comments
 (0)