Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc204a96 authored by Mark Salyzyn's avatar Mark Salyzyn Committed by Gerrit Code Review
Browse files

Merge changes Ia9509ad0,I4e815d74,I10e8d92c

* changes:
  logcat: test White Black list
  logd: Find log time for arbitrary time to tail
  logd: liblog: logcat: Arbitrary time to tail
parents 6ab10a1c 95cfc7b8
Loading
Loading
Loading
Loading
+27 −5
Original line number Original line Diff line number Diff line
@@ -17,11 +17,17 @@
#ifndef _LIBS_LOG_LOG_READ_H
#ifndef _LIBS_LOG_LOG_READ_H
#define _LIBS_LOG_LOG_READ_H
#define _LIBS_LOG_LOG_READ_H


#include <stdint.h>
#include <time.h>
#include <time.h>


/* struct log_time is a wire-format variant of struct timespec */
/* struct log_time is a wire-format variant of struct timespec */
#define NS_PER_SEC 1000000000ULL
#define NS_PER_SEC 1000000000ULL

#ifdef __cplusplus
#ifdef __cplusplus

// NB: do NOT define a copy constructor. This will result in structure
// no longer being compatible with pass-by-value which is desired
// efficient behavior. Also, pass-by-reference breaks C/C++ ABI.
struct log_time {
struct log_time {
public:
public:
    uint32_t tv_sec; // good to Feb 5 2106
    uint32_t tv_sec; // good to Feb 5 2106
@@ -32,16 +38,12 @@ public:
        tv_sec = T.tv_sec;
        tv_sec = T.tv_sec;
        tv_nsec = T.tv_nsec;
        tv_nsec = T.tv_nsec;
    }
    }
    log_time(const log_time &T)
    {
        tv_sec = T.tv_sec;
        tv_nsec = T.tv_nsec;
    }
    log_time(uint32_t sec, uint32_t nsec)
    log_time(uint32_t sec, uint32_t nsec)
    {
    {
        tv_sec = sec;
        tv_sec = sec;
        tv_nsec = nsec;
        tv_nsec = nsec;
    }
    }
    static const timespec EPOCH;
    log_time()
    log_time()
    {
    {
    }
    }
@@ -86,6 +88,12 @@ public:
    {
    {
        return !(*this > T);
        return !(*this > T);
    }
    }
    log_time operator-= (const timespec &T);
    log_time operator- (const timespec &T) const
    {
        log_time local(*this);
        return local -= T;
    }


    // log_time
    // log_time
    bool operator== (const log_time &T) const
    bool operator== (const log_time &T) const
@@ -114,17 +122,31 @@ public:
    {
    {
        return !(*this > T);
        return !(*this > T);
    }
    }
    log_time operator-= (const log_time &T);
    log_time operator- (const log_time &T) const
    {
        log_time local(*this);
        return local -= T;
    }


    uint64_t nsec() const
    uint64_t nsec() const
    {
    {
        return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
        return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
    }
    }

    static const char default_format[];

    // Add %#q for the fraction of a second to the standard library functions
    char *strptime(const char *s, const char *format = default_format);
} __attribute__((__packed__));
} __attribute__((__packed__));

#else
#else

typedef struct log_time {
typedef struct log_time {
    uint32_t tv_sec;
    uint32_t tv_sec;
    uint32_t tv_nsec;
    uint32_t tv_nsec;
} __attribute__((__packed__)) log_time;
} __attribute__((__packed__)) log_time;

#endif
#endif


#endif /* define _LIBS_LOG_LOG_READ_H */
#endif /* define _LIBS_LOG_LOG_READ_H */
+4 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@


#include <stdint.h>
#include <stdint.h>
#include <log/log.h>
#include <log/log.h>
#include <log/log_read.h>


#ifdef __cplusplus
#ifdef __cplusplus
extern "C" {
extern "C" {
@@ -161,6 +162,9 @@ int android_logger_set_prune_list(struct logger_list *logger_list,
struct logger_list *android_logger_list_alloc(int mode,
struct logger_list *android_logger_list_alloc(int mode,
                                              unsigned int tail,
                                              unsigned int tail,
                                              pid_t pid);
                                              pid_t pid);
struct logger_list *android_logger_list_alloc_time(int mode,
                                                   log_time start,
                                                   pid_t pid);
void android_logger_list_free(struct logger_list *logger_list);
void android_logger_list_free(struct logger_list *logger_list);
/* In the purest sense, the following two are orthogonal interfaces */
/* In the purest sense, the following two are orthogonal interfaces */
int android_logger_list_read(struct logger_list *logger_list,
int android_logger_list_read(struct logger_list *logger_list,
+4 −2
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ liblog_sources := logd_write.c
else
else
liblog_sources := logd_write_kern.c
liblog_sources := logd_write_kern.c
endif
endif
liblog_sources += log_time.cpp


ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),)
ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),)
liblog_cflags := -DUSERDEBUG_BUILD=1
liblog_cflags := -DUSERDEBUG_BUILD=1
@@ -60,13 +61,14 @@ endif
# ========================================================
# ========================================================
LOCAL_MODULE := liblog
LOCAL_MODULE := liblog
LOCAL_SRC_FILES := $(liblog_host_sources)
LOCAL_SRC_FILES := $(liblog_host_sources)
LOCAL_LDLIBS := -lpthread
LOCAL_LDLIBS := -lpthread -lrt
LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1
LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1
include $(BUILD_HOST_STATIC_LIBRARY)
include $(BUILD_HOST_STATIC_LIBRARY)


include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_MODULE := liblog
LOCAL_MODULE := liblog
LOCAL_WHOLE_STATIC_LIBRARIES := liblog
LOCAL_WHOLE_STATIC_LIBRARIES := liblog
LOCAL_LDLIBS := -lrt
include $(BUILD_HOST_SHARED_LIBRARY)
include $(BUILD_HOST_SHARED_LIBRARY)




@@ -75,7 +77,7 @@ include $(BUILD_HOST_SHARED_LIBRARY)
include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_MODULE := lib64log
LOCAL_MODULE := lib64log
LOCAL_SRC_FILES := $(liblog_host_sources)
LOCAL_SRC_FILES := $(liblog_host_sources)
LOCAL_LDLIBS := -lpthread
LOCAL_LDLIBS := -lpthread -lrt
LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1 -m64
LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1 -m64
include $(BUILD_HOST_STATIC_LIBRARY)
include $(BUILD_HOST_STATIC_LIBRARY)


+34 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <inttypes.h>
#include <signal.h>
#include <signal.h>
#include <stddef.h>
#include <stddef.h>
#define NOMINMAX /* for windows to suppress definition of min in stdlib.h */
#define NOMINMAX /* for windows to suppress definition of min in stdlib.h */
@@ -234,6 +235,7 @@ struct logger_list {
    struct listnode node;
    struct listnode node;
    int mode;
    int mode;
    unsigned int tail;
    unsigned int tail;
    log_time start;
    pid_t pid;
    pid_t pid;
    int sock;
    int sock;
};
};
@@ -441,6 +443,8 @@ struct logger_list *android_logger_list_alloc(int mode,


    list_init(&logger_list->node);
    list_init(&logger_list->node);
    logger_list->mode = mode;
    logger_list->mode = mode;
    logger_list->start.tv_sec = 0;
    logger_list->start.tv_nsec = 0;
    logger_list->tail = tail;
    logger_list->tail = tail;
    logger_list->pid = pid;
    logger_list->pid = pid;
    logger_list->sock = -1;
    logger_list->sock = -1;
@@ -448,6 +452,27 @@ struct logger_list *android_logger_list_alloc(int mode,
    return logger_list;
    return logger_list;
}
}


struct logger_list *android_logger_list_alloc_time(int mode,
                                                   log_time start,
                                                   pid_t pid)
{
    struct logger_list *logger_list;

    logger_list = calloc(1, sizeof(*logger_list));
    if (!logger_list) {
        return NULL;
    }

    list_init(&logger_list->node);
    logger_list->mode = mode;
    logger_list->start = start;
    logger_list->tail = 0;
    logger_list->pid = pid;
    logger_list->sock = -1;

    return logger_list;
}

/* android_logger_list_register unimplemented, no use case */
/* android_logger_list_register unimplemented, no use case */
/* android_logger_list_unregister unimplemented, no use case */
/* android_logger_list_unregister unimplemented, no use case */


@@ -564,6 +589,15 @@ int android_logger_list_read(struct logger_list *logger_list,
            cp += ret;
            cp += ret;
        }
        }


        if (logger_list->start.tv_sec || logger_list->start.tv_nsec) {
            ret = snprintf(cp, remaining, " start=%" PRIu32 ".%09" PRIu32,
                           logger_list->start.tv_sec,
                           logger_list->start.tv_nsec);
            ret = min(ret, remaining);
            remaining -= ret;
            cp += ret;
        }

        if (logger_list->pid) {
        if (logger_list->pid) {
            ret = snprintf(cp, remaining, " pid=%u", logger_list->pid);
            ret = snprintf(cp, remaining, " pid=%u", logger_list->pid);
            ret = min(ret, remaining);
            ret = min(ret, remaining);
+7 −0
Original line number Original line Diff line number Diff line
@@ -308,6 +308,13 @@ struct logger_list *android_logger_list_alloc(int mode,
    return logger_list;
    return logger_list;
}
}


struct logger_list *android_logger_list_alloc_time(int mode,
                                                   log_time start UNUSED,
                                                   pid_t pid)
{
    return android_logger_list_alloc(mode, 0, pid);
}

/* android_logger_list_register unimplemented, no use case */
/* android_logger_list_register unimplemented, no use case */
/* android_logger_list_unregister unimplemented, no use case */
/* android_logger_list_unregister unimplemented, no use case */


Loading