Skip to content

Commit 0b7cbd2

Browse files
[Darwin][Sanitizers][CrashReporter] Adopt initializer for Crash Reporter Annotations struct (llvm#123978)
An initializer for the Crash Reporter Annotatoins struct was added in version 5. For the simplicity of not needing to always update the struct in subsequent versions, this patchs checks for the initializer before attempting to redefine the struct on its own. Note -- we have an existing test for this that is disabled by default, it is inherently flakey due to the nature of crash reporter. But we can run that when making crash reporter related changes. rdar://136156203
1 parent 7a831eb commit 0b7cbd2

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern char **environ;
4545
# define SANITIZER_OS_TRACE 0
4646
# endif
4747

48-
// import new crash reporting api
48+
// Integrate with CrashReporter library if available
4949
# if defined(__has_include) && __has_include(<CrashReporterClient.h>)
5050
# define HAVE_CRASHREPORTERCLIENT_H 1
5151
# include <CrashReporterClient.h>
@@ -796,8 +796,13 @@ static char crashreporter_info_buff[__sanitizer::kErrorMessageBufferSize] = {};
796796
static Mutex crashreporter_info_mutex;
797797

798798
extern "C" {
799-
// Integrate with crash reporter libraries.
799+
800800
#if HAVE_CRASHREPORTERCLIENT_H
801+
// Available in CRASHREPORTER_ANNOTATIONS_VERSION 5+
802+
# ifdef CRASHREPORTER_ANNOTATIONS_INITIALIZER
803+
CRASHREPORTER_ANNOTATIONS_INITIALIZER()
804+
# else
805+
// Support for older CrashRerporter annotiations
801806
CRASH_REPORTER_CLIENT_HIDDEN
802807
struct crashreporter_annotations_t gCRAnnotations
803808
__attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) = {
@@ -808,17 +813,17 @@ struct crashreporter_annotations_t gCRAnnotations
808813
0,
809814
0,
810815
0,
811-
#if CRASHREPORTER_ANNOTATIONS_VERSION > 4
816+
# if CRASHREPORTER_ANNOTATIONS_VERSION > 4
812817
0,
813-
#endif
818+
# endif
814819
};
815-
816-
#else
817-
// fall back to old crashreporter api
820+
# endif
821+
# else
822+
// Revert to previous crash reporter API if client header is not available
818823
static const char *__crashreporter_info__ __attribute__((__used__)) =
819824
&crashreporter_info_buff[0];
820825
asm(".desc ___crashreporter_info__, 0x10");
821-
#endif
826+
#endif // HAVE_CRASHREPORTERCLIENT_H
822827

823828
} // extern "C"
824829

0 commit comments

Comments
 (0)