mirror of
https://github.com/darlinghq/darling.git
synced 2024-11-23 12:19:43 +00:00
Solving unresolved symbols in Security.framework to make MacPorts happy
This commit is contained in:
parent
8233d93aca
commit
fe8b8b6ff9
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -304,3 +304,6 @@
|
||||
[submodule "src/external/usertemplate"]
|
||||
path = src/external/usertemplate
|
||||
url = ../darling-usertemplate.git
|
||||
[submodule "src/external/libtrace"]
|
||||
path = src/external/libtrace
|
||||
url = ../darling-libtrace.git
|
||||
|
@ -30,6 +30,7 @@ FUNCTION(use_ld64 target)
|
||||
-Wl,-dylib_file,/usr/lib/system/libsystem_duct.dylib:${CMAKE_BINARY_DIR}/src/duct/src/libsystem_duct_firstpass.dylib \
|
||||
-Wl,-dylib_file,/usr/lib/system/libsystem_pthread.dylib:${CMAKE_BINARY_DIR}/src/external/libpthread/src/libsystem_pthread_firstpass.dylib \
|
||||
-Wl,-dylib_file,/usr/lib/system/libsystem_platform.dylib:${CMAKE_BINARY_DIR}/src/external/libplatform/libplatform_firstpass.dylib \
|
||||
-Wl,-dylib_file,/usr/lib/system/libsystem_trace.dylib:${CMAKE_BINARY_DIR}/src/external/libtrace/libsystem_trace_firstpass.dylib \
|
||||
-Wl,-dylib_file,/usr/lib/system/libcorecrypto.dylib:${CMAKE_BINARY_DIR}/src/external/corecrypto/libcorecrypto_firstpass.dylib \
|
||||
-Wl,-dylib_file,/usr/lib/system/libsystem_coretls.dylib:${CMAKE_BINARY_DIR}/src/external/coretls/libsystem_coretls.dylib \
|
||||
-Wl,-dylib_file,/usr/lib/system/libcommonCrypto.dylib:${CMAKE_BINARY_DIR}/src/external/commoncrypto/libcommonCrypto.dylib \
|
||||
|
@ -137,9 +137,6 @@
|
||||
#define __MAC_10_12_1 101201
|
||||
#define __MAC_10_12_2 101202
|
||||
#define __MAC_10_12_4 101204
|
||||
#define __MAC_10_13 101300
|
||||
#define __MAC_10_13_1 101301
|
||||
#define __MAC_10_13_2 101302
|
||||
/* __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
|
||||
|
||||
#define __IPHONE_2_0 20000
|
||||
@ -171,9 +168,6 @@
|
||||
#define __IPHONE_10_1 100100
|
||||
#define __IPHONE_10_2 100200
|
||||
#define __IPHONE_10_3 100300
|
||||
#define __IPHONE_11_0 110000
|
||||
#define __IPHONE_11_1 110100
|
||||
#define __IPHONE_11_2 110200
|
||||
/* __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */
|
||||
|
||||
#define __TVOS_9_0 90000
|
||||
@ -183,9 +177,6 @@
|
||||
#define __TVOS_10_0_1 100001
|
||||
#define __TVOS_10_1 100100
|
||||
#define __TVOS_10_2 100200
|
||||
#define __TVOS_11_0 110000
|
||||
#define __TVOS_11_1 110100
|
||||
#define __TVOS_11_2 110200
|
||||
|
||||
#define __WATCHOS_1_0 10000
|
||||
#define __WATCHOS_2_0 20000
|
||||
@ -195,9 +186,6 @@
|
||||
#define __WATCHOS_3_1 30100
|
||||
#define __WATCHOS_3_1_1 30101
|
||||
#define __WATCHOS_3_2 30200
|
||||
#define __WATCHOS_4_0 40000
|
||||
#define __WATCHOS_4_1 40100
|
||||
#define __WATCHOS_4_2 40200
|
||||
|
||||
#include <AvailabilityInternal.h>
|
||||
|
||||
@ -381,86 +369,51 @@
|
||||
Macros for defining which versions/platform a given symbol can be used.
|
||||
|
||||
@see http://clang.llvm.org/docs/AttributeReference.html#availability
|
||||
|
||||
* Note that these macros are only compatible with clang compilers that
|
||||
* support the following target selection options:
|
||||
*
|
||||
* -mmacosx-version-min
|
||||
* -miphoneos-version-min
|
||||
* -mwatchos-version-min
|
||||
* -mtvos-version-min
|
||||
* -mbridgeos-version-min
|
||||
*/
|
||||
|
||||
#if defined(__has_feature) && defined(__has_attribute)
|
||||
#if __has_attribute(availability)
|
||||
|
||||
/*
|
||||
* API Introductions
|
||||
*
|
||||
* Use to specify the release that a particular API became available.
|
||||
*
|
||||
* Platform names:
|
||||
* macos, ios, tvos, watchos
|
||||
*
|
||||
* Examples:
|
||||
* __API_AVAILABLE(macos(10.10))
|
||||
* __API_AVAILABLE(macos(10.9), ios(10.0))
|
||||
* __API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0))
|
||||
*/
|
||||
#define __API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE5, __API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
|
||||
/*
|
||||
* API Introductions
|
||||
*
|
||||
* Use to specify the release that a particular API became available.
|
||||
*
|
||||
* Platform names:
|
||||
* macos, ios, tvos, watchos
|
||||
*
|
||||
* Examples:
|
||||
* __API_AVAILABLE(macos(10.10))
|
||||
* __API_AVAILABLE(macos(10.9), ios(10.0))
|
||||
* __API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0))
|
||||
*/
|
||||
#define __API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
|
||||
/*
|
||||
* API Deprecations
|
||||
*
|
||||
* Use to specify the release that a particular API became unavailable.
|
||||
*
|
||||
* Platform names:
|
||||
* macos, ios, tvos, watchos
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* __API_DEPRECATED("No longer supported", macos(10.4, 10.8))
|
||||
* __API_DEPRECATED("No longer supported", macos(10.4, 10.8), ios(2.0, 3.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
*
|
||||
* __API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0))
|
||||
* __API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0))
|
||||
*/
|
||||
#define __API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG6,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1)(__VA_ARGS__)
|
||||
#define __API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP6,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1)(__VA_ARGS__)
|
||||
/*
|
||||
* API Deprecations
|
||||
*
|
||||
* Use to specify the release that a particular API became unavailable.
|
||||
*
|
||||
* Platform names:
|
||||
* macos, ios, tvos, watchos
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* __API_DEPRECATED("No longer supported", macos(10.4, 10.8))
|
||||
* __API_DEPRECATED("No longer supported", macos(10.4, 10.8), ios(2.0, 3.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
*
|
||||
* __API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0))
|
||||
* __API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0))
|
||||
*/
|
||||
#define __API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1)(__VA_ARGS__)
|
||||
#define __API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1)(__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* API Unavailability
|
||||
* Use to specify that an API is unavailable for a particular platform.
|
||||
*
|
||||
* Example:
|
||||
* __API_UNAVAILABLE(macos)
|
||||
* __API_UNAVAILABLE(watchos, tvos)
|
||||
*/
|
||||
#define __API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE4,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1)(__VA_ARGS__)
|
||||
#else
|
||||
|
||||
/*
|
||||
* Evaluate to nothing for compilers that don't support availability.
|
||||
*/
|
||||
|
||||
#define __API_AVAILABLE(...)
|
||||
#define __API_DEPRECATED(...)
|
||||
#define __API_DEPRECATED_WITH_REPLACEMENT(...)
|
||||
#define __API_UNAVAILABLE(...)
|
||||
#endif /* __has_attribute(availability) */
|
||||
#else
|
||||
|
||||
/*
|
||||
* Evaluate to nothing for compilers that don't support clang language extensions.
|
||||
*/
|
||||
|
||||
#define __API_AVAILABLE(...)
|
||||
#define __API_DEPRECATED(...)
|
||||
#define __API_DEPRECATED_WITH_REPLACEMENT(...)
|
||||
#define __API_UNAVAILABLE(...)
|
||||
#endif /* #if defined(__has_feature) && defined(__has_attribute) */
|
||||
/*
|
||||
* API Unavailability
|
||||
* Use to specify that an API is unavailable for a particular platform.
|
||||
*
|
||||
* Example:
|
||||
* __API_UNAVAILABLE(macos)
|
||||
* __API_UNAVAILABLE(watchos, tvos)
|
||||
*/
|
||||
#define __API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
#endif /* __AVAILABILITY__ */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* @APPLE_OSREFERENCE_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.
|
||||
*
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* 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,
|
||||
@ -17,25 +22,22 @@
|
||||
* 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@
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_ACTIVITY_H__
|
||||
#define __OS_ACTIVITY_H__
|
||||
|
||||
#include <os/object.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <mach-o/loader.h>
|
||||
#include <MacTypes.h>
|
||||
#include <os/trace_base.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if ((defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0) \
|
||||
|| (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0) \
|
||||
|| (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0) \
|
||||
|| (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12))
|
||||
OS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#pragma mark - types and globals
|
||||
|
||||
#if OS_LOG_TARGET_HAS_10_12_FEATURES
|
||||
#define OS_ACTIVITY_OBJECT_API 1
|
||||
#else
|
||||
#if OS_ACTIVITY_OBJECT_API
|
||||
@ -44,21 +46,6 @@ __BEGIN_DECLS
|
||||
#define OS_ACTIVITY_OBJECT_API 0
|
||||
#endif
|
||||
|
||||
extern void* __dso_handle;
|
||||
|
||||
#define OS_LOG_STRING(_var, _str) \
|
||||
_Static_assert(__builtin_constant_p(_str), "formatters/labels/descriptions must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) static const char _var[] __asm(OS_STRINGIFY(OS_CONCAT(LOSACTIVITY_, __COUNTER__))) = _str
|
||||
|
||||
/*!
|
||||
* @typedef os_breadcrumb_t
|
||||
* An opaque value for the breadcrumb ID.
|
||||
*/
|
||||
__API_DEPRECATED("No longer supported", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
typedef uint32_t os_breadcrumb_t;
|
||||
|
||||
#define OS_ACTIVITY_NULL 0
|
||||
|
||||
/*!
|
||||
* @enum os_activity_flag_t
|
||||
*
|
||||
@ -69,14 +56,19 @@ typedef uint32_t os_breadcrumb_t;
|
||||
* Use the default flags.
|
||||
*
|
||||
* @constant OS_ACTIVITY_FLAG_DETACHED
|
||||
* Detach the newly created activity from the provided activity (if any). If passed in conjunction
|
||||
* with an exiting activity, the activity will only note what activity "created" the new one, but
|
||||
* will make the new activity a top level activity. This allows users to see what activity triggered
|
||||
* work without actually relating the activities.
|
||||
* Detach the newly created activity from the provided activity (if any). If
|
||||
* passed in conjunction with an exiting activity, the activity will only note
|
||||
* what activity "created" the new one, but will make the new activity a top
|
||||
* level activity. This allows users to see what activity triggered work
|
||||
* without actually relating the activities.
|
||||
*
|
||||
* @constant OS_ACTIVITY_FLAG_IF_NONE_PRESENT
|
||||
* Will only create a new activity if none present. If an activity ID is already present, a new object
|
||||
* will be returned with the same activity ID underneath.
|
||||
* Will only create a new activity if none present. If an activity ID is
|
||||
* already present, a new object will be returned with the same activity ID
|
||||
* underneath.
|
||||
*
|
||||
* Passing both OS_ACTIVITY_FLAG_DETACHED and OS_ACTIVITY_FLAG_IF_NONE_PRESENT
|
||||
* is undefined.
|
||||
*/
|
||||
OS_ENUM(os_activity_flag, uint32_t,
|
||||
OS_ACTIVITY_FLAG_DEFAULT = 0,
|
||||
@ -92,7 +84,7 @@ OS_ENUM(os_activity_flag, uint32_t,
|
||||
* @typedef os_activity_t
|
||||
* An opaque activity object.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
#if OS_OBJECT_USE_OBJC
|
||||
OS_OBJECT_DECL(os_activity);
|
||||
#else
|
||||
@ -107,7 +99,7 @@ typedef struct os_activity_s *os_activity_t;
|
||||
* detached activity.
|
||||
*/
|
||||
#define OS_ACTIVITY_NONE OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_none)
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT
|
||||
const struct os_activity_s _os_activity_none;
|
||||
|
||||
@ -119,7 +111,7 @@ const struct os_activity_s _os_activity_none;
|
||||
* If no activity is present it is treated as if it is detached.
|
||||
*/
|
||||
#define OS_ACTIVITY_CURRENT OS_OBJECT_GLOBAL_OBJECT(os_activity_t, _os_activity_current)
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT
|
||||
const struct os_activity_s _os_activity_current;
|
||||
|
||||
@ -131,7 +123,7 @@ const struct os_activity_s _os_activity_current;
|
||||
* @typedef os_activity_t
|
||||
* An opaque activity identifier.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
typedef uint64_t os_activity_t;
|
||||
|
||||
#endif // OS_ACTIVITY_OBJECT_API
|
||||
@ -140,39 +132,40 @@ typedef uint64_t os_activity_t;
|
||||
* @typedef os_activity_id_t
|
||||
* An value representing the activity ID assigned to an newly created activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
typedef uint64_t os_activity_id_t;
|
||||
|
||||
#if !defined(__TRACE_BUILDING_TRACE__)
|
||||
/*!
|
||||
* @typedef os_activity_scope_state_t
|
||||
* Structure that is populated by os_activity_scope_enter and restored using
|
||||
* os_activity_scope_leave.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
typedef struct os_activity_scope_state_s {
|
||||
uint64_t opaque[2];
|
||||
} *os_activity_scope_state_t;
|
||||
#else
|
||||
typedef struct os_activity_scope_state_s *os_activity_scope_state_t;
|
||||
#endif
|
||||
|
||||
#pragma mark - Internal support functions
|
||||
|
||||
#if OS_ACTIVITY_OBJECT_API
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT_NEEDS_RELEASE OS_NOT_TAIL_CALLED OS_OBJECT_RETURNS_RETAINED
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT_NEEDS_RELEASE OS_NOT_TAIL_CALLED
|
||||
OS_OBJECT_RETURNS_RETAINED
|
||||
os_activity_t
|
||||
_os_activity_create(void *dso, const char *description, os_activity_t activity, os_activity_flag_t flags);
|
||||
_os_activity_create(void *dso, const char *description, os_activity_t activity,
|
||||
os_activity_flag_t flags);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function _os_activity_label_useraction
|
||||
*
|
||||
* @abstract
|
||||
* Internal function for use by os_activity_label_useraction. Do not use directly.
|
||||
* Internal function for use by os_activity_label_useraction.
|
||||
*
|
||||
* @warning
|
||||
* Do not use directly.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_label_useraction(void *dso, const char *name);
|
||||
@ -183,10 +176,11 @@ _os_activity_label_useraction(void *dso, const char *name);
|
||||
* @abstract
|
||||
* Do not use directly because your description will not be preserved.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_initiate(void *dso, const char *description, os_activity_flag_t flags, os_block_t activity_block OS_NOESCAPE);
|
||||
_os_activity_initiate(void *dso, const char *description,
|
||||
os_activity_flag_t flags, os_block_t activity_block OS_NOESCAPE);
|
||||
|
||||
/*!
|
||||
* @function _os_activity_initiate_f
|
||||
@ -194,35 +188,11 @@ _os_activity_initiate(void *dso, const char *description, os_activity_flag_t fla
|
||||
* @abstract
|
||||
* Do not use directly because your description will not be preserved.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
API_AVAILABLE(macos(10.10), ios(8.0), watchos(2.0), tvos(9.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_initiate_f(void *dso, const char *description, os_activity_flag_t flags, void *context, os_function_t function);
|
||||
|
||||
#pragma mark - Internal deprecated function support
|
||||
|
||||
/*!
|
||||
* @function _os_activity_set_breadcrumb
|
||||
*
|
||||
* @abstract
|
||||
* Internal function for setting breadcrumb. Do not use directly.
|
||||
*/
|
||||
__API_DEPRECATED_WITH_REPLACEMENT("os_activity_label_useraction", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_set_breadcrumb(void *dso, const char *name);
|
||||
|
||||
/*!
|
||||
* @function _os_activity_start
|
||||
*
|
||||
* @abstract
|
||||
* Internal function for activity start, do not use directly will not preserve
|
||||
* description.
|
||||
*/
|
||||
__API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NOT_TAIL_CALLED
|
||||
os_activity_t
|
||||
_os_activity_start(void *dso, const char *description, os_activity_flag_t flags);
|
||||
_os_activity_initiate_f(void *dso, const char *description,
|
||||
os_activity_flag_t flags, void *context, os_function_t function);
|
||||
|
||||
#pragma mark - activity related
|
||||
|
||||
@ -237,22 +207,25 @@ _os_activity_start(void *dso, const char *description, os_activity_flag_t flags)
|
||||
* a tracing buffer as appropriate. All new activities are created as a
|
||||
* subactivity of an existing activity on the current thread.
|
||||
*
|
||||
* os_activity_initiate("indexing database", OS_ACTIVITY_FLAG_DEFAULT, ^(void) {
|
||||
* // either do work directly or issue work asynchronously
|
||||
* });
|
||||
* <code>
|
||||
* os_activity_initiate("indexing database", OS_ACTIVITY_FLAG_DEFAULT, ^(void) {
|
||||
* // either do work directly or issue work asynchronously
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* @param description
|
||||
* A constant string describing the activity, e.g., "performClick" or
|
||||
* "menuSelection".
|
||||
*
|
||||
* @param flags
|
||||
* Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
|
||||
* Flags to be used when initiating the activity, typically
|
||||
* OS_ACTIVITY_FLAG_DEFAULT.
|
||||
*
|
||||
* @param activity_block
|
||||
* The block to execute a given activity
|
||||
*/
|
||||
#define os_activity_initiate(description, flags, activity_block) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
OS_LOG_STRING(ACT, __description, description); \
|
||||
_os_activity_initiate(&__dso_handle, __description, flags, activity_block); \
|
||||
})
|
||||
|
||||
@ -267,14 +240,17 @@ _os_activity_start(void *dso, const char *description, os_activity_flag_t flags)
|
||||
* a tracing buffer as appropriate. All new activities are created as a
|
||||
* subactivity of an existing activity on the current thread.
|
||||
*
|
||||
* os_activity_initiate_f("indexing database", OS_ACTIVITY_FLAG_DEFAULT, context, function);
|
||||
* <code>
|
||||
* os_activity_initiate_f("indexing database", OS_ACTIVITY_FLAG_DEFAULT, context, function);
|
||||
* </code>
|
||||
*
|
||||
* @param description
|
||||
* A constant string describing the activity, e.g., "performClick" or
|
||||
* "menuSelection".
|
||||
*
|
||||
* @param flags
|
||||
* Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
|
||||
* Flags to be used when initiating the activity, typically
|
||||
* OS_ACTIVITY_FLAG_DEFAULT.
|
||||
*
|
||||
* @param context
|
||||
* An optional context that will be supplied to the activity function.
|
||||
@ -283,7 +259,7 @@ _os_activity_start(void *dso, const char *description, os_activity_flag_t flags)
|
||||
* The function to execute for the new activity.
|
||||
*/
|
||||
#define os_activity_initiate_f(description, flags, context, function) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
OS_LOG_STRING(ACT, __description, description); \
|
||||
_os_activity_initiate_f(&__dso_handle, __description, flags, context, function); \
|
||||
})
|
||||
|
||||
@ -292,30 +268,35 @@ _os_activity_start(void *dso, const char *description, os_activity_flag_t flags)
|
||||
* @function os_activity_create
|
||||
*
|
||||
* @abstract
|
||||
* Creates an os_activity_t object which can be passed to os_activity_apply function.
|
||||
*
|
||||
* @discussion
|
||||
* Creates an os_activity_t object which can be passed to os_activity_apply function.
|
||||
* Creates an os_activity_t object which can be passed to os_activity_apply
|
||||
* function.
|
||||
*
|
||||
* @param description
|
||||
* Pass a description for the activity. The description must be a constant string
|
||||
* within the calling executable or library.
|
||||
* Pass a description for the activity. The description must be a constant
|
||||
* string within the calling executable or library.
|
||||
*
|
||||
* @param parent_activity
|
||||
* Depending on flags will link the newly created activity to the value passed or
|
||||
* note where the activity was created. Possible activities include: OS_ACTIVITY_NONE,
|
||||
* OS_ACTIVITY_CURRENT or any existing os_activity_t object created using os_activity_create.
|
||||
* Depending on flags will link the newly created activity to the value passed
|
||||
* or note where the activity was created. Possible activities include:
|
||||
* OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT or any existing os_activity_t object
|
||||
* created using os_activity_create.
|
||||
*
|
||||
* @param flags
|
||||
* A valid os_activity_flag_t which will determine behavior of the newly created activity.
|
||||
* A valid os_activity_flag_t which will determine behavior of the newly created
|
||||
* activity.
|
||||
*
|
||||
* If the OS_ACTIVITY_FLAG_DETACHED flag is passed, the value passed to the
|
||||
* parent_activity argument is ignored, and OS_ACTIVITY_NONE is used instead.
|
||||
*
|
||||
* If the OS_ACTIVITY_FLAG_IF_NONE_PRESENT flag is passed, then passing another
|
||||
* value than OS_ACTIVITY_CURRENT to the parent_activity argument is undefined.
|
||||
*
|
||||
* @result
|
||||
* Returns an os_activity_t object which can be used with os_activity_apply.
|
||||
*/
|
||||
#define os_activity_create(description, parent_activity, flags) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
os_activity_t __activity = _os_activity_create(&__dso_handle, __description, parent_activity, flags); \
|
||||
__activity; \
|
||||
OS_LOG_STRING(ACT, __description, description); \
|
||||
_os_activity_create(&__dso_handle, __description, parent_activity, flags); \
|
||||
})
|
||||
|
||||
/*!
|
||||
@ -324,17 +305,14 @@ _os_activity_start(void *dso, const char *description, os_activity_flag_t flags)
|
||||
* @abstract
|
||||
* Execute a block using a given activity object.
|
||||
*
|
||||
* @discussion
|
||||
* Execute a block using a given activity object.
|
||||
*
|
||||
* @param activity
|
||||
* There are global objects available which include: OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT
|
||||
* or an existing os_activity_t object.
|
||||
* The given activity object created with os_activity_create() or
|
||||
* OS_ACTIVITY_NONE.
|
||||
*
|
||||
* @param block
|
||||
* Pass the block to be executed within the context of the given activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_apply(os_activity_t activity, os_block_t block OS_NOESCAPE);
|
||||
@ -345,12 +323,9 @@ os_activity_apply(os_activity_t activity, os_block_t block OS_NOESCAPE);
|
||||
* @abstract
|
||||
* Execute a given function with a provided activity.
|
||||
*
|
||||
* @discussion
|
||||
* Execute a given function with a provided activity.
|
||||
*
|
||||
* @param activity
|
||||
* There are global objects available which include: OS_ACTIVITY_NONE, OS_ACTIVITY_CURRENT
|
||||
* or an existing os_activity_t object.
|
||||
* The given activity object created with os_activity_create() or
|
||||
* OS_ACTIVITY_NONE.
|
||||
*
|
||||
* @param context
|
||||
* Context to pass to the function which may be NULL.
|
||||
@ -358,10 +333,11 @@ os_activity_apply(os_activity_t activity, os_block_t block OS_NOESCAPE);
|
||||
* @param function
|
||||
* Pass the function to be executed within the context of the given activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_apply_f(os_activity_t activity, void *context, os_function_t function);
|
||||
os_activity_apply_f(os_activity_t activity, void *context,
|
||||
os_function_t function);
|
||||
|
||||
/*!
|
||||
* @function os_activity_scope_enter
|
||||
@ -370,14 +346,16 @@ os_activity_apply_f(os_activity_t activity, void *context, os_function_t functio
|
||||
* Will change the current execution context to use the provided activity.
|
||||
*
|
||||
* @discussion
|
||||
* Will change the current execution context to use the provided activity. An activity
|
||||
* can be created and then applied to the current scope by doing:
|
||||
* Will change the current execution context to use the provided activity.
|
||||
* An activity can be created and then applied to the current scope by doing:
|
||||
*
|
||||
* struct os_activity_scope_state_s state;
|
||||
* os_activity_t activity = os_activity_create("my new activity", 0);
|
||||
* os_activity_scope_enter(activity, &state);
|
||||
* ... do some work ...
|
||||
* os_activity_scope_leave(&state);
|
||||
* <code>
|
||||
* struct os_activity_scope_state_s state;
|
||||
* os_activity_t activity = os_activity_create("my new activity", 0);
|
||||
* os_activity_scope_enter(activity, &state);
|
||||
* ... do some work ...
|
||||
* os_activity_scope_leave(&state);
|
||||
* </code>
|
||||
*
|
||||
* To auto-cleanup state call:
|
||||
*
|
||||
@ -389,7 +367,7 @@ os_activity_apply_f(os_activity_t activity, void *context, os_function_t functio
|
||||
* @param state
|
||||
* A stack-based struct os_activity_scope_state_s to store the state.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_scope_enter(os_activity_t activity, os_activity_scope_state_t state);
|
||||
@ -401,13 +379,13 @@ os_activity_scope_enter(os_activity_t activity, os_activity_scope_state_t state)
|
||||
* Will pop state up to the state provided.
|
||||
*
|
||||
* @discussion
|
||||
* Will leave scope using the state provided. If state is not present an error will be
|
||||
* generated.
|
||||
* Will leave scope using the state provided. If state is not present an error
|
||||
* will be generated.
|
||||
*
|
||||
* @param state
|
||||
* Must be a valid value filled by os_activity_scope_enter call.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_scope_leave(os_activity_scope_state_t state);
|
||||
@ -421,55 +399,6 @@ os_activity_scope_leave(os_activity_scope_state_t state);
|
||||
|
||||
#endif // OS_ACTIVITY_OBJECT_API
|
||||
|
||||
/*!
|
||||
* @function os_activity_start
|
||||
*
|
||||
* @abstract
|
||||
* Starts a new activity immediately within the current context.
|
||||
*
|
||||
* @discussion
|
||||
* Starts a new activity immediately within the current context. Deprecated please use new
|
||||
* os_activity_create and os_activity_apply.
|
||||
*
|
||||
* os_activity_t activity = os_activity_start("indexing database", OS_ACTIVITY_FLAG_DEFAULT);
|
||||
* < do some work >
|
||||
* os_activity_end(activity);
|
||||
*
|
||||
* @param description
|
||||
* A constant string describing the activity, e.g., "performClick" or
|
||||
* "menuSelection".
|
||||
*
|
||||
* @param flags
|
||||
* Flags to be used when initiating the activity, typically OS_ACTIVITY_FLAG_DEFAULT.
|
||||
*
|
||||
* @result
|
||||
* Returns a valid os_activity_id_t or 0 on failure.
|
||||
*/
|
||||
#define os_activity_start(description, flags) __extension__({ \
|
||||
OS_LOG_STRING(__description, description); \
|
||||
os_activity_t _aid = _os_activity_start(&__dso_handle, __description, flags); \
|
||||
_aid; \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_activity_end
|
||||
*
|
||||
* @abstract
|
||||
* Ends the specified activity on the current thread.
|
||||
*
|
||||
* @discussion
|
||||
* Ends the specified activity on the current thread. Does not signify anything
|
||||
* other than the originator has received control back from the activity. Work
|
||||
* could still be in flight related to the activity.
|
||||
*
|
||||
* @param activity
|
||||
* An os_activity_t returned from os_activity_start.
|
||||
*/
|
||||
__API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_end(os_activity_t activity);
|
||||
|
||||
/*!
|
||||
* @function os_activity_get_active
|
||||
*
|
||||
@ -480,7 +409,7 @@ os_activity_end(os_activity_t activity);
|
||||
* Activities have a sense of nesting and therefore there could be more than
|
||||
* one activity involved on the current thread. This should be used by
|
||||
* diagnostic tools only for making additional decisions about a situation.
|
||||
*
|
||||
*
|
||||
* @param entries
|
||||
* Pass a buffer of sufficient size to hold the the number of os_activity_id_t
|
||||
* being requested.
|
||||
@ -492,7 +421,8 @@ os_activity_end(os_activity_t activity);
|
||||
* @result
|
||||
* Number of activity identifiers written to 'entries'
|
||||
*/
|
||||
__API_DEPRECATED("No longer supported", macosx(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
API_DEPRECATED("No longer supported", macos(10.10, 10.12), ios(8.0, 10.0),
|
||||
watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
unsigned int
|
||||
os_activity_get_active(os_activity_id_t *entries, unsigned int *count);
|
||||
@ -512,29 +442,33 @@ os_activity_get_active(os_activity_id_t *entries, unsigned int *count);
|
||||
* @result
|
||||
* The identifier for the provided activity.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NONNULL1 OS_WARN_RESULT
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
os_activity_id_t
|
||||
os_activity_get_identifier(os_activity_t activity, os_activity_id_t *parent_id);
|
||||
os_activity_get_identifier(os_activity_t activity,
|
||||
os_activity_id_t *_Nullable parent_id);
|
||||
|
||||
/*!
|
||||
* @function os_activity_label_useraction
|
||||
*
|
||||
* @abstract
|
||||
* Label an activity that is auto-generated by AppKit/UIKit with a name that is useful
|
||||
* for debugging macro-level user actions.
|
||||
* Label an activity that is auto-generated by AppKit/UIKit with a name that is
|
||||
* useful for debugging macro-level user actions.
|
||||
*
|
||||
* @discussion
|
||||
* Label an activity that is auto-generated by AppKit/UIKit with a name that is useful
|
||||
* for debugging macro-level user actions. The API should be called early within the scope
|
||||
* of the IBAction and before any sub-activities are created. The name provided will
|
||||
* be shown in tools in additon to the underlying AppKit/UIKit provided name. This API
|
||||
* can only be called once and only on the activity created by AppKit/UIKit. These actions
|
||||
* help determine workflow of the user in order to reproduce problems that occur.
|
||||
* For example, a control press and/or menu item selection can be labeled:
|
||||
* Label an activity that is auto-generated by AppKit/UIKit with a name that is
|
||||
* useful for debugging macro-level user actions. The API should be called
|
||||
* early within the scope of the IBAction and before any sub-activities are
|
||||
* created. The name provided will be shown in tools in additon to the
|
||||
* underlying AppKit/UIKit provided name. This API can only be called once and
|
||||
* only on the activity created by AppKit/UIKit. These actions help determine
|
||||
* workflow of the user in order to reproduce problems that occur. For example,
|
||||
* a control press and/or menu item selection can be labeled:
|
||||
*
|
||||
* os_activity_label_useraction("New mail message");
|
||||
* os_activity_label_useraction("Empty trash");
|
||||
* <code>
|
||||
* os_activity_label_useraction("New mail message");
|
||||
* os_activity_label_useraction("Empty trash");
|
||||
* </code>
|
||||
*
|
||||
* Where the underlying AppKit/UIKit name will be "gesture:" or "menuSelect:".
|
||||
*
|
||||
@ -542,31 +476,81 @@ os_activity_get_identifier(os_activity_t activity, os_activity_id_t *parent_id);
|
||||
* A constant string that describes the the action.
|
||||
*/
|
||||
#define os_activity_label_useraction(label) __extension__({ \
|
||||
OS_LOG_STRING(__label, label); \
|
||||
OS_LOG_STRING(ACT, __label, label); \
|
||||
_os_activity_label_useraction(&__dso_handle, __label); \
|
||||
})
|
||||
|
||||
#pragma mark - application breadcrumbs
|
||||
#pragma mark - deprecated function support
|
||||
|
||||
/*!
|
||||
* @function _os_activity_start
|
||||
*
|
||||
* @abstract
|
||||
* Internal function for activity start, do not use directly will not preserve
|
||||
* description.
|
||||
*/
|
||||
API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope",
|
||||
macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NOT_TAIL_CALLED
|
||||
os_activity_t
|
||||
_os_activity_start(void *dso, const char *description, os_activity_flag_t flags);
|
||||
|
||||
/*!
|
||||
* @function os_activity_start
|
||||
*
|
||||
* @warning
|
||||
* Deprecated please use new os_activity_create and os_activity_apply.
|
||||
*/
|
||||
#define os_activity_start(description, flags) __extension__({ \
|
||||
OS_LOG_STRING(ACT, __description, description); \
|
||||
_os_activity_start(&__dso_handle, __description, flags); \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_activity_end
|
||||
*
|
||||
* @warning
|
||||
* Deprecated please use new os_activity_create and os_activity_apply.
|
||||
*/
|
||||
API_DEPRECATED("use combination of os_activity_create and os_activity_apply/os_activity_scope",
|
||||
macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
os_activity_end(os_activity_t activity);
|
||||
|
||||
/*!
|
||||
* @typedef os_breadcrumb_t
|
||||
* An opaque value for the breadcrumb ID.
|
||||
*/
|
||||
API_DEPRECATED("No longer supported", macos(10.10, 10.12), ios(8.0, 10.0),
|
||||
watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
typedef uint32_t os_breadcrumb_t;
|
||||
|
||||
/*!
|
||||
* @function _os_activity_set_breadcrumb
|
||||
*
|
||||
* @warning
|
||||
* Deprecated, please use os_activity_label_useraction.
|
||||
*/
|
||||
API_DEPRECATED_WITH_REPLACEMENT("os_activity_label_useraction",
|
||||
macos(10.10, 10.12), ios(8.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_activity_set_breadcrumb(void *dso, const char *name);
|
||||
|
||||
/*!
|
||||
* @function os_activity_set_breadcrumb
|
||||
*
|
||||
* @abstract
|
||||
* This flags the current activity as a "breadcrumb", i.e., an interesting event.
|
||||
*
|
||||
* @discussion
|
||||
* Not all activities are interesting events at the macro-level. Some activities
|
||||
* can be flagged as a breadcrumb for evalutating cross activity interactions.
|
||||
* This can only be called once per activity, other requests will be ignored.
|
||||
*
|
||||
* @param name
|
||||
* A constant string that describes the breadcrumb.
|
||||
* @warning
|
||||
* Deprecated, please use os_activity_label_useraction.
|
||||
*/
|
||||
#define os_activity_set_breadcrumb(name) __extension__({ \
|
||||
OS_LOG_STRING(__name, name); \
|
||||
OS_LOG_STRING(ACT, __name, name); \
|
||||
_os_activity_set_breadcrumb(&__dso_handle, __name); \
|
||||
})
|
||||
|
||||
OS_ASSUME_NONNULL_END
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // __OS_ACTIVITY_H__
|
1
platform-include/os/alloc_once_private.h
Symbolic link
1
platform-include/os/alloc_once_private.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/libsystem/alloc_once_private.h
|
81
platform-include/os/availability.h
Normal file
81
platform-include/os/availability.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_AVAILABILITY__
|
||||
#define __OS_AVAILABILITY__
|
||||
|
||||
#include <AvailabilityInternal.h>
|
||||
|
||||
/*
|
||||
Macros for defining which versions/platform a given symbol can be used.
|
||||
|
||||
@see http://clang.llvm.org/docs/AttributeReference.html#availability
|
||||
*/
|
||||
|
||||
/*
|
||||
* API Introductions
|
||||
*
|
||||
* Use to specify the release that a particular API became available.
|
||||
*
|
||||
* Platform names:
|
||||
* macos, ios, tvos, watchos
|
||||
*
|
||||
* Examples:
|
||||
* API_AVAILABLE(macos(10.10))
|
||||
* API_AVAILABLE(macos(10.9), ios(10.0))
|
||||
* API_AVAILABLE(macos(10.4), ios(8.0), watchos(2.0), tvos(10.0))
|
||||
*/
|
||||
|
||||
#define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* API Deprecations
|
||||
*
|
||||
* Use to specify the release that a particular API became unavailable.
|
||||
*
|
||||
* Platform names:
|
||||
* macos, ios, tvos, watchos
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* API_DEPRECATED("No longer supported", macos(10.4, 10.8))
|
||||
* API_DEPRECATED("No longer supported", macos(10.4, 10.8), ios(2.0, 3.0), watchos(2.0, 3.0), tvos(9.0, 10.0))
|
||||
*
|
||||
* API_DEPRECATED_WITH_REPLACEMENT("-setName:", tvos(10.0, 10.4), ios(9.0, 10.0))
|
||||
* API_DEPRECATED_WITH_REPLACEMENT("SomeClassName", macos(10.4, 10.6), watchos(2.0, 3.0))
|
||||
*/
|
||||
|
||||
#define API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_MSG5,__API_DEPRECATED_MSG4,__API_DEPRECATED_MSG3,__API_DEPRECATED_MSG2,__API_DEPRECATED_MSG1)(__VA_ARGS__)
|
||||
#define API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__,__API_DEPRECATED_REP5,__API_DEPRECATED_REP4,__API_DEPRECATED_REP3,__API_DEPRECATED_REP2,__API_DEPRECATED_REP1)(__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* API Unavailability
|
||||
* Use to specify that an API is unavailable for a particular platform.
|
||||
*
|
||||
* Example:
|
||||
* API_UNAVAILABLE(macos)
|
||||
* API_UNAVAILABLE(watchos, tvos)
|
||||
*/
|
||||
|
||||
#define API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__,__API_UNAVAILABLE3,__API_UNAVAILABLE2,__API_UNAVAILABLE1)(__VA_ARGS__)
|
||||
|
||||
#endif /* __OS_AVAILABILITY__ */
|
@ -1,50 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016 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 __OS_LOG_H__
|
||||
#define __OS_LOG_H__
|
||||
|
||||
#ifndef __os_log_h
|
||||
#define __os_log_h
|
||||
|
||||
#include <os/object.h>
|
||||
#include <os/base.h>
|
||||
#include <os/trace.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <mach-o/loader.h>
|
||||
#include <os/availability.h>
|
||||
#include <os/base.h>
|
||||
#include <os/object.h>
|
||||
#include <os/trace.h>
|
||||
|
||||
#if !__has_builtin(__builtin_os_log_format)
|
||||
//#warning using os/log.h requires Xcode 8 or later
|
||||
#error using os/log.h requires Xcode 8 or later
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#ifdef OS_LOG_FORMAT_WARNINGS
|
||||
#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic warning \"-Wformat\"")
|
||||
#else
|
||||
#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic error \"-Wformat\"")
|
||||
#endif
|
||||
|
||||
extern void* __dso_handle;
|
||||
|
||||
#if OS_OBJECT_SWIFT3
|
||||
OS_OBJECT_DECL_SWIFT(os_log);
|
||||
#elif OS_OBJECT_USE_OBJC
|
||||
@ -59,14 +29,7 @@ typedef struct os_log_s *os_log_t;
|
||||
* @discussion
|
||||
* Use this to disable a specific log message.
|
||||
*/
|
||||
#if OS_LOG_TARGET_HAS_10_13_FEATURES
|
||||
#define OS_LOG_DISABLED OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_disabled)
|
||||
API_AVAILABLE(macosx(10.13), ios(11.0), watchos(4.0), tvos(11.0))
|
||||
OS_EXPORT
|
||||
struct os_log_s _os_log_disabled;
|
||||
#else
|
||||
#define OS_LOG_DISABLED ((os_log_t _Nonnull)NULL)
|
||||
#endif
|
||||
#define OS_LOG_DISABLED NULL
|
||||
|
||||
/*!
|
||||
* @const OS_LOG_DEFAULT
|
||||
@ -75,7 +38,7 @@ struct os_log_s _os_log_disabled;
|
||||
* Use this to log a message in accordance with current system settings.
|
||||
*/
|
||||
#define OS_LOG_DEFAULT OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_default)
|
||||
__API_AVAILABLE(macosx(10.11), ios(9.0), watchos(2.0), tvos(9.0))
|
||||
API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0))
|
||||
OS_EXPORT
|
||||
struct os_log_s _os_log_default;
|
||||
|
||||
@ -86,28 +49,32 @@ struct os_log_s _os_log_default;
|
||||
* Supported log message types.
|
||||
*
|
||||
* @constant OS_LOG_TYPE_DEFAULT
|
||||
* Equivalent type for "os_log()" messages, i.e., default messages that are always
|
||||
* captured to memory or disk.
|
||||
* Equivalent type for "os_log()" messages, i.e., default messages that are
|
||||
* always captured to memory or disk.
|
||||
*
|
||||
* @constant OS_LOG_TYPE_INFO
|
||||
* Equivalent type for "os_log_info()" messages, i.e., Additional informational messages.
|
||||
* Equivalent type for "os_log_info()" messages, i.e., Additional informational
|
||||
* messages.
|
||||
*
|
||||
* @constant OS_LOG_TYPE_DEBUG
|
||||
* Equivalent type for "os_log_debug()" messages, i.e., Debug messages.
|
||||
*
|
||||
* @constant OS_LOG_TYPE_ERROR
|
||||
* Equivalent type for "os_log_error()" messages, i.e., local process error messages.
|
||||
* Equivalent type for "os_log_error()" messages, i.e., local process error
|
||||
* messages.
|
||||
*
|
||||
* @constant OS_LOG_TYPE_FAULT
|
||||
* Equivalent type for "os_log_fault()" messages, i.e., a system error that involves
|
||||
* potentially more than one process, usually used by daemons and services.
|
||||
* Equivalent type for "os_log_fault()" messages, i.e., a system error that
|
||||
* involves potentially more than one process, usually used by daemons and
|
||||
* services.
|
||||
*/
|
||||
OS_ENUM(os_log_type, uint8_t,
|
||||
OS_LOG_TYPE_DEFAULT = 0x00,
|
||||
OS_LOG_TYPE_INFO = 0x01,
|
||||
OS_LOG_TYPE_DEBUG = 0x02,
|
||||
OS_LOG_TYPE_ERROR = 0x10,
|
||||
OS_LOG_TYPE_FAULT = 0x11);
|
||||
OS_LOG_TYPE_DEFAULT = 0x00,
|
||||
OS_LOG_TYPE_INFO = 0x01,
|
||||
OS_LOG_TYPE_DEBUG = 0x02,
|
||||
OS_LOG_TYPE_ERROR = 0x10,
|
||||
OS_LOG_TYPE_FAULT = 0x11,
|
||||
);
|
||||
|
||||
/*!
|
||||
* @function os_log_create
|
||||
@ -138,7 +105,7 @@ OS_ENUM(os_log_type, uint8_t,
|
||||
*
|
||||
* A value will always be returned to allow for dynamic enablement.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_OBJECT_RETURNS_RETAINED OS_NONNULL_ALL
|
||||
os_log_t
|
||||
os_log_create(const char *subsystem, const char *category);
|
||||
@ -197,21 +164,14 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* line is decoded. This string must be a constant string, not dynamically
|
||||
* generated. Supports all standard printf types in addition to %@ (objects).
|
||||
*/
|
||||
#if !__has_builtin(__builtin_os_log_format)
|
||||
#define os_log_with_type(log, type, format, ...)
|
||||
#else
|
||||
#define os_log_with_type(log, type, format, ...) __extension__({ \
|
||||
if (os_log_type_enabled(log, type)) { \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wvla\"") \
|
||||
OS_LOG_FORMAT_ERRORS \
|
||||
__attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) static const char __format[] __asm(OS_STRINGIFY(OS_CONCAT(LOSLOG_, __COUNTER__))) = format; \
|
||||
uint8_t _os_log_buf[__builtin_os_log_format_buffer_size(format, ##__VA_ARGS__)]; \
|
||||
_os_log_impl(&__dso_handle, log, type, __format, (uint8_t *) __builtin_os_log_format(_os_log_buf, format, ##__VA_ARGS__), (unsigned int) sizeof(_os_log_buf)); \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
os_log_t _log_tmp = (log); \
|
||||
os_log_type_t _type_tmp = (type); \
|
||||
if (os_log_type_enabled(_log_tmp, _type_tmp)) { \
|
||||
OS_LOG_CALL_WITH_FORMAT(_os_log_impl, \
|
||||
(&__dso_handle, _log_tmp, _type_tmp), format, ##__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function os_log
|
||||
@ -220,7 +180,7 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* Insert a log message into the Unified Logging and Tracing system.
|
||||
*
|
||||
* @discussion
|
||||
* Insert a log message into the Unified Logging and Tracing system in
|
||||
* Insert a log message into the Unified Logging and Tracing system in
|
||||
* accordance with the preferences specified by the provided log object.
|
||||
* These messages cannot be disabled and therefore always captured either
|
||||
* to memory or disk.
|
||||
@ -242,7 +202,8 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* line is decoded. This string must be a constant string, not dynamically
|
||||
* generated. Supports all standard printf types and %@ (objects).
|
||||
*/
|
||||
#define os_log(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_DEFAULT, format, ##__VA_ARGS__)
|
||||
#define os_log(log, format, ...) \
|
||||
os_log_with_type(log, OS_LOG_TYPE_DEFAULT, format, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
* @function os_log_info
|
||||
@ -252,7 +213,7 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* and Tracing system.
|
||||
*
|
||||
* @discussion
|
||||
* Insert a log message into the Unified Logging and Tracing system in
|
||||
* Insert a log message into the Unified Logging and Tracing system in
|
||||
* accordance with the preferences specified by the provided log object.
|
||||
*
|
||||
* When an os_activity_id_t is present, the log message will also be scoped by
|
||||
@ -272,7 +233,8 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* line is decoded. This string must be a constant string, not dynamically
|
||||
* generated. Supports all standard printf types and %@ (objects).
|
||||
*/
|
||||
#define os_log_info(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_INFO, format, ##__VA_ARGS__)
|
||||
#define os_log_info(log, format, ...) \
|
||||
os_log_with_type(log, OS_LOG_TYPE_INFO, format, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
* @function os_log_debug
|
||||
@ -301,7 +263,8 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* line is decoded. This string must be a constant string, not dynamically
|
||||
* generated. Supports all standard printf types and %@ (objects).
|
||||
*/
|
||||
#define os_log_debug(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_DEBUG, format, ##__VA_ARGS__)
|
||||
#define os_log_debug(log, format, ...) \
|
||||
os_log_with_type(log, OS_LOG_TYPE_DEBUG, format, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
* @function os_log_error
|
||||
@ -329,7 +292,8 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* line is decoded. This string must be a constant string, not dynamically
|
||||
* generated. Supports all standard printf types and %@ (objects).
|
||||
*/
|
||||
#define os_log_error(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__)
|
||||
#define os_log_error(log, format, ...) \
|
||||
os_log_with_type(log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
* @function os_log_fault
|
||||
@ -340,7 +304,7 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* @discussion
|
||||
* Log a fault message issue into the Unified Logging and Tracing system
|
||||
* signifying a multi-process (i.e., system error) related issue, either
|
||||
* due to interaction via IPC or some other. Faults will gather information
|
||||
* due to interaction via IPC or some other. Faults will gather information
|
||||
* from the entire process chain and record it for later inspection.
|
||||
*
|
||||
* When an os_activity_id_t is present, the log message will also be scoped by
|
||||
@ -360,7 +324,8 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* line is decoded. This string must be a constant string, not dynamically
|
||||
* generated. Supports all standard printf types and %@ (objects).
|
||||
*/
|
||||
#define os_log_fault(log, format, ...) os_log_with_type(log, OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__)
|
||||
#define os_log_fault(log, format, ...) \
|
||||
os_log_with_type(log, OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
* @function os_log_type_enabled
|
||||
@ -371,7 +336,7 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* @discussion
|
||||
* Evaluate if a specific log type is enabled before doing work
|
||||
*
|
||||
* @param log
|
||||
* @param oslog
|
||||
* Pass OS_LOG_DEFAULT or a log object previously created with os_log_create.
|
||||
*
|
||||
* @param type
|
||||
@ -380,7 +345,7 @@ os_log_create(const char *subsystem, const char *category);
|
||||
* @result
|
||||
* Will return a boolean.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
bool
|
||||
os_log_type_enabled(os_log_t oslog, os_log_type_t type);
|
||||
@ -391,36 +356,41 @@ os_log_type_enabled(os_log_t oslog, os_log_type_t type);
|
||||
* @abstract
|
||||
* Internal function that takes compiler generated encoding and captures the necessary content.
|
||||
*/
|
||||
__API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
API_AVAILABLE(macos(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_log_impl(void *dso, os_log_t log, os_log_type_t type, const char *format, uint8_t *buf, unsigned int size);
|
||||
_os_log_impl(void *dso, os_log_t log, os_log_type_t type,
|
||||
const char *format, uint8_t *buf, uint32_t size);
|
||||
|
||||
/*
|
||||
* Support for older iteration of API for source compatibility only...
|
||||
*/
|
||||
|
||||
__API_DEPRECATED("no longer supported, use os_log_debug(OS_LOG_DEFAULT, ...)", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
API_DEPRECATED("no longer supported, use os_log_debug(OS_LOG_DEFAULT, ...)",
|
||||
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_log_internal(void *dso, os_log_t log, os_log_type_t type, const char *message, ...);
|
||||
|
||||
__API_AVAILABLE(macosx(10.11), ios(9.0), watchos(2.0), tvos(9.0))
|
||||
API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_OBJECT_RETURNS_RETAINED OS_NOT_TAIL_CALLED OS_NONNULL_ALL
|
||||
os_log_t
|
||||
_os_log_create(void *dso, const char *subsystem, const char *category);
|
||||
|
||||
__API_DEPRECATED("no longer suppored - always returns true", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
API_DEPRECATED("no longer suppored - always returns true",
|
||||
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
bool
|
||||
os_log_is_enabled(os_log_t log);
|
||||
|
||||
__API_DEPRECATED_WITH_REPLACEMENT("os_log_debug_enabled", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
API_DEPRECATED_WITH_REPLACEMENT("os_log_debug_enabled",
|
||||
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
bool
|
||||
os_log_is_debug_enabled(os_log_t log);
|
||||
|
||||
__API_DEPRECATED("no longer supported - use os_log with per-parameter privacy options", macosx(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
API_DEPRECATED("no longer supported - use os_log with per-parameter privacy options",
|
||||
macos(10.11,10.12), ios(9.0,10.0), watchos(2.0,3.0), tvos(9.0,10.0))
|
||||
OS_NOTHROW OS_ALWAYS_INLINE
|
||||
static inline void
|
||||
_os_log_sensitive_deprecated(void) { }
|
||||
@ -436,34 +406,35 @@ _os_log_sensitive_deprecated(void) { }
|
||||
})
|
||||
|
||||
#define OS_LOG_RELEASE OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_release)
|
||||
__API_DEPRECATED("use os_log(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
API_DEPRECATED("use os_log(OS_LOG_DEFAULT, ...)",
|
||||
macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
OS_EXPORT
|
||||
struct os_log_s _os_log_release;
|
||||
|
||||
#define OS_LOG_DEBUG OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_debug)
|
||||
__API_DEPRECATED("use os_log_debug(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
API_DEPRECATED("use os_log_debug(OS_LOG_DEFAULT, ...)",
|
||||
macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
OS_EXPORT
|
||||
struct os_log_s _os_log_debug;
|
||||
|
||||
#define OS_LOG_ERROR OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_error)
|
||||
__API_DEPRECATED("use os_log_error(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
API_DEPRECATED("use os_log_error(OS_LOG_DEFAULT, ...)",
|
||||
macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
OS_EXPORT
|
||||
struct os_log_s _os_log_error;
|
||||
|
||||
#define OS_LOG_FAULT OS_OBJECT_GLOBAL_OBJECT(os_log_t, _os_log_fault)
|
||||
__API_DEPRECATED("use os_log_fault(OS_LOG_DEFAULT, ...)", macosx(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
API_DEPRECATED("use os_log_fault(OS_LOG_DEFAULT, ...)",
|
||||
macos(10.11,10.11), ios(9.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0))
|
||||
OS_EXPORT
|
||||
struct os_log_s _os_log_fault;
|
||||
|
||||
#if ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12) \
|
||||
|| (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(__TV_OS_VERSION_MIN_REQUIRED) \
|
||||
&& !defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) \
|
||||
|| (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) \
|
||||
|| (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0))
|
||||
#if !OS_LOG_TARGET_HAS_10_12_FEATURES
|
||||
#undef os_log_with_type
|
||||
#define os_log_with_type(log, type, format, ...) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic error \"-Wformat\"") \
|
||||
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
|
||||
_os_log_internal(&__dso_handle, log, type, format, ##__VA_ARGS__); \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
@ -472,9 +443,10 @@ struct os_log_s _os_log_fault;
|
||||
#define os_log_debug_enabled(...) os_log_is_debug_enabled(__VA_ARGS__)
|
||||
|
||||
#undef os_log_create
|
||||
#define os_log_create(subsystem, category) _os_log_create(&__dso_handle, subsystem, category)
|
||||
#endif
|
||||
#define os_log_create(subsystem, category) \
|
||||
_os_log_create(&__dso_handle, subsystem, category)
|
||||
#endif // !OS_LOG_TARGET_HAS_10_12_FEATURES
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __os_log_h */
|
||||
#endif // !__OS_LOG_H__
|
499
platform-include/os/trace.h
Normal file
499
platform-include/os/trace.h
Normal file
@ -0,0 +1,499 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_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. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* 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_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_TRACE_H__
|
||||
#define __OS_TRACE_H__
|
||||
|
||||
#include <os/trace_base.h>
|
||||
#if __has_include(<xpc/xpc.h>)
|
||||
#include <xpc/xpc.h>
|
||||
typedef xpc_object_t os_trace_payload_object_t;
|
||||
#else
|
||||
typedef void *os_trace_payload_object_t;
|
||||
#endif
|
||||
|
||||
#if !__GNUC__
|
||||
#error "must be GNU C compatible"
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* We need at least clang 7.3 or later due to bugs in os_log_format parsing */
|
||||
#if __has_builtin(__builtin_os_log_format) && (__clang_major__ > 7 || (__clang_major__ == 7 && __clang_minor__ >= 3))
|
||||
|
||||
OS_ALWAYS_INLINE __attribute__((format(os_trace, 1, 2)))
|
||||
static inline void
|
||||
_os_trace_verify_printf(const char *msg, ...)
|
||||
{
|
||||
#pragma unused(msg)
|
||||
}
|
||||
|
||||
/* Previous OSes must go through older style...
|
||||
*
|
||||
* Format:
|
||||
* Items: [ ]
|
||||
* Item sizes: [
|
||||
* 8 bits * count
|
||||
* ]
|
||||
* Item count: 8 bits
|
||||
*/
|
||||
|
||||
#define OS_TRACE_CALL(_t, _p, _f, ...) __extension__({ \
|
||||
if (os_trace_type_enabled(_t)) { \
|
||||
_os_trace_verify_printf(_f, ##__VA_ARGS__); \
|
||||
OS_LOG_STRING(TRACE, __f, _f); \
|
||||
uint32_t __size = (uint32_t)__builtin_os_log_format_buffer_size(_f, ##__VA_ARGS__); \
|
||||
uint8_t _buf[__size]; \
|
||||
__builtin_os_log_format(_buf, _f, ##__VA_ARGS__); \
|
||||
uint32_t tz = 0; \
|
||||
uint8_t tb[__size]; \
|
||||
uint8_t *buff = _buf; \
|
||||
uint8_t *p = ++buff; \
|
||||
uint8_t count = *p++; \
|
||||
uint8_t trailer[count + 1]; \
|
||||
trailer[count] = count; \
|
||||
for (uint8_t ii = 0; ii < count; ii++) { \
|
||||
uint8_t desc = *p++; \
|
||||
uint8_t size = *p++; \
|
||||
uint8_t *value = p; \
|
||||
p += size; \
|
||||
if ((desc >> 4) || (desc & 0x1)) { \
|
||||
size = 0;\
|
||||
}\
|
||||
if (size) {\
|
||||
memcpy(&tb[tz], value, size);\
|
||||
tz += size;\
|
||||
}\
|
||||
trailer[ii] = size;\
|
||||
}\
|
||||
memcpy(&tb[tz], trailer, sizeof(trailer));\
|
||||
tz += sizeof(trailer);\
|
||||
_os_trace_with_buffer(&__dso_handle, __f, _t, tb, tz, _p);\
|
||||
} \
|
||||
})
|
||||
#else
|
||||
#define OS_TRACE_CALL(...)
|
||||
#endif
|
||||
|
||||
// macros to re-order arguments so we can call log function
|
||||
#define _os_trace_with_payload_1(_t, _f, _p) OS_TRACE_CALL(_t, _p, _f)
|
||||
#define _os_trace_with_payload_2(_t, _f, _1, _p) OS_TRACE_CALL(_t, _p, _f, _1)
|
||||
#define _os_trace_with_payload_3(_t, _f, _1, _2, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2)
|
||||
#define _os_trace_with_payload_4(_t, _f, _1, _2, _3, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3)
|
||||
#define _os_trace_with_payload_5(_t, _f, _1, _2, _3, _4, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4)
|
||||
#define _os_trace_with_payload_6(_t, _f, _1, _2, _3, _4, _5, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5)
|
||||
#define _os_trace_with_payload_7(_t, _f, _1, _2, _3, _4, _5, _6, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5, _6)
|
||||
#define _os_trace_with_payload_8(_t, _f, _1, _2, _3, _4, _5, _6, _7, _p) OS_TRACE_CALL(_t, _p, _f, _1, _2, _3, _4, _5, _6, _7)
|
||||
|
||||
#define _os_trace_call_n(_t, _f, ...) OS_TRACE_CALL(_t, NULL, _f, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
*
|
||||
* @abstract
|
||||
* Hashtags in trace messages
|
||||
*
|
||||
* @discussion
|
||||
* Developers are encouraged to include hashtags in log messages, regardless of
|
||||
* what API you use.
|
||||
* A hashtag is composed of a hash (#) symbol, followed by at least three
|
||||
* non-whitespace characters, terminated by whitespace or the end of the
|
||||
* message. Hashtags may not begin with a number.
|
||||
*
|
||||
* Below is the list of predefined tags:
|
||||
* #System - Message in the context of a system process.
|
||||
* #User - Message in the context of a user process.
|
||||
* #Developer - Message in the context of software development. For example,
|
||||
* deprecated APIs and debugging messages.
|
||||
* #Attention - Message that should be investigated by a system
|
||||
* administrator, because it may be a sign of a larger issue.
|
||||
* For example, errors from a hard drive controller that
|
||||
* typically occur when the drive is about to fail.
|
||||
* #Critical - Message in the context of a critical event or failure.
|
||||
* #Error - Message that is a noncritical error.
|
||||
* #Comment - Message that is a comment.
|
||||
* #Marker - Message that marks a change to divide the messages around it
|
||||
* into those before and those after the change.
|
||||
* #Clue - Message containing extra key/value pairs with additional
|
||||
* information to help reconstruct the context.
|
||||
* #Security - Message related to security concerns.
|
||||
* #Filesystem - Message describing a file system related event.
|
||||
* #Network - Message describing a network-related event.
|
||||
* #Hardware - Message describing a hardware-related event.
|
||||
* #CPU - Message describing CPU related event, e.g., initiating heavy
|
||||
* work load
|
||||
* #State - Message describing state changed, e.g., global state,
|
||||
* preference, etc.
|
||||
* #Graphics - Message describing significant graphics event
|
||||
* #Disk - Message describing disk activity
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma mark - Other defines
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_RELEASE
|
||||
* Trace messages to be captured on a typical user install. These should be
|
||||
* limited to things which improve diagnosis of a failure/crash/hang. Trace
|
||||
* buffers are generally smaller on a production system.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_RELEASE (1u << 0)
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_DEBUG
|
||||
* Trace messages to be captured while debugger or other development tool is
|
||||
* attached to the originator.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_DEBUG (1u << 1)
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_INFO
|
||||
* Trace messages that are captured when a debugger is attached, system or
|
||||
* Application mode has been increased to include additional information.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_INFO (1u << 2)
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_ERROR
|
||||
* Trace the message as an error and force a collection as a failure may be
|
||||
* imminent.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_ERROR ((1u << 6) | (1u << 0))
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_FAULT
|
||||
* Trace the message as a fatal error which forces a collection and a diagnostic
|
||||
* to be initiated.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_FAULT ((1u << 7) | (1u << 6) | (1u << 0))
|
||||
|
||||
/*!
|
||||
* @typedef os_trace_payload_t
|
||||
*
|
||||
* @abstract
|
||||
* A block that populates an xpc_object_t of type XPC_TYPE_DICTIONARY to
|
||||
* represent complex data.
|
||||
*
|
||||
* @discussion
|
||||
* This block will only be invoked under conditions where tools have attached to
|
||||
* the process. The payload can be used to send arbitrary data via the trace
|
||||
* call. Tools may use the data to validate state for integration tests or
|
||||
* provide other introspection services. No assumptions are made about the
|
||||
* format or structure of the data.
|
||||
*/
|
||||
typedef void (^os_trace_payload_t)(os_trace_payload_object_t xdict);
|
||||
|
||||
#pragma mark - function declarations
|
||||
|
||||
/*!
|
||||
* @function os_trace
|
||||
*
|
||||
* @abstract
|
||||
* Always inserts a trace message into a buffer pool for later decoding.
|
||||
*
|
||||
* @discussion
|
||||
* Trace message that will be recorded on a typical user install. These should
|
||||
* be limited to things which help diagnose a failure during postmortem
|
||||
* analysis. Trace buffers are generally smaller on a production system.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* <code>
|
||||
* os_trace("network event: %ld, last seen: %ld, avg: %g",
|
||||
* event_id, last_seen, avg);
|
||||
* </code>
|
||||
*/
|
||||
#define os_trace(format, ...) OS_TRACE_CALL(OS_TRACE_TYPE_RELEASE, NULL, format, ##__VA_ARGS__)
|
||||
|
||||
#if OS_LOG_TARGET_HAS_10_12_FEATURES
|
||||
/*!
|
||||
* @function os_trace_info
|
||||
*
|
||||
* @abstract
|
||||
* Optionally inserts a trace message containing additional information into a
|
||||
* buffer pool for later decoding.
|
||||
*
|
||||
* @discussion
|
||||
* Trace messages that will be captured when additional information is needed
|
||||
* and are not captured by default. They will only be captured if the
|
||||
* system/process/activity mode has been increased or if a Development tool has
|
||||
* been attached to the process.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string that represents a human-readable message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* <code>
|
||||
* os_trace_info("network interface status %ld", status);
|
||||
* </code>
|
||||
*/
|
||||
#define os_trace_info(format, ...) \
|
||||
OS_TRACE_CALL(OS_TRACE_TYPE_INFO, NULL, format, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function os_trace_debug
|
||||
*
|
||||
* @abstract
|
||||
* Insert debug trace message into a buffer pool for later decoding.
|
||||
*
|
||||
* @discussion
|
||||
* Debug trace message to be recorded while debugger or other development tool
|
||||
* is attached to the originator. This is transported interprocess to help
|
||||
* diagnose the entire call chain including external helpers.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string that represents a human-readable message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* <code>
|
||||
* os_trace_debug("network interface status %ld", status);
|
||||
* </code>
|
||||
*/
|
||||
#define os_trace_debug(format, ...) \
|
||||
OS_TRACE_CALL(OS_TRACE_TYPE_DEBUG, NULL, format, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
* @function os_trace_info_enabled
|
||||
*
|
||||
* @abstract
|
||||
* Avoid unnecessary work for a trace point by checking if additional
|
||||
* information is enabled.
|
||||
*
|
||||
* @discussion
|
||||
* Avoid unnecessary work for a trace point by checking if additional
|
||||
* information is enabled. Generally trace points should not involve expensive
|
||||
* operations, but some circumstances warrant it. Use this function to avoid
|
||||
* doing the work unless debug level trace messages are requested.
|
||||
*
|
||||
* <code>
|
||||
* if (os_trace_info_enabled()) {
|
||||
* os_trace_info("value = %d, average = %d",
|
||||
* [[dict objectForKey: @"myKey"] intValue],
|
||||
* (int)[self getAverage:dict]);
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @result
|
||||
* Returns true if info types are enabled.
|
||||
*/
|
||||
API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
bool
|
||||
os_trace_info_enabled(void);
|
||||
|
||||
/*!
|
||||
* @function os_trace_debug_enabled
|
||||
*
|
||||
* @abstract
|
||||
* Avoid unnecessary work for a trace point by checking if debug level is
|
||||
* enabled.
|
||||
*
|
||||
* @discussion
|
||||
* Avoid unnecessary work for a trace point by checking if debug level is
|
||||
* enabled. Generally trace points should not involve expensive operations, but
|
||||
* some circumstances warrant it. Use this function to avoid doing the work
|
||||
* unless debug level trace messages are requested.
|
||||
*
|
||||
* <code>
|
||||
* if (os_trace_debug_enabled()) {
|
||||
* os_trace_debug("value = %d, average = %d",
|
||||
* [[dict objectForKey: @"myKey"] intValue],
|
||||
* (int)[self getAverage:dict]);
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @result
|
||||
* Returns true if debug mode is enabled.
|
||||
*/
|
||||
API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
bool
|
||||
os_trace_debug_enabled(void);
|
||||
|
||||
/*!
|
||||
* @function os_trace_type_enabled
|
||||
*
|
||||
* @abstract
|
||||
* Avoid unnecessary work for a trace point by checking a specific type
|
||||
*
|
||||
* @discussion
|
||||
* Avoid unnecessary work for a trace point by checking a specific type
|
||||
*
|
||||
* @result
|
||||
* Returns true if type is enabled.
|
||||
*/
|
||||
API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
|
||||
OS_NOTHROW OS_WARN_RESULT OS_ALWAYS_INLINE
|
||||
static inline bool
|
||||
os_trace_type_enabled(uint8_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case OS_TRACE_TYPE_INFO:
|
||||
return os_trace_info_enabled();
|
||||
case OS_TRACE_TYPE_DEBUG:
|
||||
return os_trace_debug_enabled();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @function os_trace_error
|
||||
*
|
||||
* @abstract
|
||||
* Trace the message as an error and force a collection of the trace buffer as
|
||||
* a failure may be imminent.
|
||||
*
|
||||
* @discussion
|
||||
* Trace the message as an error and force a collection of the trace buffer as
|
||||
* a failure may be imminent.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts to pass
|
||||
* arbitrary strings will store a pointer that is unresolvable and will generate
|
||||
* an error during decode.
|
||||
*
|
||||
* <code>
|
||||
* os_trace_error("socket %d connection timeout %ld", fd, secs);
|
||||
* </code>
|
||||
*/
|
||||
#define os_trace_error(format, ...) \
|
||||
OS_TRACE_CALL(OS_TRACE_TYPE_ERROR, NULL, format, ##__VA_ARGS__)
|
||||
|
||||
/*!
|
||||
* @function os_trace_fault
|
||||
*
|
||||
* @abstract
|
||||
* Trace the message as a fault which forces a collection of the trace buffer
|
||||
* and diagnostic of the activity.
|
||||
*
|
||||
* @discussion
|
||||
* Trace the message as a fault which forces a collection of the trace buffer
|
||||
* and diagnostic of the activity.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* <code>
|
||||
* os_trace_fault("failed to lookup uid %d - aborting", uid);
|
||||
* </code>
|
||||
*/
|
||||
#define os_trace_fault(format, ...) \
|
||||
OS_TRACE_CALL(OS_TRACE_TYPE_FAULT, NULL, format, ##__VA_ARGS__)
|
||||
|
||||
#if __has_include(<xpc/xpc.h>)
|
||||
/*!
|
||||
* @function os_trace_with_payload
|
||||
*
|
||||
* @abstract
|
||||
* Add a trace entry containing the provided values and call the block if
|
||||
* appropriate.
|
||||
*
|
||||
* @discussion
|
||||
* Will insert a trace entry into a limited ring buffer for an activity or
|
||||
* process. Trace points are for recording interesting data that would improve
|
||||
* diagnosis of unexpected crashes, failures and hangs. The block will only be
|
||||
* called under the required conditions.
|
||||
*
|
||||
* @param trace_msg
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported. Attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* The final parameter must be a block of type os_trace_payload_t.
|
||||
*
|
||||
* <code>
|
||||
* os_trace_with_payload("network event %ld", event, ^(xpc_object_t xdict) {
|
||||
*
|
||||
* // validate the network interface and address where what was expected
|
||||
* xpc_dictionary_set_string(xdict, "network", ifp->ifa_name);
|
||||
* xpc_dictionary_set_string(xdict, "ip_address", _get_address(ifp));
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
#define os_trace_with_payload(format, ...) \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
|
||||
OS_TRACE_TYPE_RELEASE, format, ##__VA_ARGS__)
|
||||
|
||||
#if OS_LOG_TARGET_HAS_10_12_FEATURES
|
||||
|
||||
#define os_trace_info_with_payload(format, ...) \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
|
||||
OS_TRACE_TYPE_INFO, format, ##__VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
os_trace_info_with_payload(const char *format, ...);
|
||||
|
||||
#endif // !OS_LOG_TARGET_HAS_10_12_FEATURES
|
||||
|
||||
#define os_trace_debug_with_payload(format, ...) \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
|
||||
OS_TRACE_TYPE_DEBUG, format, ##__VA_ARGS__)
|
||||
|
||||
#define os_trace_error_with_payload(format, ...) \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
|
||||
OS_TRACE_TYPE_ERROR, format, ##__VA_ARGS__)
|
||||
|
||||
#define os_trace_fault_with_payload(format, ...) \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(\
|
||||
OS_TRACE_TYPE_FAULT, format, ##__VA_ARGS__)
|
||||
|
||||
#endif // __has_include(<xpc/xpc.h>)
|
||||
|
||||
/*!
|
||||
* @function _os_trace_with_buffer
|
||||
*
|
||||
* @abstract
|
||||
* Internal function to support pre-encoded buffer.
|
||||
*/
|
||||
API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0))
|
||||
OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED
|
||||
void
|
||||
_os_trace_with_buffer(void *dso, const char *message, uint8_t type,
|
||||
const void *buffer, size_t buffer_size, os_trace_payload_t payload);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // !__OS_TRACE_H__
|
96
platform-include/os/trace_base.h
Normal file
96
platform-include/os/trace_base.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_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. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* 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_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#ifndef __OS_TRACE_BASE_H__
|
||||
#define __OS_TRACE_BASE_H__
|
||||
|
||||
#include <mach-o/loader.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <os/availability.h>
|
||||
#include <os/base.h>
|
||||
#include <os/object.h>
|
||||
|
||||
#define OS_LOG_FORMATLIKE(x, y) __attribute__((format(os_log, x, y)))
|
||||
|
||||
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0) \
|
||||
|| (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0) \
|
||||
|| (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0) \
|
||||
|| (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12)
|
||||
#define OS_LOG_TARGET_HAS_10_12_FEATURES 1
|
||||
#else
|
||||
#define OS_LOG_TARGET_HAS_10_12_FEATURES 0
|
||||
#endif
|
||||
|
||||
#ifndef OS_COUNT_ARGS
|
||||
#define OS_COUNT_ARGS(...) OS_COUNT_ARGS1(, ##__VA_ARGS__, _8, _7, _6, _5, _4, _3, _2, _1, _0)
|
||||
#define OS_COUNT_ARGS1(z, a, b, c, d, e, f, g, h, cnt, ...) cnt
|
||||
#endif
|
||||
|
||||
#ifdef OS_LOG_FORMAT_WARNINGS
|
||||
#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic warning \"-Wformat\"")
|
||||
#else
|
||||
#define OS_LOG_FORMAT_ERRORS _Pragma("clang diagnostic error \"-Wformat\"")
|
||||
#endif
|
||||
|
||||
#define OS_LOG_PRAGMA_PUSH \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wvla\"") \
|
||||
OS_LOG_FORMAT_ERRORS
|
||||
|
||||
#define OS_LOG_PRAGMA_POP _Pragma("clang diagnostic pop")
|
||||
|
||||
#define OS_LOG_STRING(_ns, _var, _str) \
|
||||
_Static_assert(__builtin_constant_p(_str), \
|
||||
"formatters/labels/descriptions must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__oslogstring,cstring_literals"),internal_linkage)) \
|
||||
static const char _var[] __asm(OS_STRINGIFY(OS_CONCAT(LOS_##_ns, __COUNTER__))) = _str
|
||||
|
||||
|
||||
#define OS_LOG_REMOVE_PARENS(...) __VA_ARGS__
|
||||
|
||||
#define OS_LOG_CALL_WITH_FORMAT(fun, fun_args, fmt, ...) __extension__({ \
|
||||
OS_LOG_PRAGMA_PUSH OS_LOG_STRING(LOG, _os_fmt_str, fmt); \
|
||||
uint8_t _os_fmt_buf[__builtin_os_log_format_buffer_size(fmt, ##__VA_ARGS__)]; \
|
||||
fun(OS_LOG_REMOVE_PARENS fun_args, _os_fmt_str, \
|
||||
(uint8_t *)__builtin_os_log_format(_os_fmt_buf, fmt, ##__VA_ARGS__), \
|
||||
(uint32_t)sizeof(_os_fmt_buf)) OS_LOG_PRAGMA_POP; \
|
||||
})
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern struct mach_header __dso_handle;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // !__OS_TRACE_BASE_H__
|
@ -95,6 +95,20 @@ void os_reason_free(os_reason_t cur_reason);
|
||||
#define OS_REASON_REPORTCRASH 12
|
||||
#define OS_REASON_COREANIMATION 13
|
||||
#define OS_REASON_AGGREGATED 14
|
||||
#define OS_REASON_RUNNINGBOARD 15
|
||||
#define OS_REASON_ASSERTIOND OS_REASON_RUNNINGBOARD /* old name */
|
||||
#define OS_REASON_SKYWALK 16
|
||||
#define OS_REASON_SETTINGS 17
|
||||
#define OS_REASON_LIBSYSTEM 18
|
||||
#define OS_REASON_FOUNDATION 19
|
||||
#define OS_REASON_WATCHDOG 20
|
||||
#define OS_REASON_METAL 21
|
||||
#define OS_REASON_WATCHKIT 22
|
||||
#define OS_REASON_GUARD 23
|
||||
#define OS_REASON_ANALYTICS 24
|
||||
#define OS_REASON_SANDBOX 25
|
||||
#define OS_REASON_SECURITY 26
|
||||
#define OS_REASON_ENDPOINTSECURITY 27
|
||||
|
||||
/*
|
||||
* Update whenever new OS_REASON namespaces are added.
|
||||
|
@ -200,6 +200,7 @@ add_subdirectory(external/libkqueue)
|
||||
|
||||
add_subdirectory(external/libplatform)
|
||||
add_subdirectory(external/libpthread)
|
||||
add_subdirectory(external/libtrace)
|
||||
add_subdirectory(kernel)
|
||||
add_subdirectory(libc)
|
||||
add_subdirectory(vchroot)
|
||||
@ -326,6 +327,7 @@ add_subdirectory(external/DSTools)
|
||||
add_subdirectory(external/DirectoryService)
|
||||
add_subdirectory(ImageIO)
|
||||
add_subdirectory(login)
|
||||
add_subdirectory(libaks)
|
||||
add_subdirectory(SecurityFoundation)
|
||||
add_subdirectory(libsysmon)
|
||||
add_subdirectory(libcompression)
|
||||
|
@ -31,3 +31,18 @@ CFDataRef TKTokenCopyObjectData(TKTokenRef token, CFDataRef object_id, CFErrorRe
|
||||
CFDataRef TKTokenCopyObjectCreationAccessControl(TKTokenRef token, CFTypeRef object_or_attrs, CFErrorRef *error) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFDictionaryRef TKTokenControl(TKTokenRef token, CFDictionaryRef attributes, CFErrorRef *error)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFArrayRef TKTokenCopyIdentities(TKTokenRef token, int usage, CFErrorRef *error)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFDataRef TKTokenCopyOperationResult(TKTokenRef token, CFDataRef objectID, int operation, CFArrayRef algorithms, int other, CFTypeRef in1, CFTypeRef in2, CFErrorRef *error)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,893 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015 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 __OS_TRACE_H__
|
||||
#define __OS_TRACE_H__
|
||||
|
||||
#include <Availability.h>
|
||||
#include <os/base.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#if __has_include(<xpc/xpc.h>)
|
||||
#include <xpc/xpc.h>
|
||||
#else
|
||||
typedef void *xpc_object_t;
|
||||
#endif
|
||||
|
||||
#if !__GNUC__
|
||||
#error "must be GNU C compatible"
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern void *__dso_handle;
|
||||
|
||||
OS_ALWAYS_INLINE
|
||||
static inline void
|
||||
_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))
|
||||
{
|
||||
#pragma unused(msg)
|
||||
}
|
||||
|
||||
#if !defined OS_COUNT_ARGS
|
||||
#define OS_COUNT_ARGS(...) OS_COUNT_ARGS1(, ##__VA_ARGS__, _8, _7, _6, _5, _4, _3, _2, _1, _0)
|
||||
#define OS_COUNT_ARGS1(z, a, b, c, d, e, f, g, h, cnt, ...) cnt
|
||||
#endif
|
||||
|
||||
/* use old macros for anything less than iOS 10 and MacOS 10.12 */
|
||||
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) \
|
||||
|| (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_3_0) \
|
||||
|| (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < __TVOS_10_0) \
|
||||
|| (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12)
|
||||
|
||||
#define _os_trace_0(_l, _m, _t) __extension__({ \
|
||||
_os_trace_verify_printf(_l); \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, NULL, 0, NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_1(_l, _m, _t, _1) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
_os_trace_verify_printf(_l, _c1); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
uint8_t _s[1]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._cnt = 1, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_2(_l, _m, _t, _1, _2) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
uint8_t _s[2]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._cnt = 2, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_3(_l, _m, _t, _1, _2, _3) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
uint8_t _s[3]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._cnt = 3, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_4(_l, _m, _t, _1, _2, _3, _4) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
uint8_t _s[4]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._cnt = 4, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_5(_l, _m, _t, _1, _2, _3, _4, _5) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
const __typeof__(_5) _c5 = _5; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4, _c5); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
__typeof__(_c5) _f5; \
|
||||
uint8_t _s[5]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._f5 = _c5, ._s[4] = sizeof(_c5), \
|
||||
._cnt = 5, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_6(_l, _m, _t, _1, _2, _3, _4, _5, _6) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
const __typeof__(_5) _c5 = _5; \
|
||||
const __typeof__(_6) _c6 = _6; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4, _c5, _c6); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
__typeof__(_c5) _f5; \
|
||||
__typeof__(_c6) _f6; \
|
||||
uint8_t _s[6]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._f5 = _c5, ._s[4] = sizeof(_c5), \
|
||||
._f6 = _c6, ._s[5] = sizeof(_c6), \
|
||||
._cnt = 6, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_7(_l, _m, _t, _1, _2, _3, _4, _5, _6, _7) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
const __typeof__(_5) _c5 = _5; \
|
||||
const __typeof__(_6) _c6 = _6; \
|
||||
const __typeof__(_7) _c7 = _7; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4, _c5, _c6, _c7); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
__typeof__(_c5) _f5; \
|
||||
__typeof__(_c6) _f6; \
|
||||
__typeof__(_c7) _f7; \
|
||||
uint8_t _s[7]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._f5 = _c5, ._s[4] = sizeof(_c5), \
|
||||
._f6 = _c6, ._s[5] = sizeof(_c6), \
|
||||
._f7 = _c7, ._s[6] = sizeof(_c7), \
|
||||
._cnt = 7, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_1(_l, _m, _t, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l); \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, NULL, 0, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_2(_l, _m, _t, _1, _payload) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
_os_trace_verify_printf(_l, _c1); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
uint8_t _s[1]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._cnt = 1, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_3(_l, _m, _t, _1, _2, _payload) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
uint8_t _s[2]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._cnt = 2, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_4(_l, _m, _t, _1, _2, _3, _payload) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
uint8_t _s[3]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._cnt = 3, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_5(_l, _m, _t, _1, _2, _3, _4, _payload) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
uint8_t _s[4]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._cnt = 4, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_6(_l, _m, _t, _1, _2, _3, _4, _5, _payload) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
const __typeof__(_4) _c5 = _5; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4, _c5); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
__typeof__(_c5) _f5; \
|
||||
uint8_t _s[5]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._f5 = _c5, ._s[4] = sizeof(_c5), \
|
||||
._cnt = 5, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_7(_l, _m, _t, _1, _2, _3, _4, _5, _6, _payload) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
const __typeof__(_5) _c5 = _5; \
|
||||
const __typeof__(_6) _c6 = _6; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4, _c5, _c6); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
__typeof__(_c5) _f5; \
|
||||
__typeof__(_c6) _f6; \
|
||||
uint8_t _s[6]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._f5 = _c5, ._s[4] = sizeof(_c5), \
|
||||
._f6 = _c6, ._s[5] = sizeof(_c6), \
|
||||
._cnt = 6, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_8(_l, _m, _t, _1, _2, _3, _4, _5, _6, _7, _payload) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wpacked\"") \
|
||||
const __typeof__(_1) _c1 = _1; \
|
||||
const __typeof__(_2) _c2 = _2; \
|
||||
const __typeof__(_3) _c3 = _3; \
|
||||
const __typeof__(_4) _c4 = _4; \
|
||||
const __typeof__(_5) _c5 = _5; \
|
||||
const __typeof__(_6) _c6 = _6; \
|
||||
const __typeof__(_7) _c7 = _7; \
|
||||
_os_trace_verify_printf(_l, _c1, _c2, _c3, _c4, _c5, _c6, _c7); \
|
||||
const struct __attribute__((packed)) { \
|
||||
__typeof__(_c1) _f1; \
|
||||
__typeof__(_c2) _f2; \
|
||||
__typeof__(_c3) _f3; \
|
||||
__typeof__(_c4) _f4; \
|
||||
__typeof__(_c5) _f5; \
|
||||
__typeof__(_c6) _f6; \
|
||||
__typeof__(_c7) _f7; \
|
||||
uint8_t _s[7]; \
|
||||
uint8_t _cnt; \
|
||||
} _buf = { \
|
||||
._f1 = _c1, ._s[0] = sizeof(_c1), \
|
||||
._f2 = _c2, ._s[1] = sizeof(_c2), \
|
||||
._f3 = _c3, ._s[2] = sizeof(_c3), \
|
||||
._f4 = _c4, ._s[3] = sizeof(_c4), \
|
||||
._f5 = _c5, ._s[4] = sizeof(_c5), \
|
||||
._f6 = _c6, ._s[5] = sizeof(_c6), \
|
||||
._f7 = _c7, ._s[6] = sizeof(_c7), \
|
||||
._cnt = 7, \
|
||||
}; \
|
||||
_os_trace_with_buffer(&__dso_handle, _m, _t, &_buf, sizeof(_buf), _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#define OS_TRACE_CALL(format, _m, _t, ...) __extension__({ \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"") \
|
||||
OS_CONCAT(_os_trace, OS_COUNT_ARGS(__VA_ARGS__))(format, _m, _t, ##__VA_ARGS__); \
|
||||
_Pragma("clang diagnostic pop") \
|
||||
})
|
||||
|
||||
#else
|
||||
|
||||
// Use a new layout in Mac OS 10.12+ and iOS 10.0+
|
||||
#define OS_TRACE_CALL(_l, _m, _t, ...) __extension__({ \
|
||||
uint8_t buf[1024]; \
|
||||
_os_trace_verify_printf(_l, ##__VA_ARGS__); \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, ##__VA_ARGS__); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, NULL); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_1(_l, _m, _t, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, NULL, 0, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_2(_l, _m, _t, _1, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l, _1); \
|
||||
uint8_t buf[1024]; \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, _1); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_3(_l, _m, _t, _1, _2, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l, _1, _2); \
|
||||
uint8_t buf[1024]; \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, _1, _2); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_4(_l, _m, _t, _1, _2, _3, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l, _1, _2, _3); \
|
||||
uint8_t buf[1024]; \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, _1, _2, _3); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_5(_l, _m, _t, _1, _2, _3, _4, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l, _1, _2, _3, _4); \
|
||||
uint8_t buf[1024]; \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, _1, _2, _3, _4); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_6(_l, _m, _t, _1, _2, _3, _4, _5, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l, _1, _2, _3, _4, _5); \
|
||||
uint8_t buf[1024]; \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, _1, _2, _3, _4, _5); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_7(_l, _m, _t, _1, _2, _3, _4, _5, _6, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l, _1, _2, _3, _4, _5, _6); \
|
||||
uint8_t buf[1024]; \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, _1, _2, _3, _4, _5, _6); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#define _os_trace_with_payload_8(_l, _m, _t, _1, _2, _3, _4, _5, _6, _7, _payload) __extension__({ \
|
||||
_os_trace_verify_printf(_l, _1, _2, _3, _4, _5, _6, _7); \
|
||||
uint8_t buf[1024]; \
|
||||
size_t buf_size = _os_trace_encode(buf, sizeof(buf), _m, _1, _2, _3, _4, _5, _6, _7); \
|
||||
_os_trace_internal(&__dso_handle, _t, _m, buf, buf_size, _payload); \
|
||||
__asm__(""); /* avoid tailcall */ \
|
||||
})
|
||||
|
||||
#endif /* if Mac OS >= 10.12 or iPhone OS >= 10.0 */
|
||||
|
||||
/*!
|
||||
*
|
||||
* @abstract
|
||||
* Hashtags in trace messages
|
||||
*
|
||||
* @discussion
|
||||
* Developers are encouraged to include hashtags in log messages, regardless of what API you use.
|
||||
* A hashtag is composed of a hash (#) symbol, followed by at least three non-whitespace characters,
|
||||
* terminated by whitespace or the end of the message. Hashtags may not begin with a number.
|
||||
*
|
||||
* Below is the list of predefined tags:
|
||||
* #System - Message in the context of a system process.
|
||||
* #User - Message in the context of a user process.
|
||||
* #Developer - Message in the context of software development. For example, deprecated APIs and debugging messages.
|
||||
* #Attention - Message that should be investigated by a system administrator, because it may be a sign of a larger issue.
|
||||
* For example, errors from a hard drive controller that typically occur when the drive is about to fail.
|
||||
* #Critical - Message in the context of a critical event or critical failure.
|
||||
* #Error - Message that is a noncritical error.
|
||||
* #Comment - Message that is a comment.
|
||||
* #Marker - Message that marks a change to divide the messages around it into those before and those after the change.
|
||||
* #Clue - Message containing extra key/value pairs with additional information to help reconstruct the context.
|
||||
* #Security - Message related to security concerns.
|
||||
* #Filesystem - Message describing a file system related event.
|
||||
* #Network - Message describing a network-related event.
|
||||
* #Hardware - Message describing a hardware-related event.
|
||||
* #CPU - Message describing CPU related event, e.g., initiating heavy work load
|
||||
* #State - Message describing state changed, e.g., global state, preference, etc.
|
||||
* #Graphics - Message describing significant graphics event
|
||||
* #Disk - Message describing disk activity
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma mark - Other defines
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_RELEASE
|
||||
* Trace messages to be captured on a typical user install. These should be
|
||||
* limited to things which improve diagnosis of a failure/crash/hang. Trace
|
||||
* buffers are generally smaller on a production system.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_RELEASE (1u << 0)
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_DEBUG
|
||||
* Trace messages to be captured while debugger or other development tool is
|
||||
* attached to the originator.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_DEBUG (1u << 1)
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_INFO
|
||||
* Trace messages that are captured when a debugger is attached, system or
|
||||
* Application mode has been increased to include additional information.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_INFO (1u << 2)
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_ERROR
|
||||
* Trace the message as an error and force a collection as a failure may be
|
||||
* imminent.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_ERROR ((1u << 6) | (1u << 0))
|
||||
|
||||
/*!
|
||||
* @define OS_TRACE_TYPE_FAULT
|
||||
* Trace the message as a fatal error which forces a collection and a diagnostic
|
||||
* to be initiated.
|
||||
*/
|
||||
#define OS_TRACE_TYPE_FAULT ((1u << 7) | (1u << 6) | (1u << 0))
|
||||
|
||||
/*!
|
||||
* @typedef os_trace_payload_t
|
||||
* A block that populates an xpc_object_t of type XPC_TYPE_DICTIONARY to represent
|
||||
* complex data. This block will only be invoked under conditions where tools
|
||||
* have attached to the process. The payload can be used to send arbitrary data
|
||||
* via the trace call. Tools may use the data to validate state for integration
|
||||
* tests or provide other introspection services. No assumptions are made about
|
||||
* the format or structure of the data.
|
||||
*/
|
||||
typedef void (^os_trace_payload_t)(xpc_object_t xdict);
|
||||
|
||||
#pragma mark - function declarations
|
||||
|
||||
/*!
|
||||
* @function os_trace
|
||||
*
|
||||
* @abstract
|
||||
* Always inserts a trace message into a buffer pool for later decoding.
|
||||
*
|
||||
* @discussion
|
||||
* Trace message that will be recorded on a typical user install. These should
|
||||
* be limited to things which help diagnose a failure during postmortem
|
||||
* analysis. Trace buffers are generally smaller on a production system.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* os_trace("network event: %ld, last seen: %ld, avg: %g", event_id, last_seen, avg);
|
||||
*/
|
||||
#define os_trace(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_TRACE_CALL(format, _m, OS_TRACE_TYPE_RELEASE, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
|
||||
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0) \
|
||||
|| (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0) \
|
||||
|| (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_10_0) \
|
||||
|| (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_12)
|
||||
|
||||
/*!
|
||||
* @function os_trace_info
|
||||
*
|
||||
* @abstract
|
||||
* Optionally inserts a trace message containing additional information into a
|
||||
* buffer pool for later decoding.
|
||||
*
|
||||
* @discussion
|
||||
* Trace messages that will be captured when additional information is needed
|
||||
* and are not captured by default. They will only be captured if the
|
||||
* system/process/activity mode has been increased or if a Development tool has
|
||||
* been attached to the process.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string that represents a human-readable message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* os_trace_info("network interface status %ld", status);
|
||||
*/
|
||||
#define os_trace_info(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_TRACE_CALL(format, _m, OS_TRACE_TYPE_INFO, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @function os_trace_debug
|
||||
*
|
||||
* @abstract
|
||||
* Insert debug trace message into a buffer pool for later decoding.
|
||||
*
|
||||
* @discussion
|
||||
* Debug trace message to be recorded while debugger or other development tool is
|
||||
* attached to the originator. This is transported interprocess to help
|
||||
* diagnose the entire call chain including external helpers.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string that represents a human-readable message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* os_trace_debug("network interface status %ld", status);
|
||||
*/
|
||||
#define os_trace_debug(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_TRACE_CALL(format, _m, OS_TRACE_TYPE_DEBUG, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_trace_info_enabled
|
||||
*
|
||||
* @abstract
|
||||
* Avoid unnecessary work for a trace point by checking if additional information
|
||||
* is enabled.
|
||||
*
|
||||
* @discussion
|
||||
* Avoid unnecessary work for a trace point by checking if additional information
|
||||
* is enabled. Generally trace points should not involve expensive operations, but some
|
||||
* circumstances warrant it. Use this function to avoid doing the work unless
|
||||
* debug level trace messages are requested.
|
||||
*
|
||||
* if (os_trace_info_enabled()) {
|
||||
* os_trace_info("value = %d, average = %d",
|
||||
* [[dict objectForKey: @"myKey"] intValue],
|
||||
* (int) [self getAverage: dict]);
|
||||
* }
|
||||
*
|
||||
* @result
|
||||
* Returns true if development mode is enabled.
|
||||
*/
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
bool
|
||||
os_trace_info_enabled(void);
|
||||
|
||||
/*!
|
||||
* @function os_trace_debug_enabled
|
||||
*
|
||||
* @abstract
|
||||
* Avoid unnecessary work for a trace point by checking if debug level is enabled.
|
||||
*
|
||||
* @discussion
|
||||
* Avoid unnecessary work for a trace point by checking if debug level is enabled.
|
||||
* Generally trace points should not involve expensive operations, but some
|
||||
* circumstances warrant it. Use this function to avoid doing the work unless
|
||||
* debug level trace messages are requested.
|
||||
*
|
||||
* if (os_trace_debug_enabled()) {
|
||||
* os_trace_debug("value = %d, average = %d",
|
||||
* [[dict objectForKey: @"myKey"] intValue],
|
||||
* (int) [self getAverage: dict]);
|
||||
* }
|
||||
*
|
||||
* @result
|
||||
* Returns true if debug mode is enabled.
|
||||
*/
|
||||
__OSX_AVAILABLE(10.10) __IOS_AVAILABLE(8.0) __WATCHOS_AVAILABLE(1.0) __TVOS_AVAILABLE(9.0)
|
||||
OS_EXPORT OS_NOTHROW OS_WARN_RESULT
|
||||
bool
|
||||
os_trace_debug_enabled(void);
|
||||
|
||||
/*!
|
||||
* @function os_trace_error
|
||||
*
|
||||
* @abstract
|
||||
* Trace the message as an error and force a collection of the trace buffer as a
|
||||
* failure may be imminent.
|
||||
*
|
||||
* @discussion
|
||||
* Trace the message as an error and force a collection of the trace buffer as a
|
||||
* failure may be imminent.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* os_trace_error("socket %d connection timeout %ld", fd, secs);
|
||||
*/
|
||||
#define os_trace_error(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_TRACE_CALL(format, _m, OS_TRACE_TYPE_ERROR, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
/*!
|
||||
* @function os_trace_fault
|
||||
*
|
||||
* @abstract
|
||||
* Trace the message as a fault which forces a collection of the trace buffer
|
||||
* and diagnostic of the activity.
|
||||
*
|
||||
* @discussion
|
||||
* Trace the message as a fault which forces a collection of the trace buffer
|
||||
* and diagnostic of the activity.
|
||||
*
|
||||
* @param format
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported, attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* os_trace_fault("failed to lookup uid %d - aborting", uid);
|
||||
*/
|
||||
#define os_trace_fault(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_TRACE_CALL(format, _m, OS_TRACE_TYPE_FAULT, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#if __has_include(<xpc/xpc.h>)
|
||||
/*!
|
||||
* @function os_trace_with_payload
|
||||
*
|
||||
* @abstract
|
||||
* Add a trace entry containing the provided values and call the block if
|
||||
* appropriate.
|
||||
*
|
||||
* @discussion
|
||||
* Will insert a trace entry into a limited ring buffer for an activity or
|
||||
* process. Trace points are for recording interesting data that would improve
|
||||
* diagnosis of unexpected crashes, failures and hangs. The block will only be
|
||||
* called under the required conditions.
|
||||
*
|
||||
* @param trace_msg
|
||||
* A printf-style format string to generate a human-readable log message when
|
||||
* the trace line is decoded. Only scalar types are supported. Attempts
|
||||
* to pass arbitrary strings will store a pointer that is unresolvable and
|
||||
* will generate an error during decode.
|
||||
*
|
||||
* The final parameter must be a block of type os_trace_payload_t.
|
||||
*
|
||||
* os_trace_with_payload("network event %ld", event, ^(xpc_object_t xdict) {
|
||||
*
|
||||
* // validate the network interface and address where what was expected
|
||||
* xpc_dictionary_set_string(xdict, "network", ifp->ifa_name);
|
||||
* xpc_dictionary_set_string(xdict, "ip_address", _get_address(ifp));
|
||||
* });
|
||||
*/
|
||||
#define os_trace_with_payload(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(format, _m, OS_TRACE_TYPE_RELEASE, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define os_trace_info_with_payload(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(format, _m, OS_TRACE_TYPE_INFO, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define os_trace_debug_with_payload(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(format, _m, OS_TRACE_TYPE_DEBUG, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define os_trace_error_with_payload(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(format, _m, OS_TRACE_TYPE_ERROR, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define os_trace_fault_with_payload(format, ...) __extension__({ \
|
||||
_Static_assert(__builtin_constant_p(format), "format must be a constant string"); \
|
||||
__attribute__((section("__TEXT,__os_trace"))) static const char _m[] = format; \
|
||||
OS_CONCAT(_os_trace_with_payload, OS_COUNT_ARGS(__VA_ARGS__))(format, _m, OS_TRACE_TYPE_FAULT, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#endif // __has_include(<xpc/xpc.h>)
|
||||
|
||||
// TODO: change this once we have compiler support
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
|
||||
OS_EXPORT OS_NOTHROW
|
||||
size_t
|
||||
_os_trace_encode(uint8_t *buf, size_t buf_size, const char *format, ...);
|
||||
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0)
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
_os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload);
|
||||
|
||||
/*!
|
||||
* @function _os_trace_with_buffer
|
||||
*
|
||||
* @abstract
|
||||
* Internal function to support pre-encoded buffer.
|
||||
*/
|
||||
__OSX_AVAILABLE(10.10) __IOS_AVAILABLE(8.0) __WATCHOS_AVAILABLE(1.0) __TVOS_AVAILABLE(9.0)
|
||||
OS_EXPORT OS_NOTHROW
|
||||
void
|
||||
_os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // __OS_TRACE_H__
|
2
src/external/cocotron
vendored
2
src/external/cocotron
vendored
@ -1 +1 @@
|
||||
Subproject commit f610b22d141c667f8ef9f6fe56b17ca91449c65f
|
||||
Subproject commit f325ff3c047670f31f9cdef53de0e6d959fd08bc
|
2
src/external/libdispatch
vendored
2
src/external/libdispatch
vendored
@ -1 +1 @@
|
||||
Subproject commit 0b8c59cc650f3378817dd73ad0c6a06f8d1d05ee
|
||||
Subproject commit fbc31200603db68bdc2ca3e44be99f7f2c97dc9e
|
1
src/external/libtrace
vendored
Submodule
1
src/external/libtrace
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 74f7b4babdb5759e6ee997b8d81e2da0133a5e0b
|
2
src/external/security
vendored
2
src/external/security
vendored
@ -1 +1 @@
|
||||
Subproject commit 2e611a40d521b3d6d66bfb6f792251c62e16f545
|
||||
Subproject commit 1896db842b9a3f3fbfb5c216f5e71f922a715d79
|
5
src/libaks/CMakeLists.txt
Normal file
5
src/libaks/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
project(libaks)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
add_darling_static_library(aks SOURCES libaks.c)
|
@ -2,6 +2,11 @@
|
||||
#define _LIB_AKS_H_
|
||||
|
||||
#include <IOKit/IOReturn.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// FIXME: I have no idea what these are for, so they are 0 for now
|
||||
#define session_keybag_handle 0
|
||||
@ -36,4 +41,8 @@ extern kern_return_t aks_assert_hold(keybag_handle_t keybagHandle, AKSAssertionT
|
||||
|
||||
extern kern_return_t aks_assert_drop(keybag_handle_t keybagHandle, AKSAssertionType_t lockAssertType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,10 @@ typedef int aks_smartcard_mode_t;
|
||||
#define AKS_SMARTCARD_MODE_RSA 1
|
||||
#define AKS_SMARTCARD_MODE_ECDH 2
|
||||
|
||||
CFRef<CFArrayRef> LACreateNewContextWithACMContext(int a, int b);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void aks_smartcard_unregister(int a);
|
||||
int aks_smartcard_request_unlock(int a, unsigned char *b, int c, void **d, size_t *e);
|
||||
int aks_smartcard_unlock(int a, unsigned char *b, int c, unsigned char *d, int e, void **f, size_t *g);
|
||||
@ -16,4 +19,8 @@ int aks_smartcard_register(int a, unsigned char *b, int c, int d, unsigned char
|
||||
int aks_smartcard_get_sc_usk(void *a, int b, const void **c, size_t *d);
|
||||
int aks_smartcard_get_ec_pub(void *a, int b, const void **c, size_t *d);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
42
src/libaks/libaks.c
Normal file
42
src/libaks/libaks.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include "libaks.h"
|
||||
#include "libaks_smartcard.h"
|
||||
|
||||
void aks_smartcard_unregister(int a)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int aks_smartcard_request_unlock(int a, unsigned char *b, int c, void **d, size_t *e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int aks_smartcard_unlock(int a, unsigned char *b, int c, unsigned char *d, int e, void **f, size_t *g)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int aks_smartcard_register(int a, unsigned char *b, int c, int d, unsigned char *e, int f, void **g, size_t *h)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int aks_smartcard_get_sc_usk(void *a, int b, const void **c, size_t *d)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int aks_smartcard_get_ec_pub(void *a, int b, const void **c, size_t *d)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
kern_return_t aks_assert_hold(keybag_handle_t keybagHandle, AKSAssertionType_t lockAssertType, uint64_t timeout)
|
||||
{
|
||||
return KERN_FAILURE;
|
||||
}
|
||||
|
||||
kern_return_t aks_assert_drop(keybag_handle_t keybagHandle, AKSAssertionType_t lockAssertType)
|
||||
{
|
||||
return KERN_FAILURE;
|
||||
}
|
@ -3,6 +3,6 @@ project(libc-os)
|
||||
cmake_minimum_required(VERSION 2.4.0)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
set(os_sources assumes.c debug_private.c log.c)
|
||||
set(os_sources assumes.c debug_private.c)
|
||||
|
||||
add_darling_object_library(libc-os ${os_sources})
|
||||
|
@ -1 +0,0 @@
|
||||
../../libsystem/alloc_once_private.h
|
@ -1,104 +0,0 @@
|
||||
#include <os/log.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <asl.h>
|
||||
|
||||
struct os_log_s
|
||||
{
|
||||
int stub;
|
||||
};
|
||||
|
||||
struct os_log_s _os_log_disabled;
|
||||
static asl_object_t asl_client;
|
||||
|
||||
static void deinit_asl(void)
|
||||
{
|
||||
asl_close(asl_client);
|
||||
}
|
||||
|
||||
static void init_asl(void)
|
||||
{
|
||||
if (!asl_client)
|
||||
{
|
||||
asl_client = asl_open(getprogname(), "user", 0);
|
||||
if (asl_client)
|
||||
atexit(deinit_asl);
|
||||
}
|
||||
}
|
||||
|
||||
static int log_type_os2asl(os_log_type_t t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case OS_LOG_TYPE_INFO:
|
||||
return ASL_LEVEL_INFO;
|
||||
case OS_LOG_TYPE_DEBUG:
|
||||
return ASL_LEVEL_DEBUG;
|
||||
case OS_LOG_TYPE_ERROR:
|
||||
return ASL_LEVEL_ERR;
|
||||
case OS_LOG_TYPE_FAULT:
|
||||
return ASL_LEVEL_CRIT;
|
||||
case OS_LOG_TYPE_DEFAULT:
|
||||
default:
|
||||
return ASL_LEVEL_NOTICE;
|
||||
}
|
||||
}
|
||||
|
||||
bool os_log_type_enabled(os_log_t oslog, os_log_type_t type)
|
||||
{
|
||||
printf("os_log_enabled stub called\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void _os_log_impl(void *dso,
|
||||
os_log_t log,
|
||||
os_log_type_t type,
|
||||
const char *format,
|
||||
uint8_t *buf,
|
||||
uint32_t size)
|
||||
{
|
||||
printf("_os_log_impl called: %s\n", format);
|
||||
}
|
||||
|
||||
void _os_log_error_impl(void *dso, os_log_t log, os_log_type_t type,
|
||||
const char *format, uint8_t *buf, uint32_t size)
|
||||
{
|
||||
printf("_os_log_error_impl called: %s\n", format);
|
||||
}
|
||||
|
||||
void _os_log_fault_impl(void *dso, os_log_t log, os_log_type_t type,
|
||||
const char *format, uint8_t *buf, uint32_t size)
|
||||
{
|
||||
printf("_os_log_fault_impl called: %s\n", format);
|
||||
}
|
||||
|
||||
void _os_log_internal(void *dso, os_log_t log, os_log_type_t type, const char *message, ...)
|
||||
{
|
||||
init_asl();
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, message);
|
||||
|
||||
asl_vlog(asl_client, NULL, log_type_os2asl(type), message, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
os_log_t _os_log_create(void *dso, const char *subsystem, const char *category)
|
||||
{
|
||||
printf("_os_log_create called: %s, %s\n", subsystem, category);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool os_log_is_enabled(os_log_t log)
|
||||
{
|
||||
printf("os_log_is_enabled called\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool os_log_is_debug_enabled(os_log_t log)
|
||||
{
|
||||
printf("os_log_is_debug_enabled called\n");
|
||||
return 1;
|
||||
}
|
@ -56,6 +56,7 @@ target_link_libraries(system PRIVATE
|
||||
system_malloc
|
||||
system_c
|
||||
system_kernel
|
||||
system_trace
|
||||
keymgr
|
||||
system_m
|
||||
system_info
|
||||
@ -90,6 +91,7 @@ set_property(TARGET system APPEND_STRING PROPERTY LINK_FLAGS
|
||||
-sub_library libsystem_duct \
|
||||
-sub_library libsystem_pthread \
|
||||
-sub_library libsystem_platform \
|
||||
-sub_library libsystem_trace \
|
||||
-sub_library libdispatch \
|
||||
-sub_library liblaunch \
|
||||
-sub_library libremovefile \
|
||||
|
@ -22,6 +22,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define QTN_NOT_QUARANTINED (-1)
|
||||
|
||||
#define QTN_FLAG_SANDBOX 1
|
||||
@ -90,5 +94,9 @@ extern int qtn_file_apply_to_mount_point(qtn_file_t a, const char *b);
|
||||
|
||||
#define qtn_xattr_name _qtn_xattr_name
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -143,3 +143,13 @@ void qtn_proc_free(qtn_proc_t proc)
|
||||
free(proc);
|
||||
}
|
||||
|
||||
int qtn_file_apply_to_mount_point(qtn_file_t a, const char *b)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qtn_file_init_with_mount_point(qtn_file_t a, char b[1024])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user