* commit '12ea8005665085ae82c1b233ae93d12855e04b8b': Clean up internal libc logging.
This commit is contained in:
commit
cf23cbb1d4
@ -149,7 +149,6 @@ libc_common_src_files := \
|
||||
bionic/isatty.c \
|
||||
bionic/issetugid.c \
|
||||
bionic/ldexp.c \
|
||||
bionic/logd_write.c \
|
||||
bionic/lseek64.c \
|
||||
bionic/md5.c \
|
||||
bionic/memchr.c \
|
||||
@ -238,7 +237,6 @@ libc_common_src_files := \
|
||||
libc_bionic_src_files := \
|
||||
bionic/assert.cpp \
|
||||
bionic/brk.cpp \
|
||||
bionic/debug_format.cpp \
|
||||
bionic/dirent.cpp \
|
||||
bionic/__errno.c \
|
||||
bionic/eventfd.cpp \
|
||||
@ -246,6 +244,7 @@ libc_bionic_src_files := \
|
||||
bionic/getauxval.cpp \
|
||||
bionic/getcwd.cpp \
|
||||
bionic/libc_init_common.cpp \
|
||||
bionic/libc_logging.cpp \
|
||||
bionic/libgen.cpp \
|
||||
bionic/__memcpy_chk.cpp \
|
||||
bionic/__memmove_chk.cpp \
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <private/logd.h>
|
||||
#include <private/libc_logging.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
@ -52,7 +52,7 @@ atexit(void (*func)(void))
|
||||
*/
|
||||
static char const warning[] = "WARNING: generic atexit() called from legacy shared library\n";
|
||||
|
||||
__libc_android_log_write(ANDROID_LOG_WARN, "libc", warning);
|
||||
__libc_format_log(ANDROID_LOG_WARN, "libc", warning);
|
||||
fprintf(stderr, warning);
|
||||
|
||||
return (__cxa_atexit((void (*)(void *))func, NULL, NULL));
|
||||
|
@ -29,8 +29,7 @@
|
||||
#include <sys/cachectl.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <private/logd.h>
|
||||
#include <private/debug_format.h>
|
||||
#include <private/libc_logging.h>
|
||||
#define XLOG(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc-cacheflush",__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* __fgets_chk. Called in place of fgets() when we know the
|
||||
|
@ -29,7 +29,7 @@
|
||||
#undef _FORTIFY_SOURCE
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __memcpy_chk.
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____memmove_chk.
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____memset_chk.
|
||||
|
@ -29,8 +29,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bionic_ssp.h"
|
||||
#include "debug_format.h"
|
||||
#include "logd.h"
|
||||
#include "libc_logging.h"
|
||||
|
||||
void __stack_chk_fail() {
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", "stack corruption detected");
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
#include <safe_iop.h>
|
||||
|
||||
/*
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____strcpy_chk.
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* __strlcat_chk. Called in place of strlcat() when we know the
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* __strlcpy_chk. Called in place of strlcpy() when we know the
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __strlen_chk.
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
#include <safe_iop.h>
|
||||
|
||||
/*
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____strncpy_chk.
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____vsnprintf_chk.
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____vsprintf_chk.
|
||||
|
@ -32,8 +32,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/debug_format.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
// We log to stderr for the benefit of "adb shell" users, and the log for the benefit
|
||||
// of regular app developers who want to see their asserts.
|
||||
|
@ -33,9 +33,8 @@
|
||||
#include <unwind.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "debug_format.h"
|
||||
#include "debug_mapinfo.h"
|
||||
#include "logd.h"
|
||||
#include "libc_logging.h"
|
||||
|
||||
/* depends how the system includes define this */
|
||||
#ifdef HAVE_UNWIND_CONTEXT_STRUCT
|
||||
|
@ -24,8 +24,7 @@
|
||||
|
||||
#include <linux/ashmem.h>
|
||||
|
||||
#include <private/debug_format.h>
|
||||
#include <private/logd.h>
|
||||
#include <private/libc_logging.h>
|
||||
|
||||
// Send dlmalloc errors to the log.
|
||||
static void __bionic_heap_corruption_error(const char* function);
|
||||
|
@ -26,13 +26,15 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <../private/debug_format.h> // Relative path so we can #include this for testing.
|
||||
#include <../private/libc_logging.h> // Relative path so we can #include this .cpp file for testing.
|
||||
#include <../private/ScopedPthreadMutexLocker.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -218,29 +220,30 @@ int __libc_format_fd(int fd, const char* format, ...) {
|
||||
#include <fcntl.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
static pthread_mutex_t gLogInitializationLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
int __libc_format_log_va_list(int priority, const char* tag, const char* fmt, va_list args) {
|
||||
char buf[1024];
|
||||
int result = vformat_buffer(buf, sizeof buf, fmt, args);
|
||||
int buf_strlen = vformat_buffer(buf, sizeof(buf), fmt, args);
|
||||
|
||||
static int log_fd = -1;
|
||||
if (log_fd == -1) {
|
||||
log_fd = open("/dev/log/main", O_WRONLY);
|
||||
if (log_fd == -1) {
|
||||
return result;
|
||||
static int main_log_fd = -1;
|
||||
if (main_log_fd == -1) {
|
||||
ScopedPthreadMutexLocker locker(&gLogInitializationLock);
|
||||
main_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/main", O_CLOEXEC | O_WRONLY));
|
||||
if (main_log_fd == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
struct iovec vec[3];
|
||||
vec[0].iov_base = (unsigned char *) &priority;
|
||||
vec[0].iov_base = &priority;
|
||||
vec[0].iov_len = 1;
|
||||
vec[1].iov_base = (void *) tag;
|
||||
vec[1].iov_base = const_cast<char*>(tag);
|
||||
vec[1].iov_len = strlen(tag) + 1;
|
||||
vec[2].iov_base = (void *) buf;
|
||||
vec[2].iov_len = strlen(buf) + 1;
|
||||
vec[2].iov_base = const_cast<char*>(buf);
|
||||
vec[2].iov_len = buf_strlen + 1;
|
||||
|
||||
TEMP_FAILURE_RETRY(writev(log_fd, vec, 3));
|
||||
|
||||
return result;
|
||||
return TEMP_FAILURE_RETRY(writev(main_log_fd, vec, 3));
|
||||
}
|
||||
|
||||
int __libc_format_log(int priority, const char* tag, const char* format, ...) {
|
||||
@ -516,3 +519,44 @@ out_vformat(Out *o, const char *format, va_list args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// must be kept in sync with frameworks/base/core/java/android/util/EventLog.java
|
||||
enum AndroidEventLogType {
|
||||
EVENT_TYPE_INT = 0,
|
||||
EVENT_TYPE_LONG = 1,
|
||||
EVENT_TYPE_STRING = 2,
|
||||
EVENT_TYPE_LIST = 3,
|
||||
};
|
||||
|
||||
static int __libc_android_log_event(int32_t tag, char type, const void* payload, size_t len) {
|
||||
struct iovec vec[3];
|
||||
vec[0].iov_base = &tag;
|
||||
vec[0].iov_len = sizeof(tag);
|
||||
vec[1].iov_base = &type;
|
||||
vec[1].iov_len = sizeof(type);
|
||||
vec[2].iov_base = const_cast<void*>(payload);
|
||||
vec[2].iov_len = len;
|
||||
|
||||
static int event_log_fd = -1;
|
||||
if (event_log_fd == -1) {
|
||||
ScopedPthreadMutexLocker locker(&gLogInitializationLock);
|
||||
event_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/events", O_CLOEXEC | O_WRONLY));
|
||||
}
|
||||
return TEMP_FAILURE_RETRY(writev(event_log_fd, vec, 3));
|
||||
}
|
||||
|
||||
void __libc_android_log_event_int(int32_t tag, int value) {
|
||||
__libc_android_log_event(tag, EVENT_TYPE_INT, &value, sizeof(value));
|
||||
}
|
||||
|
||||
void __libc_android_log_event_uid(int32_t tag) {
|
||||
__libc_android_log_event_int(tag, getuid());
|
||||
}
|
||||
|
||||
void __fortify_chk_fail(const char *msg, uint32_t tag) {
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", "FORTIFY_SOURCE: %s. Calling abort().\n", msg);
|
||||
if (tag != 0) {
|
||||
__libc_android_log_event_uid(tag);
|
||||
}
|
||||
abort();
|
||||
}
|
@ -1,255 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "logd.h"
|
||||
|
||||
/* should match system/core/include/cutils/logger.h */
|
||||
#define LOGGER_LOG_MAIN "log/main"
|
||||
#define LOGGER_LOG_RADIO "log/radio"
|
||||
#define LOGGER_LOG_EVENTS "log/events"
|
||||
#define LOGGER_LOG_SYSTEM "log/system"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/* IMPORTANT IMPORTANT IMPORTANT: TECHNICAL NOTE
|
||||
*
|
||||
* Some of the functions below can be called when our malloc() implementation
|
||||
* has detected that the heap is corrupted, or even from a signal handler.
|
||||
*
|
||||
* These functions should *not* use a function that allocates heap memory
|
||||
* or is not signal-safe. Using direct system calls is acceptable, and we
|
||||
* also assume that pthread_mutex_lock/unlock can be used too.
|
||||
*/
|
||||
|
||||
#define LOG_BUF_SIZE 1024
|
||||
|
||||
typedef enum {
|
||||
LOG_ID_NONE = 0,
|
||||
LOG_ID_MAIN,
|
||||
LOG_ID_RADIO,
|
||||
LOG_ID_EVENTS,
|
||||
LOG_ID_MAX
|
||||
} log_id_t;
|
||||
|
||||
/* logger handles writing to object, pointed by log channel id */
|
||||
typedef int (*logger_function_t)(log_id_t log_id, struct iovec *vec);
|
||||
|
||||
typedef struct {
|
||||
logger_function_t logger;
|
||||
int fd;
|
||||
const char *path;
|
||||
} log_channel_t;
|
||||
|
||||
static int __write_to_log_init(log_id_t log_id, struct iovec *vec);
|
||||
static int __write_to_log_null(log_id_t log_id, struct iovec *vec);
|
||||
|
||||
static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static log_channel_t log_channels[LOG_ID_MAX] = {
|
||||
{ __write_to_log_null, -1, NULL },
|
||||
{ __write_to_log_init, -1, "/dev/"LOGGER_LOG_MAIN },
|
||||
{ __write_to_log_init, -1, "/dev/"LOGGER_LOG_RADIO },
|
||||
{ __write_to_log_init, -1, "/dev/"LOGGER_LOG_EVENTS }
|
||||
};
|
||||
|
||||
/* Important: see technical note at start of source file */
|
||||
static int __write_to_log_null(log_id_t log_id, struct iovec *vec)
|
||||
{
|
||||
/*
|
||||
* ALTERED behaviour from previous version
|
||||
* always returns successful result
|
||||
*/
|
||||
int i = 0;
|
||||
size_t res = 0;
|
||||
|
||||
for ( ; i < 3; ++i) {
|
||||
res += vec[i].iov_len;
|
||||
}
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
/*
|
||||
* it's supposed, that log_id contains valid id always.
|
||||
* this check must be performed in higher level functions
|
||||
*/
|
||||
/* Important: see technical note at start of source file */
|
||||
static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec)
|
||||
{
|
||||
return TEMP_FAILURE_RETRY( writev(log_channels[log_id].fd, vec, 3) );
|
||||
}
|
||||
|
||||
/* Important: see technical note at start of source file */
|
||||
static int __write_to_log_init(log_id_t log_id, struct iovec *vec)
|
||||
{
|
||||
if ((LOG_ID_NONE < log_id) && (log_id < LOG_ID_MAX)) {
|
||||
int fd;
|
||||
|
||||
pthread_mutex_lock(&log_init_lock);
|
||||
|
||||
fd = TEMP_FAILURE_RETRY(open(log_channels[log_id].path, O_WRONLY));
|
||||
|
||||
log_channels[log_id].logger =
|
||||
(fd < 0) ? __write_to_log_null : __write_to_log_kernel;
|
||||
log_channels[log_id].fd = fd;
|
||||
|
||||
log_channels[log_id].fd = fd;
|
||||
|
||||
pthread_mutex_unlock(&log_init_lock);
|
||||
|
||||
return log_channels[log_id].logger(log_id, vec);
|
||||
}
|
||||
|
||||
/* log_id is invalid */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Important: see technical note at start of source file */
|
||||
__LIBC_HIDDEN__
|
||||
int __libc_android_log_write(int prio, const char *tag, const char *msg)
|
||||
{
|
||||
struct iovec vec[3];
|
||||
log_id_t log_id = LOG_ID_MAIN;
|
||||
|
||||
if (tag == NULL)
|
||||
tag = "";
|
||||
|
||||
vec[0].iov_base = (unsigned char *) &prio;
|
||||
vec[0].iov_len = 1;
|
||||
vec[1].iov_base = (void *) tag;
|
||||
vec[1].iov_len = strlen(tag) + 1;
|
||||
vec[2].iov_base = (void *) msg;
|
||||
vec[2].iov_len = strlen(msg) + 1;
|
||||
|
||||
return log_channels[log_id].logger(log_id, vec);
|
||||
}
|
||||
|
||||
/* The functions below are not designed to be called from a heap panic
|
||||
* function or from a signal handler. As such, they are free to use complex
|
||||
* C library functions like vsnprintf()
|
||||
*/
|
||||
__LIBC_HIDDEN__
|
||||
int __libc_android_log_vprint(int prio, const char *tag, const char *fmt,
|
||||
va_list ap)
|
||||
{
|
||||
char buf[LOG_BUF_SIZE];
|
||||
|
||||
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
||||
|
||||
return __libc_android_log_write(prio, tag, buf);
|
||||
}
|
||||
|
||||
__LIBC_HIDDEN__
|
||||
int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[LOG_BUF_SIZE];
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return __libc_android_log_write(prio, tag, buf);
|
||||
}
|
||||
|
||||
__LIBC_HIDDEN__
|
||||
int __libc_android_log_assert(const char *cond, const char *tag,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[LOG_BUF_SIZE];
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
__libc_android_log_write(ANDROID_LOG_FATAL, tag, buf);
|
||||
|
||||
exit(1);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Event logging.
|
||||
*/
|
||||
|
||||
// must be kept in sync with frameworks/base/core/java/android/util/EventLog.java
|
||||
typedef enum {
|
||||
EVENT_TYPE_INT = 0,
|
||||
EVENT_TYPE_LONG = 1,
|
||||
EVENT_TYPE_STRING = 2,
|
||||
EVENT_TYPE_LIST = 3,
|
||||
} AndroidEventLogType;
|
||||
|
||||
static int __libc_android_log_btwrite(int32_t tag, char type, const void *payload, size_t len)
|
||||
{
|
||||
struct iovec vec[3];
|
||||
|
||||
vec[0].iov_base = &tag;
|
||||
vec[0].iov_len = sizeof(tag);
|
||||
vec[1].iov_base = &type;
|
||||
vec[1].iov_len = sizeof(type);
|
||||
vec[2].iov_base = (void*)payload;
|
||||
vec[2].iov_len = len;
|
||||
|
||||
return log_channels[LOG_ID_EVENTS].logger(LOG_ID_EVENTS, vec);
|
||||
}
|
||||
|
||||
__LIBC_HIDDEN__
|
||||
void __libc_android_log_event_int(int32_t tag, int value)
|
||||
{
|
||||
__libc_android_log_btwrite(tag, EVENT_TYPE_INT, &value, sizeof(value));
|
||||
}
|
||||
|
||||
__LIBC_HIDDEN__
|
||||
void __libc_android_log_event_uid(int32_t tag)
|
||||
{
|
||||
__libc_android_log_event_int(tag, getuid());
|
||||
}
|
||||
|
||||
__LIBC_HIDDEN__
|
||||
void __fortify_chk_fail(const char *msg, uint32_t tag) {
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", "FORTIFY_SOURCE: %s. Calling abort().\n", msg);
|
||||
if (tag != 0) {
|
||||
__libc_android_log_event_uid(tag);
|
||||
}
|
||||
abort();
|
||||
}
|
@ -48,7 +48,7 @@
|
||||
#include "debug_mapinfo.h"
|
||||
#include "debug_stacktrace.h"
|
||||
#include "dlmalloc.h"
|
||||
#include "logd.h"
|
||||
#include "libc_logging.h"
|
||||
#include "malloc_debug_common.h"
|
||||
#include "ScopedPthreadMutexLocker.h"
|
||||
|
||||
|
@ -249,7 +249,7 @@ extern "C" void* memalign(size_t alignment, size_t bytes) {
|
||||
#include <sys/system_properties.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include "logd.h"
|
||||
#include "libc_logging.h"
|
||||
|
||||
/* Table for dispatching malloc calls, depending on environment. */
|
||||
static MallocDebug gMallocUse __attribute__((aligned(32))) = {
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <private/debug_format.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
#define HASHTABLE_SIZE 1543
|
||||
#define BACKTRACE_SIZE 32
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
#include "debug_stacktrace.h"
|
||||
#include "dlmalloc.h"
|
||||
#include "logd.h"
|
||||
#include "libc_logging.h"
|
||||
#include "malloc_debug_common.h"
|
||||
#include "ScopedPthreadMutexLocker.h"
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "dlmalloc.h"
|
||||
#include "logd.h"
|
||||
#include "libc_logging.h"
|
||||
#include "malloc_debug_common.h"
|
||||
|
||||
/* This file should be included into the build only when
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
extern int __open(const char*, int, int);
|
||||
|
||||
@ -60,4 +60,3 @@ int __open_2(const char *pathname, int flags) {
|
||||
|
||||
return __open(pathname, flags, 0);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
extern int __openat(int, const char*, int, int);
|
||||
|
||||
@ -61,4 +61,3 @@ int __openat_2(int fd, const char *pathname, int flags)
|
||||
|
||||
return __openat(fd, pathname, flags, 0);
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,7 @@
|
||||
|
||||
#include "private/bionic_ssp.h"
|
||||
#include "private/bionic_tls.h"
|
||||
#include "private/debug_format.h"
|
||||
#include "private/logd.h"
|
||||
#include "private/libc_logging.h"
|
||||
#include "private/thread_private.h"
|
||||
#include "private/ErrnoRestorer.h"
|
||||
#include "private/ScopedPthreadMutexLocker.h"
|
||||
|
@ -43,9 +43,7 @@
|
||||
#include "bionic_tls.h"
|
||||
#include "debug_mapinfo.h"
|
||||
#include "debug_stacktrace.h"
|
||||
#include "logd.h"
|
||||
|
||||
#include <private/debug_format.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
/*
|
||||
* ===========================================================================
|
||||
|
@ -38,9 +38,8 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "private/android_filesystem_config.h"
|
||||
#include "private/debug_format.h"
|
||||
#include "private/ErrnoRestorer.h"
|
||||
#include "private/logd.h"
|
||||
#include "private/libc_logging.h"
|
||||
|
||||
// Thread-specific state for the non-reentrant functions.
|
||||
static pthread_once_t stubs_once = PTHREAD_ONCE_INIT;
|
||||
|
@ -171,9 +171,8 @@
|
||||
|
||||
#undef XLOG
|
||||
#if DEBUG
|
||||
# include <logd.h>
|
||||
# define XLOG(...) \
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
|
||||
# include "libc_logging.h"
|
||||
# define XLOG(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
@ -707,9 +706,9 @@ static char*
|
||||
_dnsPacket_bprintQR(DnsPacket* packet, char* p, char* end)
|
||||
{
|
||||
#define QQ(x) { DNS_TYPE_##x, #x }
|
||||
static const struct {
|
||||
static const struct {
|
||||
const char* typeBytes;
|
||||
const char* typeString;
|
||||
const char* typeString;
|
||||
} qTypes[] =
|
||||
{
|
||||
QQ(A), QQ(PTR), QQ(MX), QQ(AAAA), QQ(ALL),
|
||||
|
@ -119,7 +119,7 @@ __RCSID("$NetBSD: res_send.c,v 1.9 2006/01/24 17:41:25 christos Exp $");
|
||||
# include <resolv_cache.h>
|
||||
#endif
|
||||
|
||||
#include "logd.h"
|
||||
#include "libc_logging.h"
|
||||
|
||||
#ifndef DE_CONST
|
||||
#define DE_CONST(c,v) v = ((c) ? \
|
||||
@ -555,7 +555,7 @@ res_nsend(res_state statp,
|
||||
ns);
|
||||
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc",
|
||||
"used send_vc %d\n", n);
|
||||
}
|
||||
|
||||
@ -567,15 +567,13 @@ res_nsend(res_state statp,
|
||||
} else {
|
||||
/* Use datagrams. */
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
"using send_dg\n");
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc", "using send_dg\n");
|
||||
}
|
||||
|
||||
n = send_dg(statp, buf, buflen, ans, anssiz, &terrno,
|
||||
ns, &v_circuit, &gotsomewhere);
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
"used send_dg %d\n",n);
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc", "used send_dg %d\n",n);
|
||||
}
|
||||
|
||||
if (n < 0)
|
||||
@ -583,7 +581,7 @@ res_nsend(res_state statp,
|
||||
if (n == 0)
|
||||
goto next_ns;
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc",
|
||||
"time=%d, %d\n",time(NULL), time(NULL)%2);
|
||||
}
|
||||
if (v_circuit)
|
||||
@ -728,8 +726,7 @@ static int get_timeout(const res_state statp, const int ns)
|
||||
timeout = 1;
|
||||
}
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
"using timeout of %d sec\n", timeout);
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc", "using timeout of %d sec\n", timeout);
|
||||
}
|
||||
|
||||
return timeout;
|
||||
@ -751,7 +748,7 @@ send_vc(res_state statp,
|
||||
void *tmp;
|
||||
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc", "using send_vc\n");
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc", "using send_vc\n");
|
||||
}
|
||||
|
||||
nsap = get_nsaddr(statp, (size_t)ns);
|
||||
@ -952,8 +949,7 @@ connect_with_timeout(int sock, const struct sockaddr *nsap, socklen_t salen, int
|
||||
timeout = evConsTime((long)sec, 0L);
|
||||
finish = evAddTime(now, timeout);
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
" %d send_vc\n", sock);
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d send_vc\n", sock);
|
||||
}
|
||||
|
||||
res = retrying_select(sock, &rset, &wset, &finish);
|
||||
@ -964,7 +960,7 @@ connect_with_timeout(int sock, const struct sockaddr *nsap, socklen_t salen, int
|
||||
done:
|
||||
fcntl(sock, F_SETFL, origflags);
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc",
|
||||
" %d connect_with_timeout returning %s\n", sock, res);
|
||||
}
|
||||
return res;
|
||||
@ -980,7 +976,7 @@ retrying_select(const int sock, fd_set *readset, fd_set *writeset, const struct
|
||||
|
||||
retry:
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc", " %d retying_select\n", sock);
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc", " %d retying_select\n", sock);
|
||||
}
|
||||
|
||||
now = evNowTime();
|
||||
@ -1000,7 +996,7 @@ retry:
|
||||
n = pselect(sock + 1, readset, writeset, NULL, &timeout, NULL);
|
||||
if (n == 0) {
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, " libc",
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, " libc",
|
||||
" %d retrying_select timeout\n", sock);
|
||||
}
|
||||
errno = ETIMEDOUT;
|
||||
@ -1010,7 +1006,7 @@ retry:
|
||||
if (errno == EINTR)
|
||||
goto retry;
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc",
|
||||
" %d retrying_select got error %d\n",sock, n);
|
||||
}
|
||||
return n;
|
||||
@ -1020,7 +1016,7 @@ retry:
|
||||
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, &len) < 0 || error) {
|
||||
errno = error;
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc",
|
||||
" %d retrying_select dot error2 %d\n", sock, errno);
|
||||
}
|
||||
|
||||
@ -1028,7 +1024,7 @@ retry:
|
||||
}
|
||||
}
|
||||
if (DBG) {
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
|
||||
__libc_format_log(ANDROID_LOG_DEBUG, "libc",
|
||||
" %d retrying_select returning %d for %d\n",sock, n);
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@
|
||||
#define DEBUG 0
|
||||
|
||||
#if DEBUG
|
||||
# include <logd.h>
|
||||
# include "libc_logging.h"
|
||||
# include <unistd.h> /* for gettid() */
|
||||
# define D(...) __libc_android_log_print(ANDROID_LOG_DEBUG,"libc", __VA_ARGS__)
|
||||
# define D(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc", __VA_ARGS__)
|
||||
#else
|
||||
# define D(...) do{}while(0)
|
||||
#endif
|
||||
|
@ -567,9 +567,8 @@ __END_DECLS
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
# include <logd.h>
|
||||
# define XLOG(...) \
|
||||
__libc_android_log_print(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
|
||||
# include "libc_logging.h"
|
||||
# define XLOG(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
|
||||
#else
|
||||
#define XLOG(...) do {} while (0)
|
||||
#endif
|
||||
|
@ -26,17 +26,51 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _DEBUG_FORMAT_H
|
||||
#define _DEBUG_FORMAT_H
|
||||
#ifndef _LIBC_LOGGING_H
|
||||
#define _LIBC_LOGGING_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
enum {
|
||||
BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW = 80100,
|
||||
BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW = 80105,
|
||||
BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW = 80110,
|
||||
BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW = 80115,
|
||||
BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW = 80120,
|
||||
BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW = 80125,
|
||||
BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW = 80130,
|
||||
|
||||
BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW = 80200,
|
||||
BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW = 80205,
|
||||
|
||||
BIONIC_EVENT_RESOLVER_OLD_RESPONSE = 80300,
|
||||
BIONIC_EVENT_RESOLVER_WRONG_SERVER = 80305,
|
||||
BIONIC_EVENT_RESOLVER_WRONG_QUERY = 80310,
|
||||
};
|
||||
|
||||
enum {
|
||||
ANDROID_LOG_UNKNOWN = 0,
|
||||
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
|
||||
|
||||
ANDROID_LOG_VERBOSE,
|
||||
ANDROID_LOG_DEBUG,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_WARN,
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_FATAL,
|
||||
|
||||
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
||||
};
|
||||
|
||||
//
|
||||
// Formatting routines for the C library's internal debugging.
|
||||
// Unlike the usual alternatives, these don't allocate.
|
||||
//
|
||||
|
||||
__LIBC_HIDDEN__ int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...)
|
||||
__attribute__((__format__(printf, 3, 4)));
|
||||
@ -50,6 +84,15 @@ __LIBC_HIDDEN__ int __libc_format_log(int priority, const char* tag, const char*
|
||||
__LIBC_HIDDEN__ int __libc_format_log_va_list(int priority, const char* tag, const char* format,
|
||||
va_list ap);
|
||||
|
||||
//
|
||||
// Event logging.
|
||||
//
|
||||
|
||||
__LIBC_HIDDEN__ void __libc_android_log_event_int(int32_t tag, int value);
|
||||
__LIBC_HIDDEN__ void __libc_android_log_event_uid(int32_t tag);
|
||||
|
||||
__LIBC_HIDDEN__ __noreturn void __fortify_chk_fail(const char* msg, uint32_t event_tag);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _DEBUG_FORMAT_H */
|
||||
#endif
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _ANDROID_BIONIC_LOGD_H
|
||||
#define _ANDROID_BIONIC_LOGD_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW 80100
|
||||
#define BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW 80105
|
||||
#define BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW 80110
|
||||
#define BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW 80115
|
||||
#define BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW 80120
|
||||
#define BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW 80125
|
||||
#define BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW 80130
|
||||
|
||||
#define BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW 80200
|
||||
#define BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW 80205
|
||||
|
||||
#define BIONIC_EVENT_RESOLVER_OLD_RESPONSE 80300
|
||||
#define BIONIC_EVENT_RESOLVER_WRONG_SERVER 80305
|
||||
#define BIONIC_EVENT_RESOLVER_WRONG_QUERY 80310
|
||||
|
||||
enum {
|
||||
ANDROID_LOG_UNKNOWN = 0,
|
||||
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
|
||||
|
||||
ANDROID_LOG_VERBOSE,
|
||||
ANDROID_LOG_DEBUG,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_WARN,
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_FATAL,
|
||||
|
||||
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int __libc_android_log_write(int prio, const char* tag, const char* buffer);
|
||||
int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...);
|
||||
int __libc_android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap);
|
||||
|
||||
void __libc_android_log_event_int(int32_t tag, int value);
|
||||
void __libc_android_log_event_uid(int32_t tag);
|
||||
|
||||
__noreturn extern void __fortify_chk_fail(const char *, uint32_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* _ANDROID_BIONIC_LOGD_H */
|
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
char *
|
||||
__strchr_chk(const char *p, int ch, size_t s_len)
|
||||
|
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <private/logd.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
char *
|
||||
__strrchr_chk(const char *p, int ch, size_t s_len)
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
extern "C" void __cxa_pure_virtual() {
|
||||
// We can't call __libc_android_log_write from libstdc++ because it's private, so cheat.
|
||||
// We can't call __libc_format_log from libstdc++ because it's hidden and in libc, so cheat.
|
||||
assert(!"Pure virtual function called. Are you calling virtual methods from a destructor?");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
@ -37,9 +37,6 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <private/debug_format.h>
|
||||
#include <private/logd.h>
|
||||
|
||||
extern "C" int tgkill(int tgid, int tid, int sig);
|
||||
|
||||
#define DEBUGGER_SOCKET_NAME "android:debuggerd"
|
||||
@ -157,15 +154,15 @@ static bool haveSiginfo(int signum) {
|
||||
sigemptyset(&newact.sa_mask);
|
||||
|
||||
if (sigaction(signum, &newact, &oldact) < 0) {
|
||||
__libc_android_log_write(ANDROID_LOG_FATAL, "libc",
|
||||
"Failed testing for SA_SIGINFO");
|
||||
return 0;
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", "Failed testing for SA_SIGINFO: %s",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
bool ret = (oldact.sa_flags & SA_SIGINFO) != 0;
|
||||
|
||||
if (sigaction(signum, &oldact, NULL) < 0) {
|
||||
__libc_android_log_write(ANDROID_LOG_FATAL, "libc",
|
||||
"Restore failed in test for SA_SIGINFO");
|
||||
if (sigaction(signum, &oldact, NULL) == -1) {
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", "Restore failed in test for SA_SIGINFO: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -42,7 +42,6 @@
|
||||
// Private C library headers.
|
||||
#include <private/bionic_tls.h>
|
||||
#include <private/KernelArgumentBlock.h>
|
||||
#include <private/logd.h>
|
||||
#include <private/ScopedPthreadMutexLocker.h>
|
||||
|
||||
#include "linker.h"
|
||||
@ -141,13 +140,13 @@ static unsigned bitmask[4096];
|
||||
|
||||
// You shouldn't try to call memory-allocating functions in the dynamic linker.
|
||||
// Guard against the most obvious ones.
|
||||
#define DISALLOW_ALLOCATION(return_type, name, ...) \
|
||||
return_type name __VA_ARGS__ \
|
||||
{ \
|
||||
#define DISALLOW_ALLOCATION(return_type, name, ...) \
|
||||
return_type name __VA_ARGS__ \
|
||||
{ \
|
||||
const char* msg = "ERROR: " #name " called from the dynamic linker!\n"; \
|
||||
__libc_android_log_write(ANDROID_LOG_FATAL, "linker", msg); \
|
||||
write(2, msg, strlen(msg)); \
|
||||
abort(); \
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "linker", "%s", msg); \
|
||||
write(2, msg, strlen(msg)); \
|
||||
abort(); \
|
||||
}
|
||||
#define UNUSED __attribute__((unused))
|
||||
DISALLOW_ALLOCATION(void*, malloc, (size_t u UNUSED));
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
#include <link.h>
|
||||
|
||||
#include <private/debug_format.h>
|
||||
#include "private/libc_logging.h"
|
||||
|
||||
#define DL_ERR(fmt, x...) \
|
||||
do { \
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
#include <private/debug_format.h>
|
||||
#include "private/libc_logging.h"
|
||||
|
||||
__LIBC_HIDDEN__ extern int gLdDebugVerbosity;
|
||||
|
||||
|
@ -57,11 +57,11 @@ test_c_flags = \
|
||||
-fno-builtin \
|
||||
|
||||
test_src_files = \
|
||||
debug_format_test.cpp \
|
||||
dirent_test.cpp \
|
||||
fenv_test.cpp \
|
||||
getauxval_test.cpp \
|
||||
getcwd_test.cpp \
|
||||
libc_logging_test.cpp \
|
||||
libgen_test.cpp \
|
||||
math_test.cpp \
|
||||
netdb_test.cpp \
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
#if defined(__BIONIC__)
|
||||
|
||||
#include "../libc/bionic/debug_format.cpp"
|
||||
#include "../libc/bionic/libc_logging.cpp"
|
||||
|
||||
extern int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...);
|
||||
|
||||
TEST(debug_format, smoke) {
|
||||
TEST(libc_logging, smoke) {
|
||||
char buf[BUFSIZ];
|
||||
|
||||
__libc_format_buffer(buf, sizeof(buf), "a");
|
||||
@ -106,37 +106,37 @@ TEST(debug_format, smoke) {
|
||||
EXPECT_STREQ("a68719476736,6,7,8z", buf);
|
||||
}
|
||||
|
||||
TEST(debug_format, d_INT_MAX) {
|
||||
TEST(libc_logging, d_INT_MAX) {
|
||||
char buf[BUFSIZ];
|
||||
__libc_format_buffer(buf, sizeof(buf), "%d", INT_MAX);
|
||||
EXPECT_STREQ("2147483647", buf);
|
||||
}
|
||||
|
||||
TEST(debug_format, d_INT_MIN) {
|
||||
TEST(libc_logging, d_INT_MIN) {
|
||||
char buf[BUFSIZ];
|
||||
__libc_format_buffer(buf, sizeof(buf), "%d", INT_MIN);
|
||||
EXPECT_STREQ("-2147483648", buf);
|
||||
}
|
||||
|
||||
TEST(debug_format, ld_LONG_MAX) {
|
||||
TEST(libc_logging, ld_LONG_MAX) {
|
||||
char buf[BUFSIZ];
|
||||
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
|
||||
EXPECT_STREQ("2147483647", buf);
|
||||
}
|
||||
|
||||
TEST(debug_format, ld_LONG_MIN) {
|
||||
TEST(libc_logging, ld_LONG_MIN) {
|
||||
char buf[BUFSIZ];
|
||||
__libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
|
||||
EXPECT_STREQ("-2147483648", buf);
|
||||
}
|
||||
|
||||
TEST(debug_format, lld_LLONG_MAX) {
|
||||
TEST(libc_logging, lld_LLONG_MAX) {
|
||||
char buf[BUFSIZ];
|
||||
__libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MAX);
|
||||
EXPECT_STREQ("9223372036854775807", buf);
|
||||
}
|
||||
|
||||
TEST(debug_format, lld_LLONG_MIN) {
|
||||
TEST(libc_logging, lld_LLONG_MIN) {
|
||||
char buf[BUFSIZ];
|
||||
__libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MIN);
|
||||
EXPECT_STREQ("-9223372036854775808", buf);
|
Loading…
Reference in New Issue
Block a user