Merge "system/core: preparation to pull back interfaces from android/log.h"

This commit is contained in:
Mark Salyzyn 2016-10-20 17:53:45 +00:00 committed by Gerrit Code Review
commit 27d2d49f48
62 changed files with 144 additions and 80 deletions

View File

@ -45,7 +45,7 @@
// Headers for LogMessage::LogLine.
#ifdef __ANDROID__
#include <android/log.h>
#include <log/log.h>
#include <android/set_abort_message.h>
#else
#include <sys/types.h>

View File

@ -20,7 +20,7 @@
#include <memory>
#include <string>
#include <android/log.h>
#include <log/log.h>
#include <android-base/logging.h>
namespace {

View File

@ -18,9 +18,9 @@
#include <inttypes.h>
#include <android/log.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <log/log.h>
using testing::ElementsAreArray;

View File

@ -19,8 +19,8 @@
#include <cstdlib>
#include <memory>
#include <android/log.h>
#include <android-base/logging.h>
#include <log/log.h>
#include "event_log_list_builder.h"

View File

@ -1,3 +1,21 @@
/*
* Copyright 2006, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "crasher"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "debuggerd"
#include <arpa/inet.h>
#include <dirent.h>
#include <elf.h>

View File

@ -26,6 +26,7 @@
#include <sys/ioctl.h>
#include <sys/limits.h>
#include <sys/poll.h>
#include <unistd.h>
#include <memory>

View File

@ -14,7 +14,10 @@
* limitations under the License.
*/
#define LOG_TAG "debuggerd-signal"
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>

View File

@ -19,8 +19,8 @@
#include <string>
#include <android/log.h>
#include <android-base/stringprintf.h>
#include <log/log.h>
// Forward declarations.
class Backtrace;

View File

@ -36,6 +36,7 @@
#include <backtrace/Backtrace.h>
#include <backtrace/BacktraceMap.h>
#include <cutils/properties.h>
#include <log/log.h>
#include <log/logprint.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -27,9 +27,9 @@
#include <string>
#include <android/log.h>
#include <android-base/stringprintf.h>
#include <backtrace/Backtrace.h>
#include <log/log.h>
// Whitelist output desired in the logcat output.
bool is_allowed_in_logcat(enum logtype ltype) {

View File

@ -17,7 +17,7 @@
#include <string>
#endif
#include <android/log.h>
#include <log/log.h>
#ifdef __cplusplus
extern "C" {

View File

@ -30,7 +30,7 @@
#include <sys/types.h>
#include <android/log.h>
#include <log/log.h>
#ifdef __cplusplus

View File

@ -21,7 +21,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <android/log.h>
#include <log/log.h>
#include <utils/TypeHelpers.h>
#include <utils/Vector.h>
#include <utils/VectorImpl.h>

View File

@ -22,7 +22,7 @@
#include <new>
#include <android/log.h>
#include <log/log.h>
#include <utils/TypeHelpers.h>
#include <utils/VectorImpl.h>

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "backtrace-map"
#include <ctype.h>
#include <inttypes.h>
#include <stdint.h>

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "dlmalloc-stubs"
#include "android/log.h"
#define UNUSED __attribute__((__unused__))

View File

@ -25,6 +25,7 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

View File

@ -23,7 +23,7 @@
#include <string.h>
#include <unistd.h>
#include <android/log.h>
#include <log/log.h>
#include <cutils/sched_policy.h>
#define UNUSED __attribute__((__unused__))

View File

@ -14,7 +14,11 @@
* limitations under the License.
*/
#define LOG_TAG "socket-unix"
#include <sys/uio.h>
#include <time.h>
#include <unistd.h>
#include <android/log.h>
#include <cutils/sockets.h>

View File

@ -27,6 +27,7 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <android/log.h>
#include <ion/ion.h>

View File

@ -1,12 +1,18 @@
LIBLOG(3) Android NDK Programming Manual LIBLOG(3)
LIBLOG(3) Android Internal NDK Programming Manual LIBLOG(3)
NAME
liblog - Android NDK logger interfaces
liblog - Android Internal NDK logger interfaces
SYNOPSIS
#include <android/log.h>
/*
* Please limit to 24 characters for runtime is loggable,
* 16 characters for persist is loggable, and logcat pretty
* alignment with limit of 7 characters.
*/
#define LOG_TAG "yourtag"
#include <log/log.h>
ALOG(android_priority, tag, format, ...)
IF_ALOG(android_priority, tag)
@ -66,21 +72,44 @@ SYNOPSIS
int android_logger_get_log_readable_size(struct logger *logger)
int android_logger_get_log_version(struct logger *logger)
struct logger_list *android_logger_list_alloc(int mode, unsigned int
tail, pid_t pid)
struct logger *android_logger_open(struct logger_list *logger_list,
log_id_t id)
struct logger_list *android_logger_list_open(log_id_t id, int mode,
unsigned int tail, pid_t pid)
int android_logger_list_read(struct logger_list *logger_list, struct
log_msg *log_msg
struct logger_list *android_logger_list_alloc(int mode,
unsigned int tail,
pid_t pid)
struct logger *android_logger_open(struct logger_list *logger_list,
log_id_t id)
struct logger_list *android_logger_list_open(log_id_t id, int mode,
unsigned int tail,
pid_t pid)
int android_logger_list_read(struct logger_list *logger_list,
struct log_msg *log_msg)
void android_logger_list_free(struct logger_list *logger_list)
log_id_t android_name_to_log_id(const char *logName)
const char *android_log_id_to_name(log_id_t log_id)
android_log_context create_android_logger(uint32_t tag)
int android_log_write_list_begin(android_log_context ctx)
int android_log_write_list_end(android_log_context ctx)
int android_log_write_int32(android_log_context ctx, int32_t value)
int android_log_write_int64(android_log_context ctx, int64_t value)
int android_log_write_string8(android_log_context ctx,
const char *value)
int android_log_write_string8_len(android_log_context ctx,
const char *value, size_t maxlen)
int android_log_write_float32(android_log_context ctx, float value)
int android_log_write_list(android_log_context ctx,
log_id_t id = LOG_ID_EVENTS)
android_log_context create_android_log_parser(const char *msg,
size_t len)
android_log_list_element android_log_read_next(android_log_context ctx)
android_log_list_element android_log_peek_next(android_log_context ctx)
int android_log_destroy(android_log_context *ctx)
Link with -llog
DESCRIPTION
@ -163,8 +192,8 @@ ERRORS
library retries on EINTR, -EINTR should never be returned.
SEE ALSO
syslogd(8)
syslogd(8), klogd, auditd(8)
24 Jan 2014 LIBLOG(3)
17 Oct 2016 LIBLOG(3)

View File

@ -19,6 +19,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>

View File

@ -25,10 +25,14 @@
#if !defined(_WIN32)
#include <pthread.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <android/log.h>
#include <log/uio.h>
#include "fake_log_device.h"
#include "log_portability.h"

View File

@ -18,7 +18,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <android/log.h>
#include <log/log.h>
#include "config_write.h"
#include "fake_log_device.h"

View File

@ -15,8 +15,9 @@
*/
#include <errno.h>
#include <stdint.h>
#include <android/log.h>
#include <log/log.h>
#include "log_portability.h"

View File

@ -31,9 +31,7 @@
#include <time.h>
#include <unistd.h>
#include <android/log.h>
#include <cutils/sockets.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -32,7 +32,6 @@
#include <unistd.h>
#include <cutils/sockets.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -19,11 +19,11 @@
#include <stdatomic.h>
#include <stdbool.h>
#include <log/uio.h>
#include <android/log.h>
#include <cutils/list.h>
#include <log/logger.h>
#include <log/uio.h>
#include "log_portability.h"

View File

@ -25,7 +25,6 @@
#include <android/log.h>
#include <cutils/list.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>
#include "config_read.h"

View File

@ -24,9 +24,7 @@
#include <android/set_abort_message.h>
#endif
#include <android/log.h>
#include <log/event_tag_map.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -26,9 +26,6 @@
#include <sys/types.h>
#include <time.h>
#include <android/log.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -20,9 +20,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <android/log.h>
#include <cutils/sockets.h>
#include <log/logger.h>
#include <private/android_logger.h>
#include "benchmark.h"

View File

@ -27,12 +27,10 @@
#include <string>
#include <android/log.h>
#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <cutils/properties.h>
#include <gtest/gtest.h>
#include <log/logger.h>
#include <log/logprint.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "nativebridge"
#include "nativebridge/native_bridge.h"
#include <dlfcn.h>
@ -22,6 +24,7 @@
#include <stdio.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <unistd.h>
#include <cstring>

View File

@ -14,6 +14,7 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#define LOG_TAG "pixelflinger-code"
#include <errno.h>
#include <stdint.h>

View File

@ -15,6 +15,8 @@
** limitations under the License.
*/
#define LOG_TAG "pixelflinger-code"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>

View File

@ -15,6 +15,8 @@
** limitations under the License.
*/
#define LOG_TAG "pixelflinger-code"
#include <assert.h>
#include <stdio.h>

View File

@ -15,6 +15,8 @@
** limitations under the License.
*/
#define LOG_TAG "pixelflinger-code"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>

View File

@ -15,6 +15,8 @@
** limitations under the License.
*/
#define LOG_TAG "pixelflinger-trap"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -18,7 +18,7 @@
#include <errno.h>
#include <android/log.h>
#include <log/log.h>
#include <sysutils/FrameworkCommand.h>
#define UNUSED __attribute__((unused))

View File

@ -19,8 +19,9 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <android/log.h>
#include <log/log.h>
#include <sysutils/FrameworkCommand.h>
#include <sysutils/FrameworkListener.h>
#include <sysutils/SocketClient.h>

View File

@ -41,7 +41,7 @@
const int LOCAL_QLOG_NL_EVENT = 112;
const int LOCAL_NFLOG_PACKET = NFNL_SUBSYS_ULOG << 8 | NFULNL_MSG_PACKET;
#include <android/log.h>
#include <log/log.h>
#include <sysutils/NetlinkEvent.h>
NetlinkEvent::NetlinkEvent() {

View File

@ -20,11 +20,12 @@
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/netlink.h> /* out of order because must follow sys/socket.h */
#include <android/log.h>
#include <cutils/uevent.h>
#include <log/log.h>
#include <sysutils/NetlinkEvent.h>
#if 1

View File

@ -17,10 +17,12 @@
#define LOG_TAG "Service"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <android/log.h>
#include <cutils/properties.h>
#include <log/log.h>
#include <sysutils/ServiceManager.h>
ServiceManager::ServiceManager() {

View File

@ -25,8 +25,9 @@
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <android/log.h>
#include <log/log.h>
#include <sysutils/SocketClient.h>
SocketClient::SocketClient(int socket, bool owned) {

View File

@ -24,9 +24,10 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <android/log.h>
#include <cutils/sockets.h>
#include <log/log.h>
#include <sysutils/SocketListener.h>
#include <sysutils/SocketClient.h>

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "sharedbuffer"
#include <stdlib.h>
#include <string.h>

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "unicode"
#include <limits.h>
#include <stddef.h>

View File

@ -18,6 +18,8 @@
* Read-only access to Zip archives, with minimal heap allocation.
*/
#define LOG_TAG "ziparchive"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
@ -30,11 +32,11 @@
#include <memory>
#include <vector>
#include <android/log.h>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h> // TEMP_FAILURE_RETRY may or may not be in unistd
#include <android-base/memory.h>
#include <log/log.h>
#include <utils/Compat.h>
#include <utils/FileMap.h>
#include "ziparchive/zip_archive.h"

View File

@ -18,6 +18,7 @@
#include <arpa/inet.h>
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>

View File

@ -25,7 +25,6 @@
#include <sys/uio.h>
#include <syslog.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -22,7 +22,6 @@
#include <time.h>
#include <unistd.h>
#include <log/logger.h>
#include <private/android_logger.h>
#include "LogBuffer.h"

View File

@ -23,7 +23,6 @@
#include <unistd.h>
#include <cutils/sockets.h>
#include <log/logger.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

View File

@ -20,8 +20,8 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <android/log.h>
#include <sysutils/SocketClient.h>
#include <log/log.h>
// Hijack this header as a common include file used by most all sources
// to report some utilities defined here and there.

View File

@ -18,26 +18,20 @@
*
*/
#define LOG_TAG "libaudit"
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <android/log.h>
#include "libaudit.h"
/**
* Waits for an ack from the kernel
* @param fd
* The netlink socket fd
* @param seq
* The current sequence number were acking on
* @return
* This function returns 0 on success, else -errno.
*/
static int get_ack(int fd, int16_t seq)
static int get_ack(int fd)
{
int rc;
struct audit_message rep;
@ -60,11 +54,6 @@ static int get_ack(int fd, int16_t seq)
}
}
if ((int16_t)rep.nlh.nlmsg_seq != seq) {
SLOGW("Expected sequence number between user space and kernel space is out of skew, "
"expected %u got %u", seq, rep.nlh.nlmsg_seq);
}
return 0;
}
@ -109,7 +98,6 @@ static int audit_send(int fd, int type, const void *data, size_t size)
/* Ensure the message is not too big */
if (NLMSG_SPACE(size) > MAX_AUDIT_MESSAGE_LENGTH) {
SLOGE("netlink message is too large");
return -EINVAL;
}
@ -140,7 +128,6 @@ static int audit_send(int fd, int type, const void *data, size_t size)
/* Not all the bytes were sent */
if (rc < 0) {
rc = -errno;
SLOGE("Error sending data over the netlink socket: %s", strerror(-errno));
goto out;
} else if ((uint32_t) rc != req.nlh.nlmsg_len) {
rc = -EPROTO;
@ -148,7 +135,7 @@ static int audit_send(int fd, int type, const void *data, size_t size)
}
/* We sent all the bytes, get the ack */
rc = get_ack(fd, sequence);
rc = get_ack(fd);
/* If the ack failed, return the error, else return the sequence number */
rc = (rc == 0) ? (int) sequence : rc;
@ -156,7 +143,6 @@ static int audit_send(int fd, int type, const void *data, size_t size)
out:
/* Don't let sequence roll to negative */
if (sequence < 0) {
SLOGW("Auditd to Kernel sequence number has rolled over");
sequence = 0;
}
@ -183,7 +169,6 @@ int audit_setup(int fd, uint32_t pid)
/* Let the kernel know this pid will be registering for audit events */
rc = audit_send(fd, AUDIT_SET, &status, sizeof(status));
if (rc < 0) {
SLOGE("Could net set pid for audit events, error: %s", strerror(-rc));
return rc;
}
@ -241,25 +226,21 @@ int audit_get_reply(int fd, struct audit_message *rep, reply_t block, int peek)
/* If request is non blocking and errno is EAGAIN, just return 0 */
return 0;
}
SLOGE("Error receiving from netlink socket, error: %s", strerror(-rc));
return rc;
}
if (nladdrlen != sizeof(nladdr)) {
SLOGE("Protocol fault, error: %s", strerror(EPROTO));
return -EPROTO;
}
/* Make sure the netlink message was not spoof'd */
if (nladdr.nl_pid) {
SLOGE("Invalid netlink pid received, expected 0 got: %d", nladdr.nl_pid);
return -EINVAL;
}
/* Check if the reply from the kernel was ok */
if (!NLMSG_OK(&rep->nlh, (size_t)len)) {
rc = (len == sizeof(*rep)) ? -EFBIG : -EBADE;
SLOGE("Bad kernel response %s", strerror(-rc));
}
return rc;
@ -267,9 +248,5 @@ int audit_get_reply(int fd, struct audit_message *rep, reply_t block, int peek)
void audit_close(int fd)
{
int rc = close(fd);
if (rc < 0) {
SLOGE("Attempting to close invalid fd %d, error: %s", fd, strerror(errno));
}
return;
close(fd);
}

View File

@ -17,8 +17,10 @@
#define LOG_TAG "TrustyGateKeeper"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <android/log.h>
#include <trusty/tipc.h>

View File

@ -21,6 +21,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <android/log.h>
#include <trusty/tipc.h>

View File

@ -22,6 +22,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <android/log.h>

View File

@ -20,6 +20,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <android/log.h>
#include <hardware/nvram.h>

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/uio.h>
#include <unistd.h>
#include <trusty/tipc.h>

View File

@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/major.h>
#include <linux/mmc/ioctl.h>