2 * Copyright (c) 2015-2016 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef log_encode_types_h
25 #define log_encode_types_h
28 * These are IPIs between xnu and libtrace, used to have common encoding
29 * and implementation for kernel logging and user logging. They are subject
30 * to change at any point.
39 #pragma mark - buffer support structures, enums
41 OS_ENUM(os_log_value_type
, uint8_t,
42 OS_LOG_BUFFER_VALUE_TYPE_SCALAR
= 0,
43 OS_LOG_BUFFER_VALUE_TYPE_COUNT
= 1,
44 OS_LOG_BUFFER_VALUE_TYPE_STRING
= 2,
46 OS_LOG_BUFFER_VALUE_TYPE_POINTER
= 3,
47 OS_LOG_BUFFER_VALUE_TYPE_OBJECT
= 4,
51 OS_ENUM(os_log_value_subtype
, uint8_t,
52 OS_LOG_BUFFER_VALUE_SUBTYPE_NONE
= 0,
53 OS_LOG_BUFFER_VALUE_SUBTYPE_INTEGER
= 1,
55 OS_LOG_BUFFER_VALUE_SUBTYPE_FLOAT
= 2,
59 enum os_log_int_types_t
{
70 union os_log_format_types_u
{
95 typedef struct os_log_format_value_s
{
96 union os_log_format_types_u type
;
97 os_log_value_type_t ctype
;
99 } *os_log_format_value_t
;
101 #define OST_FORMAT_MAX_ARGS 48
103 #define OST_FORMAT_MAX_STRING_SIZE 512
105 #define OST_FORMAT_MAX_STRING_SIZE 1024
108 #define OST_FORMAT_NON_STATIC ~0
110 typedef struct os_log_buffer_value_s
{
111 #define OS_LOG_CONTENT_FLAG_PRIVATE 0x1
113 os_log_value_type_t type
: 4;
116 } *os_log_buffer_value_t
;
118 typedef struct os_log_buffer_s
{
119 #define OS_LOG_BUFFER_HAS_PRIVATE 0x1
120 #define OS_LOG_BUFFER_HAS_NON_SCALAR 0x2
122 #define OS_LOG_BUFFER_MAX_SIZE 256
124 #define OS_LOG_BUFFER_MAX_SIZE 1024
131 typedef struct os_log_buffer_context_s
{
133 os_log_buffer_t buffer
;
143 uint16_t content_off
; // offset into buffer->content
144 uint16_t content_sz
; // size not including the header
145 uint16_t pubdata_off
;
147 uint16_t privdata_off
;
148 uint16_t privdata_sz
;
152 // if argument content was limited with %.* or %.#
155 const char *symptom_str
;
156 const void *symptom_ptr
;
157 uint16_t symptom_ptr_len
;
163 } *os_log_buffer_context_t
;
165 typedef struct os_log_arginfo_s
{
170 /* Clients of these interfaces/structures may be expected to provide implementations of the following functions */
174 _NSCF2data(const void *obj
, char *string_value
, size_t string_sz
, bool *is_private
);
178 _os_log_string_is_public(const char *str
);
180 #endif /* log_encode_types_h */