1 //===-- utilities_fuchsia.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 //===----------------------------------------------------------------------===//
9 #include "gwp_asan/utilities.h"
14 #include <zircon/sanitizer.h>
15 #include <zircon/status.h>
18 void die(const char *Message
) {
19 __sanitizer_log_write(Message
, strlen(Message
));
23 void dieWithErrorCode(const char *Message
, int64_t ErrorCode
) {
24 const char *error_str
=
25 _zx_status_get_string(static_cast<zx_status_t
>(ErrorCode
));
26 size_t buffer_size
= strlen(Message
) + 32 + strlen(error_str
);
27 char *buffer
= static_cast<char *>(alloca(buffer_size
));
28 snprintf(buffer
, buffer_size
, "%s (Error Code: %s)", Message
, error_str
);
29 __sanitizer_log_write(buffer
, strlen(buffer
));
32 } // namespace gwp_asan