1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/* This file is used to define the internal protocol for the Android Logger */ 18 19#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ 20#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ 21 22#include <stdint.h> 23 24#include <log/log.h> 25#include <log/log_read.h> 26 27#define LOGGER_MAGIC 'l' 28 29/* Header Structure to pstore */ 30typedef struct __attribute__((__packed__)) { 31 uint8_t magic; 32 uint16_t len; 33 uint16_t uid; 34 uint16_t pid; 35} android_pmsg_log_header_t; 36 37/* Header Structure to logd, and second header for pstore */ 38typedef struct __attribute__((__packed__)) { 39 typeof_log_id_t id; 40 uint16_t tid; 41 log_time realtime; 42} android_log_header_t; 43 44/* Event Header Structure to logd */ 45typedef struct __attribute__((__packed__)) { 46 int32_t tag; // Little Endian Order 47} android_event_header_t; 48 49/* Event payload EVENT_TYPE_INT */ 50typedef struct __attribute__((__packed__)) { 51 int8_t type; // EVENT_TYPE_INT 52 int32_t data; // Little Endian Order 53} android_event_int_t; 54 55/* Event with single EVENT_TYPE_INT */ 56typedef struct __attribute__((__packed__)) { 57 android_event_header_t header; 58 android_event_int_t payload; 59} android_log_event_int_t; 60 61/* Event payload EVENT_TYPE_LONG */ 62typedef struct __attribute__((__packed__)) { 63 int8_t type; // EVENT_TYPE_LONG 64 int64_t data; // Little Endian Order 65} android_event_long_t; 66 67/* Event with single EVENT_TYPE_LONG */ 68typedef struct __attribute__((__packed__)) { 69 android_event_header_t header; 70 android_event_long_t payload; 71} android_log_event_long_t; 72 73/* 74 * Event payload EVENT_TYPE_STRING 75 * 76 * Danger: do not embed this structure into another structure. 77 * This structure uses a flexible array member, and when 78 * compiled using g++, __builtin_object_size(data, 1) returns 79 * a bad value. This is possibly a g++ bug, or a bug due to 80 * the fact that flexible array members are not supported 81 * in C++. 82 * http://stackoverflow.com/questions/4412749/are-flexible-array-members-valid-in-c 83 */ 84typedef struct __attribute__((__packed__)) { 85 int8_t type; // EVENT_TYPE_STRING; 86 int32_t length; // Little Endian Order 87 char data[]; 88} android_event_string_t; 89 90/* Event with single EVENT_TYPE_STRING */ 91typedef struct __attribute__((__packed__)) { 92 android_event_header_t header; 93 int8_t type; // EVENT_TYPE_STRING; 94 int32_t length; // Little Endian Order 95 char data[]; 96} android_log_event_string_t; 97 98#endif 99