Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /* * Copyright (c) 2015-2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ #ifndef log_encode_types_h #define log_encode_types_h /* * These are IPIs between xnu and libtrace, used to have common encoding * and implementation for kernel logging and user logging. They are subject * to change at any point. */ #include <os/base.h> #include <os/log.h> #include <stdint.h> #include <stdbool.h> #include <stddef.h> #include "log_mem.h" #pragma mark - buffer support structures, enums OS_ENUM(os_log_fmt_hdr_flags, uint8_t, OSLF_HDR_FLAG_HAS_PRIVATE = 0x01, OSLF_HDR_FLAG_HAS_NON_SCALAR = 0x02, ); OS_ENUM(os_log_fmt_cmd_type, uint8_t, OSLF_CMD_TYPE_SCALAR = 0, // %u, %lld, %x, %p, %g, ... OSLF_CMD_TYPE_COUNT = 1, // %.16P, %.*s OSLF_CMD_TYPE_STRING = 2, // %s OSLF_CMD_TYPE_POINTER = 3, // %P OSLF_CMD_TYPE_OBJECT = 4, // %@ OSLF_CMD_TYPE_WIDE_STRING = 5, // %S OSLF_CMD_TYPE_ERRNO = 6, // %m OSLF_CMD_TYPE_MASK = 7, // %{mask.foo}... ); OS_ENUM(os_log_fmt_cmd_flags, uint8_t, OSLF_CMD_FLAG_PRIVATE = 0x1, OSLF_CMD_FLAG_PUBLIC = 0x2, OSLF_CMD_FLAG_SENSITIVE = 0x4 | OSLF_CMD_FLAG_PRIVATE, ); enum os_log_int_types_t { OST_CHAR = -2, OST_SHORT = -1, OST_INT = 0, OST_LONG = 1, OST_LONGLONG = 2, OST_SIZE = 3, OST_INTMAX = 4, OST_PTRDIFF = 5, }; union os_log_fmt_types_u { uint16_t u16; uint32_t u32; uint64_t u64; char ch; short s; int i; void *p; char *pch; size_t z; intmax_t im; ptrdiff_t pd; long l; long long ll; }; typedef struct os_log_format_value_s { union os_log_fmt_types_u type; os_log_fmt_cmd_type_t ctype; uint16_t size; } *os_log_format_value_t; typedef struct os_log_fmt_hdr_s { os_log_fmt_hdr_flags_t hdr_flags; uint8_t hdr_cmd_cnt; uint8_t hdr_data[]; } *os_log_fmt_hdr_t; typedef struct os_log_fmt_cmd_s { os_log_fmt_cmd_flags_t cmd_flags : 4; os_log_fmt_cmd_type_t cmd_type : 4; uint8_t cmd_size; uint8_t cmd_data[]; } *os_log_fmt_cmd_t; typedef struct os_log_fmt_range_s { uint16_t offset; uint16_t length : 15; uint16_t truncated : 1; } *os_log_fmt_range_t; #define OS_LOG_MAX_PUB_ARGS (32) typedef struct os_log_context_s { logmem_t *ctx_logmem; uint8_t *ctx_buffer; size_t ctx_buffer_sz; os_log_fmt_hdr_t ctx_hdr; char *ctx_pubdata[OS_LOG_MAX_PUB_ARGS]; uint16_t ctx_content_off; // offset into buffer->hdr_data uint16_t ctx_content_sz; // size not including the header uint16_t ctx_pubdata_sz; uint16_t ctx_pubdata_cnt; firehose_tracepoint_flags_t ctx_ft_flags; uint8_t ctx_truncated : 1; uint8_t ctx_allocated : 1; } *os_log_context_t; #endif /* log_encode_types_h */ |