support Android's logging system for fatal_error
parent
b072022022
commit
8d0314295e
|
@ -56,6 +56,7 @@ cc_library {
|
||||||
defaults: ["hardened_malloc_defaults"],
|
defaults: ["hardened_malloc_defaults"],
|
||||||
srcs: lib_src_files,
|
srcs: lib_src_files,
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
|
static_libs: ["libasync_safe"],
|
||||||
target: {
|
target: {
|
||||||
android: {
|
android: {
|
||||||
shared: {
|
shared: {
|
||||||
|
|
7
util.c
7
util.c
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
#include <async_safe/log.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static int write_full(int fd, const char *buf, size_t length) {
|
static int write_full(int fd, const char *buf, size_t length) {
|
||||||
|
@ -27,5 +31,8 @@ COLD noreturn void fatal_error(const char *s) {
|
||||||
(void)(write_full(STDERR_FILENO, prefix, strlen(prefix)) != -1 &&
|
(void)(write_full(STDERR_FILENO, prefix, strlen(prefix)) != -1 &&
|
||||||
write_full(STDERR_FILENO, s, strlen(s)) != -1 &&
|
write_full(STDERR_FILENO, s, strlen(s)) != -1 &&
|
||||||
write_full(STDERR_FILENO, "\n", 1));
|
write_full(STDERR_FILENO, "\n", 1));
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
async_safe_format_log(ANDROID_LOG_FATAL, "hardened_malloc", "fatal allocator error: %s", s);
|
||||||
|
#endif
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue