1 //===-- utilities_posix.cpp -------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include <features.h> // IWYU pragma: keep (for __BIONIC__ macro)
16 #include "gwp_asan/definitions.h"
18 extern "C" GWP_ASAN_WEAK
void android_set_abort_message(const char *);
24 void die(const char *Message
) {
26 if (&android_set_abort_message
!= nullptr)
27 android_set_abort_message(Message
);
30 fprintf(stderr
, "%s", Message
);
35 void dieWithErrorCode(const char *Message
, int64_t ErrorCode
) {
37 if (&android_set_abort_message
== nullptr)
40 size_t buffer_size
= strlen(Message
) + 48;
41 char *buffer
= static_cast<char *>(alloca(buffer_size
));
42 snprintf(buffer
, buffer_size
, "%s (Error Code: %" PRId64
")", Message
,
44 android_set_abort_message(buffer
);
47 fprintf(stderr
, "%s (Error Code: %" PRId64
")", Message
, ErrorCode
);
51 } // namespace gwp_asan