#include <kern/kcdata.h>

kern/kcdata.h Kernel.framework

THE KCDATA MANIFESTO Kcdata is a self-describing data serialization format. It is meant to get nested data structures out of xnu with minimum fuss, but also for that data to be easy to parse. It is also meant to allow us to add new fields and evolve the data format without breaking old parsers. Kcdata is a permanent data format suitable for long-term storage including in files. It is very important that we continue to be able to parse old versions of kcdata-based formats. To this end, there are several invariants you MUST MAINTAIN if you alter this file. * None of the magic numbers should ever be a byteswap of themselves or of any of the other magic numbers. * Never remove any type. * All kcdata structs must be packed, and must exclusively use fixed-size types. * Never change the definition of any type, except to add new fields to the end. * If you do add new fields to the end of a type, do not actually change the definition of the old structure. Instead, define a new structure with the new fields. See thread_snapshot_v3 as an example. This provides source compatibility for old readers, and also documents where the potential size cutoffs are. * If you change libkdd, or kcdata.py run the unit tests under libkdd. * If you add a type or extend an existing one, add a sample test to libkdd/tests so future changes to libkdd will always parse your struct correctly. For example to add a field to this: struct foobar { uint32_t baz; uint32_t quux; } __attribute__ ((packed)); Define an evolved structure alongside it like this: struct foobar_v2 { uint32_t baz; uint32_t quux; ///////// This is where the original structure's layout ended! sizeof(struct foobar) was 8 //////// uint32_t frozzle; } __attribute__ ((packed)); If you are parsing kcdata formats, you MUST * Check the length field of each struct, including array elements. If the struct is longer than you expect, you must ignore the extra data. * Ignore any data types you do not understand. Additionally, we want to be as forward compatible as we can. Meaning old tools should still be able to use new data whenever possible. To this end, you should: * Try not to add new versions of types that supplant old ones. Instead extend the length of existing types or add supplemental types. * Try not to remove information from existing kcdata formats, unless removal was explicitly asked for. For example it is fine to add a stackshot flag to remove unwanted information, but you should not remove it from the default stackshot if the new flag is absent. * (TBD) If you do break old readers by removing information or supplanting old structs, then increase the major version number. The following is a description of the kcdata format. The format for data is setup in a generic format as follows Layout of data structure: | 8 - bytes | | type = MAGIC | LENGTH | | 0 | | type | size | | flags | | data | |___________data____________| | type | size | | flags | |___________data____________| | type = END | size=0 | | 0 | The type field describes what kind of data is passed. For example type = TASK_CRASHINFO_UUID means the following data is a uuid. These types need to be defined in task_corpse.h for easy consumption by userspace inspection tools. Some range of types is reserved for special types like ints, longs etc. A cool new functionality made possible with this extensible data format is that kernel can decide to put more information as required without requiring user space tools to re-compile to be compatible. The case of rusage struct versions could be introduced without breaking existing tools. Feature description: Generic data with description ------------------- Further more generic data with description is very much possible now. For example - kcdata_add_uint64_with_description(cdatainfo, 0x700, "NUM MACH PORTS"); - and more functions that allow adding description. The userspace tools can then look at the description and print the data even if they are not compiled with knowledge of the field apriori. Example data: 0000 57 f1 ad de 00 00 00 00 00 00 00 00 00 00 00 00 W............... 0010 01 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 ........0....... 0020 50 49 44 00 00 00 00 00 00 00 00 00 00 00 00 00 PID............. 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0040 9c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0050 01 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 ........0....... 0060 50 41 52 45 4e 54 20 50 49 44 00 00 00 00 00 00 PARENT PID...... 0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0080 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0090 ed 58 91 f1 Feature description: Container markers for compound data ------------------ If a given kernel data type is complex and requires adding multiple optional fields inside a container object for a consumer to understand arbitrary data, we package it using container markers. For example, the stackshot code gathers information and describes the state of a given task with respect to many subsystems. It includes data such as io stats, vm counters, process names/flags and syscall counts. kcdata_add_container_marker(kcdata_p, KCDATA_TYPE_CONTAINER_BEGIN, STACKSHOT_KCCONTAINER_TASK, task_uniqueid); // add multiple data, or add_<type>_with_description()s here kcdata_add_container_marker(kcdata_p, KCDATA_TYPE_CONTAINER_END, STACKSHOT_KCCONTAINER_TASK, task_uniqueid); Feature description: Custom Data formats on demand -------------------- With the self describing nature of format, the kernel provider can describe a data type (uniquely identified by a number) and use it in the buffer for sending data. The consumer can parse the type information and have knowledge of describing incoming data. Following is an example of how we can describe a kernel specific struct sample_disk_io_stats in buffer. struct sample_disk_io_stats { uint64_t disk_reads_count; uint64_t disk_reads_size; uint64_t io_priority_count[4]; uint64_t io_priority_size; } __attribute__ ((packed)); struct kcdata_subtype_descriptor disk_io_stats_def[] = { {KCS_SUBTYPE_FLAGS_NONE, KC_ST_UINT64, 0 * sizeof(uint64_t), sizeof(uint64_t), "disk_reads_count"}, {KCS_SUBTYPE_FLAGS_NONE, KC_ST_UINT64, 1 * sizeof(uint64_t), sizeof(uint64_t), "disk_reads_size"}, {KCS_SUBTYPE_FLAGS_ARRAY, KC_ST_UINT64, 2 * sizeof(uint64_t), KCS_SUBTYPE_PACK_SIZE(4, sizeof(uint64_t)), "io_priority_count"}, {KCS_SUBTYPE_FLAGS_ARRAY, KC_ST_UINT64, (2 + 4) * sizeof(uint64_t), sizeof(uint64_t), "io_priority_size"}, }; Now you can add this custom type definition into the buffer as kcdata_add_type_definition(kcdata_p, KCTYPE_SAMPLE_DISK_IO_STATS, "sample_disk_io_stats", &disk_io_stats_def[0], sizeof(disk_io_stats_def)/sizeof(struct kcdata_subtype_descriptor)); Feature description: Compression -------------------- In order to avoid keeping large amounts of memory reserved for a panic stackshot, kcdata has support for compressing the buffer in a streaming fashion. New data pushed to the kcdata buffer will be automatically compressed using an algorithm selected by the API user (currently, we only support pass-through and zlib, in the future we plan to add WKDM support, see: 57913859). To start using compression, call: kcdata_init_compress(kcdata_p, hdr_tag, memcpy_f, comp_type); where: `kcdata_p` is the kcdata buffer that will be used `hdr_tag` is the usual header tag denoting what type of kcdata buffer this will be `memcpy_f` a memcpy(3) function to use to copy into the buffer, optional. `compy_type` is the compression type, see KCDCT_ZLIB for an example. Once compression is initialized: (1) all self-describing APIs will automatically compress (2) you can now use the following APIs to compress data into the buffer: (None of the following will compress unless kcdata_init_compress() has been called) - kcdata_push_data(kcdata_descriptor_t data, uint32_t type, uint32_t size, const void *input_data) Pushes the buffer of kctype @type at[@input_data, @input_data + @size] into the kcdata buffer @data, compressing if needed. - kcdata_push_array(kcdata_descriptor_t data, uint32_t type_of_element, uint32_t size_of_element, uint32_t count, const void *input_data) Pushes the array found at @input_data, with element type @type_of_element, where each element is of size @size_of_element and there are @count elements into the kcdata buffer at @data. - kcdata_compression_window_open/close(kcdata_descriptor_t data) In case the data you are trying to push to the kcdata buffer @data is difficult to predict, you can open a "compression window". Between an open and a close, no compression will be done. Once you close the window, the underlying compression algorithm will compress the data into the buffer and automatically rewind the current end marker of the kcdata buffer. There is an ASCII art in kern_cdata.c to aid the reader in understanding this. - kcdata_finish_compression(kcdata_descriptor_t data) Must be called at the end to flush any underlying buffers used by the compression algorithms. This function will also add some statistics about the compression to the buffer which helps with decompressing later.
includes: Kernel/stdint.h, Kernel/string.h, uuid/uuid.h
305 macros · 79 structs · 27 functions · 14 enums · 11 typedefs · 1 variable

macroKCDATA_DESC_MAXLEN

#define KCDATA_DESC_MAXLEN 32
including NULL byte at end

macroKCDATA_FLAGS_STRUCT_PADDING_MASK

#define KCDATA_FLAGS_STRUCT_PADDING_MASK 0xf

macroKCDATA_FLAGS_STRUCT_HAS_PADDING

#define KCDATA_FLAGS_STRUCT_HAS_PADDING 0x80

macroKCDATA_ALIGNMENT_SIZE

kcdata aligns elements to 16 byte boundaries.
#define KCDATA_ALIGNMENT_SIZE 0x10

structkcdata_item

size 16, align 8
uint32_ttype
uint32_tsizelen(data)
uint64_tflagsflags. For structures: padding = flags & 0xf has_padding = (flags & 0x80) >> 7 has_padding is needed to disambiguate cases such as thread_snapshot_v2 and thread_snapshot_v3. Their respective sizes are 0x68 and 0x70, and thread_snapshot_v2 was emitted by old kernels *before* we started recording padding. Since legacy thread_snapsht_v2 and modern thread_snapshot_v3 will both record 0 for the padding flags, we need some other bit which will be nonzero in the flags to disambiguate. This is why we hardcode a special case for STACKSHOT_KCTYPE_THREAD_SNAPSHOT into the iterator functions below. There is only a finite number of such hardcodings which will ever be needed. They can occur when: * We have a legacy structure that predates padding flags * which we want to extend without changing the kcdata type * by only so many bytes as would fit in the space that was previously unused padding. For containers: container_id = flags For arrays: element_count = flags & UINT32_MAX element_type = (flags >> 32) & UINT32_MAX
char[]datamust be at the end

typedefkcdata_item_t

typedef struct kcdata_item * kcdata_item_t

enumKCDATA_SUBTYPE_TYPES

underlying type unsigned int
KC_ST_CHAR1
KC_ST_INT82
KC_ST_UINT83
KC_ST_INT164
KC_ST_UINT165
KC_ST_INT326
KC_ST_UINT327
KC_ST_INT648
KC_ST_UINT649

typedefkctype_subtype_t

typedef enum KCDATA_SUBTYPE_TYPES kctype_subtype_t

structkcdata_subtype_descriptor

A subtype description structure that defines how a compound data is laid out in memory. This provides on the fly definition of types and consumption by the parser.
size 40, align 4
uint8_tkcs_flags
uint8_tkcs_elem_typerestricted to kctype_subtype_t
uint16_tkcs_elem_offsetoffset in struct where data is found
uint32_tkcs_elem_sizesize of element (or) packed state for array type
char[32]kcs_namemax 31 bytes for name of field

macroKCS_SUBTYPE_FLAGS_NONE

#define KCS_SUBTYPE_FLAGS_NONE 0x0

macroKCS_SUBTYPE_FLAGS_ARRAY

#define KCS_SUBTYPE_FLAGS_ARRAY 0x1

macroKCS_SUBTYPE_FLAGS_STRUCT

Force struct type even if only one element. Normally a kcdata_type_definition is treated as a structure if it has more than one subtype descriptor. Otherwise it is treated as a simple type. For example libkdd will represent a simple integer 42 as simply 42, but it will represent a structure containing an integer 42 as {"field_name": 42}.. If a kcdata_type_definition has only single subtype, then it will be treated as a structure iff KCS_SUBTYPE_FLAGS_STRUCT is set. If it has multiple subtypes, it will always be treated as a structure. KCS_SUBTYPE_FLAGS_MERGE has the opposite effect. If this flag is used then even if there are multiple elements, they will all be treated as individual properties of the parent dictionary.
#define KCS_SUBTYPE_FLAGS_STRUCT 0x2
force struct type even if only one element

macroKCS_SUBTYPE_FLAGS_MERGE

#define KCS_SUBTYPE_FLAGS_MERGE 0x4
treat as multiple elements of parents instead of struct

typedefkcdata_subtype_descriptor_t

typedef struct kcdata_subtype_descriptor * kcdata_subtype_descriptor_t

macroKCS_SUBTYPE_PACK_SIZE

In case of array of basic c types in kctype_subtype_t, size is packed in lower 16 bits and count is packed in upper 16 bits of kcs_elem_size field.
#define KCS_SUBTYPE_PACK_SIZE(e_count, e_size) (((e_count)&0xffffu) << 16 | ((e_size)&0xffffu))

functionkcs_get_elem_size

static inline uint32_t kcs_get_elem_size(kcdata_subtype_descriptor_t d)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the total size in bytes of the field described by kcdata subtype descriptor d. For descriptors with KCS_SUBTYPE_FLAGS_ARRAY set, the element size (low 16 bits of kcs_elem_size) is multiplied by the element count (high 16 bits); otherwise kcs_elem_size is returned unchanged.

functionkcs_get_elem_count

static inline uint32_t kcs_get_elem_count(kcdata_subtype_descriptor_t d)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the number of elements in the field described by kcdata subtype descriptor d: the count packed into the upper 16 bits of kcs_elem_size when KCS_SUBTYPE_FLAGS_ARRAY is set, 1 otherwise.

functionkcs_set_elem_size

static inline int kcs_set_elem_size(
	kcdata_subtype_descriptor_t d,
	uint32_t size,
	uint32_t count
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Sets the element size and count in kcdata subtype descriptor d. A count greater than 1 describes an array field and packs count and size into the upper and lower 16 bits of kcs_elem_size; returns -1 if either value exceeds 0xffff. Returns 0 on success.

structkcdata_type_definition

size 40, align 4
uint32_tkct_type_identifier
uint32_tkct_num_elements
char[32]kct_name
struct kcdata_subtype_descriptor[]kct_elements

macroKCDATA_TYPE_INVALID

Types with description value. these will have KCDATA_DESC_MAXLEN-1 length string description and rest of kcdata_iter_size() - KCDATA_DESC_MAXLEN bytes as data
#define KCDATA_TYPE_INVALID 0x0u

macroKCDATA_TYPE_STRING_DESC

#define KCDATA_TYPE_STRING_DESC 0x1u

macroKCDATA_TYPE_UINT32_DESC

#define KCDATA_TYPE_UINT32_DESC 0x2u

macroKCDATA_TYPE_UINT64_DESC

#define KCDATA_TYPE_UINT64_DESC 0x3u

macroKCDATA_TYPE_INT32_DESC

#define KCDATA_TYPE_INT32_DESC 0x4u

macroKCDATA_TYPE_INT64_DESC

#define KCDATA_TYPE_INT64_DESC 0x5u

macroKCDATA_TYPE_BINDATA_DESC

#define KCDATA_TYPE_BINDATA_DESC 0x6u

macroKCDATA_TYPE_ARRAY

Compound type definitions
#define KCDATA_TYPE_ARRAY 0x11u
Array of data OBSOLETE DONT USE THIS

macroKCDATA_TYPE_TYPEDEFINTION

#define KCDATA_TYPE_TYPEDEFINTION 0x12u
Meta type that describes a type on the fly.

macroKCDATA_TYPE_CONTAINER_BEGIN

#define KCDATA_TYPE_CONTAINER_BEGIN 0x13u
Container type which has corresponding CONTAINER_END header. \ KCDATA_TYPE_CONTAINER_BEGIN has type in the data segment. \ Both headers have (uint64_t) ID for matching up nested data. \

macroKCDATA_TYPE_CONTAINER_END

#define KCDATA_TYPE_CONTAINER_END 0x14u

macroKCDATA_TYPE_ARRAY_PAD0

#define KCDATA_TYPE_ARRAY_PAD0 0x20u
Array of data with 0 byte of padding

macroKCDATA_TYPE_ARRAY_PAD1

#define KCDATA_TYPE_ARRAY_PAD1 0x21u
Array of data with 1 byte of padding

macroKCDATA_TYPE_ARRAY_PAD2

#define KCDATA_TYPE_ARRAY_PAD2 0x22u
Array of data with 2 byte of padding

macroKCDATA_TYPE_ARRAY_PAD3

#define KCDATA_TYPE_ARRAY_PAD3 0x23u
Array of data with 3 byte of padding

macroKCDATA_TYPE_ARRAY_PAD4

#define KCDATA_TYPE_ARRAY_PAD4 0x24u
Array of data with 4 byte of padding

macroKCDATA_TYPE_ARRAY_PAD5

#define KCDATA_TYPE_ARRAY_PAD5 0x25u
Array of data with 5 byte of padding

macroKCDATA_TYPE_ARRAY_PAD6

#define KCDATA_TYPE_ARRAY_PAD6 0x26u
Array of data with 6 byte of padding

macroKCDATA_TYPE_ARRAY_PAD7

#define KCDATA_TYPE_ARRAY_PAD7 0x27u
Array of data with 7 byte of padding

macroKCDATA_TYPE_ARRAY_PAD8

#define KCDATA_TYPE_ARRAY_PAD8 0x28u
Array of data with 8 byte of padding

macroKCDATA_TYPE_ARRAY_PAD9

#define KCDATA_TYPE_ARRAY_PAD9 0x29u
Array of data with 9 byte of padding

macroKCDATA_TYPE_ARRAY_PADa

#define KCDATA_TYPE_ARRAY_PADa 0x2au
Array of data with a byte of padding

macroKCDATA_TYPE_ARRAY_PADb

#define KCDATA_TYPE_ARRAY_PADb 0x2bu
Array of data with b byte of padding

macroKCDATA_TYPE_ARRAY_PADc

#define KCDATA_TYPE_ARRAY_PADc 0x2cu
Array of data with c byte of padding

macroKCDATA_TYPE_ARRAY_PADd

#define KCDATA_TYPE_ARRAY_PADd 0x2du
Array of data with d byte of padding

macroKCDATA_TYPE_ARRAY_PADe

#define KCDATA_TYPE_ARRAY_PADe 0x2eu
Array of data with e byte of padding

macroKCDATA_TYPE_ARRAY_PADf

#define KCDATA_TYPE_ARRAY_PADf 0x2fu
Array of data with f byte of padding

macroKCDATA_TYPE_LIBRARY_LOADINFO

Generic data types that are most commonly used
#define KCDATA_TYPE_LIBRARY_LOADINFO 0x30u

macroKCDATA_TYPE_LIBRARY_LOADINFO64

#define KCDATA_TYPE_LIBRARY_LOADINFO64 0x31u

macroKCDATA_TYPE_TIMEBASE

#define KCDATA_TYPE_TIMEBASE 0x32u

macroKCDATA_TYPE_MACH_ABSOLUTE_TIME

#define KCDATA_TYPE_MACH_ABSOLUTE_TIME 0x33u
uint64_t

macroKCDATA_TYPE_TIMEVAL

#define KCDATA_TYPE_TIMEVAL 0x34u
struct timeval64

macroKCDATA_TYPE_USECS_SINCE_EPOCH

#define KCDATA_TYPE_USECS_SINCE_EPOCH 0x35u
time in usecs uint64_t

macroKCDATA_TYPE_PID

#define KCDATA_TYPE_PID 0x36u

macroKCDATA_TYPE_PROCNAME

#define KCDATA_TYPE_PROCNAME 0x37u
char *

macroKCDATA_TYPE_NESTED_KCDATA

#define KCDATA_TYPE_NESTED_KCDATA 0x38u
nested kcdata buffer

macroKCDATA_TYPE_LIBRARY_AOTINFO

#define KCDATA_TYPE_LIBRARY_AOTINFO 0x39u

macroKCDATA_TYPE_BUFFER_END

#define KCDATA_TYPE_BUFFER_END 0xF19158EDu

macroKCDATA_BUFFER_BEGIN_CRASHINFO

#define KCDATA_BUFFER_BEGIN_CRASHINFO 0xDEADF157u
owner: corpses/task_corpse.h

macroKCDATA_BUFFER_BEGIN_STACKSHOT

type-range: 0x800 - 0x8ff
#define KCDATA_BUFFER_BEGIN_STACKSHOT 0x59a25807u
owner: sys/stackshot.h

macroKCDATA_BUFFER_BEGIN_COMPRESSED

type-range: 0x900 - 0x93f
#define KCDATA_BUFFER_BEGIN_COMPRESSED 0x434f4d50u
owner: sys/stackshot.h

macroKCDATA_BUFFER_BEGIN_DELTA_STACKSHOT

type-range: 0x900 - 0x93f
#define KCDATA_BUFFER_BEGIN_DELTA_STACKSHOT 0xDE17A59Au
owner: sys/stackshot.h

macroKCDATA_BUFFER_BEGIN_BTINFO

type-range: 0x940 - 0x9ff
#define KCDATA_BUFFER_BEGIN_BTINFO 0x46414E47u
owner: kern/kern_exit.c

macroKCDATA_BUFFER_BEGIN_OS_REASON

type-range: 0xa01 - 0xaff
#define KCDATA_BUFFER_BEGIN_OS_REASON 0x53A20900u
owner: sys/reason.h

macroKCDATA_BUFFER_BEGIN_XNUPOST_CONFIG

type-range: 0x1000-0x103f
#define KCDATA_BUFFER_BEGIN_XNUPOST_CONFIG 0x1e21c09fu
owner: osfmk/tests/kernel_tests.c

macroXNUPOST_KCTYPE_TESTCONFIG

next type range number available 0x1060 ************** definitions for XNUPOST ********************
#define XNUPOST_KCTYPE_TESTCONFIG 0x1040

macroSTACKSHOT_IO_NUM_PRIORITIES

This value must always match IO_NUM_PRIORITIES defined in thread_info.h
#define STACKSHOT_IO_NUM_PRIORITIES 4

macroSTACKSHOT_MAX_THREAD_NAME_SIZE

This value must always match MAXTHREADNAMESIZE used in bsd
#define STACKSHOT_MAX_THREAD_NAME_SIZE 64

macroSTACKSHOT_KCTYPE_IOSTATS

NOTE: Please update kcdata/libkdd/kcdtypes.c if you make any changes in STACKSHOT_KCTYPE_* types.
#define STACKSHOT_KCTYPE_IOSTATS 0x901u

macroSTACKSHOT_KCTYPE_GLOBAL_MEM_STATS

#define STACKSHOT_KCTYPE_GLOBAL_MEM_STATS 0x902u

macroSTACKSHOT_KCCONTAINER_TASK

#define STACKSHOT_KCCONTAINER_TASK 0x903u

macroSTACKSHOT_KCCONTAINER_THREAD

#define STACKSHOT_KCCONTAINER_THREAD 0x904u

macroSTACKSHOT_KCTYPE_TASK_SNAPSHOT

#define STACKSHOT_KCTYPE_TASK_SNAPSHOT 0x905u

macroSTACKSHOT_KCTYPE_THREAD_SNAPSHOT

#define STACKSHOT_KCTYPE_THREAD_SNAPSHOT 0x906u

macroSTACKSHOT_KCTYPE_DONATING_PIDS

#define STACKSHOT_KCTYPE_DONATING_PIDS 0x907u
int[]

macroSTACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO

#define STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO 0x908u

macroSTACKSHOT_KCTYPE_THREAD_NAME

#define STACKSHOT_KCTYPE_THREAD_NAME 0x909u
char[]

macroSTACKSHOT_KCTYPE_KERN_STACKFRAME

#define STACKSHOT_KCTYPE_KERN_STACKFRAME 0x90Au

macroSTACKSHOT_KCTYPE_KERN_STACKFRAME64

#define STACKSHOT_KCTYPE_KERN_STACKFRAME64 0x90Bu

macroSTACKSHOT_KCTYPE_USER_STACKFRAME

#define STACKSHOT_KCTYPE_USER_STACKFRAME 0x90Cu

macroSTACKSHOT_KCTYPE_USER_STACKFRAME64

#define STACKSHOT_KCTYPE_USER_STACKFRAME64 0x90Du

macroSTACKSHOT_KCTYPE_BOOTARGS

#define STACKSHOT_KCTYPE_BOOTARGS 0x90Eu
boot args string

macroSTACKSHOT_KCTYPE_OSVERSION

#define STACKSHOT_KCTYPE_OSVERSION 0x90Fu
os version string, same as running uname -a

macroSTACKSHOT_KCTYPE_KERN_PAGE_SIZE

#define STACKSHOT_KCTYPE_KERN_PAGE_SIZE 0x910u
kernel page size in uint32_t

macroSTACKSHOT_KCTYPE_JETSAM_LEVEL

#define STACKSHOT_KCTYPE_JETSAM_LEVEL 0x911u
jetsam level in uint32_t

macroSTACKSHOT_KCTYPE_DELTA_SINCE_TIMESTAMP

#define STACKSHOT_KCTYPE_DELTA_SINCE_TIMESTAMP 0x912u
timestamp used for the delta stackshot

macroSTACKSHOT_KCTYPE_KERN_STACKLR

#define STACKSHOT_KCTYPE_KERN_STACKLR 0x913u
uint32_t

macroSTACKSHOT_KCTYPE_KERN_STACKLR64

#define STACKSHOT_KCTYPE_KERN_STACKLR64 0x914u
uint64_t

macroSTACKSHOT_KCTYPE_USER_STACKLR

#define STACKSHOT_KCTYPE_USER_STACKLR 0x915u
uint32_t

macroSTACKSHOT_KCTYPE_USER_STACKLR64

#define STACKSHOT_KCTYPE_USER_STACKLR64 0x916u
uint64_t

macroSTACKSHOT_KCTYPE_NONRUNNABLE_TIDS

#define STACKSHOT_KCTYPE_NONRUNNABLE_TIDS 0x917u
uint64_t

macroSTACKSHOT_KCTYPE_NONRUNNABLE_TASKS

#define STACKSHOT_KCTYPE_NONRUNNABLE_TASKS 0x918u
uint64_t

macroSTACKSHOT_KCTYPE_CPU_TIMES

#define STACKSHOT_KCTYPE_CPU_TIMES 0x919u

macroSTACKSHOT_KCTYPE_STACKSHOT_DURATION

#define STACKSHOT_KCTYPE_STACKSHOT_DURATION 0x91au

macroSTACKSHOT_KCTYPE_STACKSHOT_FAULT_STATS

#define STACKSHOT_KCTYPE_STACKSHOT_FAULT_STATS 0x91bu

macroSTACKSHOT_KCTYPE_KERNELCACHE_LOADINFO

#define STACKSHOT_KCTYPE_KERNELCACHE_LOADINFO 0x91cu
kernelcache UUID -- same as KCDATA_TYPE_LIBRARY_LOADINFO64

macroSTACKSHOT_KCTYPE_THREAD_WAITINFO

#define STACKSHOT_KCTYPE_THREAD_WAITINFO 0x91du

macroSTACKSHOT_KCTYPE_THREAD_GROUP_SNAPSHOT

#define STACKSHOT_KCTYPE_THREAD_GROUP_SNAPSHOT 0x91eu
struct thread_group_snapshot{,_v2,_v3}

macroSTACKSHOT_KCTYPE_THREAD_GROUP

#define STACKSHOT_KCTYPE_THREAD_GROUP 0x91fu
uint64_t

macroSTACKSHOT_KCTYPE_JETSAM_COALITION_SNAPSHOT

#define STACKSHOT_KCTYPE_JETSAM_COALITION_SNAPSHOT 0x920u

macroSTACKSHOT_KCTYPE_JETSAM_COALITION

#define STACKSHOT_KCTYPE_JETSAM_COALITION 0x921u
uint64_t

macroSTACKSHOT_KCTYPE_THREAD_POLICY_VERSION

#define STACKSHOT_KCTYPE_THREAD_POLICY_VERSION 0x922u
THREAD_POLICY_INTERNAL_STRUCT_VERSION in uint32

macroSTACKSHOT_KCTYPE_INSTRS_CYCLES

#define STACKSHOT_KCTYPE_INSTRS_CYCLES 0x923u

macroSTACKSHOT_KCTYPE_USER_STACKTOP

#define STACKSHOT_KCTYPE_USER_STACKTOP 0x924u

macroSTACKSHOT_KCTYPE_ASID

#define STACKSHOT_KCTYPE_ASID 0x925u
uint32_t

macroSTACKSHOT_KCTYPE_PAGE_TABLES

#define STACKSHOT_KCTYPE_PAGE_TABLES 0x926u
uint64_t

macroSTACKSHOT_KCTYPE_SYS_SHAREDCACHE_LAYOUT

#define STACKSHOT_KCTYPE_SYS_SHAREDCACHE_LAYOUT 0x927u

macroSTACKSHOT_KCTYPE_THREAD_DISPATCH_QUEUE_LABEL

#define STACKSHOT_KCTYPE_THREAD_DISPATCH_QUEUE_LABEL 0x928u
dispatch queue label

macroSTACKSHOT_KCTYPE_THREAD_TURNSTILEINFO

#define STACKSHOT_KCTYPE_THREAD_TURNSTILEINFO 0x929u

macroSTACKSHOT_KCTYPE_TASK_CPU_ARCHITECTURE

#define STACKSHOT_KCTYPE_TASK_CPU_ARCHITECTURE 0x92au

macroSTACKSHOT_KCTYPE_LATENCY_INFO

#define STACKSHOT_KCTYPE_LATENCY_INFO 0x92bu

macroSTACKSHOT_KCTYPE_LATENCY_INFO_TASK

#define STACKSHOT_KCTYPE_LATENCY_INFO_TASK 0x92cu

macroSTACKSHOT_KCTYPE_LATENCY_INFO_THREAD

#define STACKSHOT_KCTYPE_LATENCY_INFO_THREAD 0x92du

macroSTACKSHOT_KCTYPE_LOADINFO64_TEXT_EXEC

#define STACKSHOT_KCTYPE_LOADINFO64_TEXT_EXEC 0x92eu
TEXT_EXEC load info -- same as KCDATA_TYPE_LIBRARY_LOADINFO64

macroSTACKSHOT_KCTYPE_AOTCACHE_LOADINFO

#define STACKSHOT_KCTYPE_AOTCACHE_LOADINFO 0x92fu

macroSTACKSHOT_KCTYPE_TRANSITIONING_TASK_SNAPSHOT

#define STACKSHOT_KCTYPE_TRANSITIONING_TASK_SNAPSHOT 0x930u

macroSTACKSHOT_KCCONTAINER_TRANSITIONING_TASK

#define STACKSHOT_KCCONTAINER_TRANSITIONING_TASK 0x931u

macroSTACKSHOT_KCTYPE_USER_ASYNC_START_INDEX

#define STACKSHOT_KCTYPE_USER_ASYNC_START_INDEX 0x932u
uint32_t index in user_stack of beginning of async stack

macroSTACKSHOT_KCTYPE_USER_ASYNC_STACKLR64

#define STACKSHOT_KCTYPE_USER_ASYNC_STACKLR64 0x933u
uint64_t async stack pointers

macroSTACKSHOT_KCCONTAINER_PORTLABEL

#define STACKSHOT_KCCONTAINER_PORTLABEL 0x934u
container for port label info

macroSTACKSHOT_KCTYPE_PORTLABEL

#define STACKSHOT_KCTYPE_PORTLABEL 0x935u
struct stackshot_portlabel

macroSTACKSHOT_KCTYPE_PORTLABEL_NAME

#define STACKSHOT_KCTYPE_PORTLABEL_NAME 0x936u
string port name

macroSTACKSHOT_KCTYPE_DYLD_COMPACTINFO

#define STACKSHOT_KCTYPE_DYLD_COMPACTINFO 0x937u
binary blob of dyld info (variable size)

macroSTACKSHOT_KCTYPE_SUSPENSION_INFO

#define STACKSHOT_KCTYPE_SUSPENSION_INFO 0x938u

macroSTACKSHOT_KCTYPE_SUSPENSION_SOURCE

#define STACKSHOT_KCTYPE_SUSPENSION_SOURCE 0x939u

macroSTACKSHOT_KCTYPE_TASK_DELTA_SNAPSHOT

#define STACKSHOT_KCTYPE_TASK_DELTA_SNAPSHOT 0x940u

macroSTACKSHOT_KCTYPE_THREAD_DELTA_SNAPSHOT

#define STACKSHOT_KCTYPE_THREAD_DELTA_SNAPSHOT 0x941u
thread_delta_snapshot_v*

macroSTACKSHOT_KCCONTAINER_SHAREDCACHE

#define STACKSHOT_KCCONTAINER_SHAREDCACHE 0x942u
container for shared cache info

macroSTACKSHOT_KCTYPE_SHAREDCACHE_INFO

#define STACKSHOT_KCTYPE_SHAREDCACHE_INFO 0x943u

macroSTACKSHOT_KCTYPE_SHAREDCACHE_AOTINFO

#define STACKSHOT_KCTYPE_SHAREDCACHE_AOTINFO 0x944u

macroSTACKSHOT_KCTYPE_SHAREDCACHE_ID

#define STACKSHOT_KCTYPE_SHAREDCACHE_ID 0x945u
uint32_t in task: if we aren't attached to Primary, which one

macroSTACKSHOT_KCTYPE_CODESIGNING_INFO

#define STACKSHOT_KCTYPE_CODESIGNING_INFO 0x946u

macroSTACKSHOT_KCTYPE_OS_BUILD_VERSION

#define STACKSHOT_KCTYPE_OS_BUILD_VERSION 0x947u
os build version string (ex: 20A123)

macroSTACKSHOT_KCTYPE_KERN_EXCLAVES_THREADINFO

#define STACKSHOT_KCTYPE_KERN_EXCLAVES_THREADINFO 0x948u

macroSTACKSHOT_KCCONTAINER_EXCLAVES

#define STACKSHOT_KCCONTAINER_EXCLAVES 0x949u

macroSTACKSHOT_KCCONTAINER_EXCLAVE_SCRESULT

#define STACKSHOT_KCCONTAINER_EXCLAVE_SCRESULT 0x94au

macroSTACKSHOT_KCTYPE_EXCLAVE_SCRESULT_INFO

#define STACKSHOT_KCTYPE_EXCLAVE_SCRESULT_INFO 0x94bu

macroSTACKSHOT_KCCONTAINER_EXCLAVE_IPCSTACKENTRY

#define STACKSHOT_KCCONTAINER_EXCLAVE_IPCSTACKENTRY 0x94cu

macroSTACKSHOT_KCTYPE_EXCLAVE_IPCSTACKENTRY_INFO

#define STACKSHOT_KCTYPE_EXCLAVE_IPCSTACKENTRY_INFO 0x94du

macroSTACKSHOT_KCTYPE_EXCLAVE_IPCSTACKENTRY_ECSTACK

#define STACKSHOT_KCTYPE_EXCLAVE_IPCSTACKENTRY_ECSTACK 0x94eu

macroSTACKSHOT_KCCONTAINER_EXCLAVE_ADDRESSSPACE

#define STACKSHOT_KCCONTAINER_EXCLAVE_ADDRESSSPACE 0x94fu

macroSTACKSHOT_KCTYPE_EXCLAVE_ADDRESSSPACE_INFO

#define STACKSHOT_KCTYPE_EXCLAVE_ADDRESSSPACE_INFO 0x950u

macroSTACKSHOT_KCTYPE_EXCLAVE_ADDRESSSPACE_NAME

#define STACKSHOT_KCTYPE_EXCLAVE_ADDRESSSPACE_NAME 0x951u

macroSTACKSHOT_KCCONTAINER_EXCLAVE_TEXTLAYOUT

#define STACKSHOT_KCCONTAINER_EXCLAVE_TEXTLAYOUT 0x952u

macroSTACKSHOT_KCTYPE_EXCLAVE_TEXTLAYOUT_INFO

#define STACKSHOT_KCTYPE_EXCLAVE_TEXTLAYOUT_INFO 0x953u

macroSTACKSHOT_KCTYPE_EXCLAVE_TEXTLAYOUT_SEGMENTS

#define STACKSHOT_KCTYPE_EXCLAVE_TEXTLAYOUT_SEGMENTS 0x954u

macroSTACKSHOT_KCTYPE_KERN_EXCLAVES_CRASH_THREADINFO

#define STACKSHOT_KCTYPE_KERN_EXCLAVES_CRASH_THREADINFO 0x955u

macroSTACKSHOT_KCTYPE_LATENCY_INFO_CPU

#define STACKSHOT_KCTYPE_LATENCY_INFO_CPU 0x956u

macroSTACKSHOT_KCTYPE_TASK_EXEC_META

#define STACKSHOT_KCTYPE_TASK_EXEC_META 0x957u

macroSTACKSHOT_KCTYPE_TASK_MEMORYSTATUS

#define STACKSHOT_KCTYPE_TASK_MEMORYSTATUS 0x958u

macroSTACKSHOT_KCTYPE_MTEINFO_CELL

#define STACKSHOT_KCTYPE_MTEINFO_CELL 0x959u
struct mteinfo_cell

macroSTACKSHOT_KCTYPE_LATENCY_INFO_BUFFER

#define STACKSHOT_KCTYPE_LATENCY_INFO_BUFFER 0x95au

macroSTACKSHOT_KCTYPE_VMRL_BLOCKING_RELS

#define STACKSHOT_KCTYPE_VMRL_BLOCKING_RELS 0x95bu

macroSTACKSHOT_KCTYPE_LOCK_STATE

#define STACKSHOT_KCTYPE_LOCK_STATE 0x95cu

structstack_snapshot_frame32

size 8, align 4
uint32_tlr
uint32_tsp

structstack_snapshot_frame64

size 16, align 8
uint64_tlr
uint64_tsp

structdyld_uuid_info_32

size 20, align 4
uint32_timageLoadAddressbase address image is mapped at
uuid_timageUUID

structdyld_uuid_info_64

size 24, align 8
uint64_timageLoadAddressXXX image slide
uuid_timageUUID

structdyld_uuid_info_64_v2

N.B.: Newer kernels output dyld_shared_cache_loadinfo structures instead of this, since the field names match their contents better.
size 32, align 8
uint64_timageLoadAddressXXX image slide
uuid_timageUUID
uint64_timageSlidBaseAddressend of version 1 of dyld_uuid_info_64. sizeof v1 was 24 slid base address or slid first mapping of image

enumdyld_shared_cache_flags

underlying type unsigned int
kSharedCacheSystemPrimary1primary shared cache on the system; attached tasks will have kTaskSharedRegionSystem set
kSharedCacheDriverkit2driverkit shared cache
kSharedCacheAOT4Rosetta shared cache

structdyld_shared_cache_loadinfo_v2

This is the renamed version of dyld_uuid_info_64 with more accurate field names, for STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO. Any users must be aware of the dyld_uuid_info_64* version history and ensure the fields they are accessing are within the actual bounds. OLD_FIELD NEW_FIELD imageLoadAddress sharedCacheSlide imageUUID sharedCacheUUID imageSlidBaseAddress sharedCacheUnreliableSlidBaseAddress - sharedCacheSlidFirstMapping - sharedCacheID - sharedCacheFlags
size 48, align 8
uint64_tsharedCacheSlideimage slide value
uuid_tsharedCacheUUID
uint64_tsharedCacheUnreliableSlidBaseAddressend of version 1 of dyld_uuid_info_64. sizeof v1 was 24 for backwards-compatibility; use sharedCacheSlidFirstMapping if available
uint64_tsharedCacheSlidFirstMappingend of version 2 of dyld_uuid_info_64. sizeof v2 was 32 slid base address of first mapping
uint32_tsharedCacheIDend of version 1 of dyld_shared_cache_loadinfo. sizeof was 40 ID of shared cache
uint32_tsharedCacheFlags

structdyld_shared_cache_loadinfo

size 40, align 8
uint64_tsharedCacheSlideimage slide value
uuid_tsharedCacheUUID
uint64_tsharedCacheUnreliableSlidBaseAddressend of version 1 of dyld_uuid_info_64. sizeof v1 was 24 for backwards-compatibility; use sharedCacheSlidFirstMapping if available
uint64_tsharedCacheSlidFirstMappingend of version 2 of dyld_uuid_info_64. sizeof v2 was 32 slid base address of first mapping

structdyld_aot_cache_uuid_info

size 48, align 8
uint64_tx86SlidBaseAddressslid first mapping address of x86 shared cache
uuid_tx86UUIDUUID of x86 shared cache
uint64_taotSlidBaseAddressslide first mapping address of aot cache
uuid_taotUUIDUUID of aot shared cache

structuser32_dyld_uuid_info

size 20, align 4
uint32_timageLoadAddressbase address image is mapped into
uuid_timageUUIDUUID of image

structuser64_dyld_uuid_info

size 24, align 8
uint64_timageLoadAddressbase address image is mapped into
uuid_timageUUIDUUID of image

structuser64_dyld_aot_info

size 56, align 8
uint64_tx86LoadAddress
uint64_taotLoadAddress
uint64_taotImageSize
uint8_t[32]aotImageKey

enumtask_snapshot_flags

underlying type unsigned long
kTaskRsrcFlagged4k{User,Kernel}64_p (values 0x1 and 0x2) are defined in generic_snapshot_flags In the EXC_RESOURCE danger zone?
kTerminatedSnapshot8
kPidSuspended16true for suspended task
kFrozen32true for hibernated task (along with pidsuspended)
kTaskDarwinBG64
kTaskExtDarwinBG128
kTaskVisVisible256
kTaskVisNonvisible512
kTaskIsForeground1024
kTaskIsBoosted2048
kTaskIsSuppressed4096
kTaskIsTimerThrottled8192deprecated
kTaskIsImpDonor16384
kTaskIsLiveImpDonor32768
kTaskIsDirty65536
kTaskWqExceededConstrainedThreadLimit131072
kTaskWqExceededTotalThreadLimit262144
kTaskWqFlagsAvailable524288
kTaskUUIDInfoFaultedIn1048576successfully faulted in some UUID info
kTaskUUIDInfoMissing2097152some UUID info was paged out
kTaskUUIDInfoTriedFault4194304tried to fault in UUID info
kTaskSharedRegionInfoUnavailable8388608shared region info unavailable
kTaskTALEngaged16777216
kTaskIsDirtyTracked671088640x2000000 unused
kTaskAllowIdleExit134217728
kTaskIsTranslated268435456
kTaskSharedRegionNone536870912task doesn't have a shared region
kTaskSharedRegionSystem1073741824task attached to region with kSharedCacheSystemPrimary set
kTaskSharedRegionOther2147483648task is attached to a different shared region
kTaskDyldCompactInfoNone4294967296
kTaskDyldCompactInfoTooBig8589934592
kTaskDyldCompactInfoFaultedIn17179869184
kTaskDyldCompactInfoMissing34359738368
kTaskDyldCompactInfoTriedFault68719476736
kTaskWqExceededCooperativeThreadLimit137438953472
kTaskWqExceededActiveConstrainedThreadLimit274877906944
kTaskRunawayMitigation549755813888
kTaskIsActive1099511627776
kTaskIsManaged2199023255552
kTaskHasAssertion4398046511104
Note: Add any new flags to kcdata.py (ts_ss_flags)

enumtask_transition_type

underlying type unsigned int
kTaskIsTerminated1Past LPEXIT

enumtask_exec_flags

See kcdata_private.h for more flag definitions
underlying type uint64_t
kTaskExecTranslated1Task is running under translation (eg, Rosetta)
kTaskExecHardenedHeap2Task has the hardened heap security feature
kTaskExecReserved004
kTaskExecReserved018
kTaskExecReserved0216
kTaskExecReserved0332

structtask_exec_meta

metadata about a task that is fixed at spawn/exec time
size 8, align 1 · packed
uint64_ttem_flagstask_exec_flags

enummte_info_cell_state_t

MTE info cell state, must match mte_cell_state_t
underlying type uint8_t
MTE_INFO_STATE_DISABLED0
MTE_INFO_STATE_PINNED1
MTE_INFO_STATE_DEACTIVATING2
MTE_INFO_STATE_CLAIMED3
MTE_INFO_STATE_INACTIVE4
MTE_INFO_STATE_RECLAIMING5
MTE_INFO_STATE_ACTIVATING6
MTE_INFO_STATE_ACTIVE7

typedefmte_info_cell_state_t

typedef enum mte_info_cell_state_t mte_info_cell_state_t;

structmte_info_cell

MTE info cell data
size 6, align 1 · packed
uint8_tmic_state
uint8_tmic_tagged_countNumber of tagged pages in this tag storage page
uint8_tmic_free_countNumber of free pages in this tag storage page
uint8_tmic_wired_countNumber of wired pages in this tag storage page, regardless of tagging
uint8_tmic_wired_tagged_countNumber of tagged pages wired that aren't used by kernel memory allocators
uint8_tmic_kernel_wired_tagged_countNumber of tagged pages wired for use by the kernel memory allocators, kmem and zalloc

enumthread_snapshot_flags

underlying type unsigned int
kHasDispatchSerial4k{User,Kernel}64_p (values 0x1 and 0x2) are defined in generic_snapshot_flags
kStacksPCOnly8Stack traces have no frame pointers.
kThreadDarwinBG16Thread is darwinbg
kThreadIOPassive32Thread uses passive IO
kThreadSuspended64Thread is suspended
kThreadTruncatedBT128Unmapped pages caused truncated backtrace
kGlobalForcedIdle256Thread performs global forced idle
kThreadFaultedBT512Some thread stack pages were faulted in as part of BT
kThreadTriedFaultBT1024We tried to fault in thread stack pages as part of BT
kThreadOnCore2048Thread was on-core when we entered debugger context
kThreadIdleWorker4096Thread is an idle libpthread worker thread
kThreadMain8192Thread is the main thread
kThreadTruncKernBT16384Unmapped pages caused truncated kernel BT
kThreadTruncUserBT32768Unmapped pages caused truncated user BT
kThreadTruncUserAsyncBT65536Unmapped pages caused truncated user async BT
Note: Add any new flags to kcdata.py (ths_ss_flags)

structmem_and_io_snapshot

size 61, align 1 · packed
uint32_tsnapshot_magic
uint32_tfree_pages
uint32_tactive_pages
uint32_tinactive_pages
uint32_tpurgeable_pages
uint32_twired_pages
uint32_tspeculative_pages
uint32_tthrottled_pages
uint32_tfilebacked_pages
uint32_tcompressions
uint32_tdecompressions
uint32_tcompressor_size
int32_tbusy_buffer_count
uint32_tpages_wanted
uint32_tpages_reclaimed
uint8_tpages_wanted_reclaimed_validdid mach_vm_pressure_monitor succeed?

structmem_and_io_snapshot_v2

size 73, align 1 · packed
uint32_tsnapshot_magic
uint32_tfree_pages
uint32_tactive_pages
uint32_tinactive_pages
uint32_tpurgeable_pages
uint32_twired_pages
uint32_tspeculative_pages
uint32_tthrottled_pages
uint32_tfilebacked_pages
uint32_tcompressions
uint32_tdecompressions
uint32_tcompressor_size
int32_tbusy_buffer_count
uint32_tpages_wanted
uint32_tpages_reclaimed
uint8_tpages_wanted_reclaimed_validdid mach_vm_pressure_monitor succeed?
uint32_tshared_region_pages
uint32_tcompressed_pages
uint32_tswapped_pages

macroSS_TH_WAIT

SS_TH_* macros are for ths_state
#define SS_TH_WAIT 0x01
queued for waiting

macroSS_TH_SUSP

#define SS_TH_SUSP 0x02
stopped or requested to stop

macroSS_TH_RUN

#define SS_TH_RUN 0x04
running or on runq

macroSS_TH_UNINT

#define SS_TH_UNINT 0x08
waiting uninteruptibly

macroSS_TH_TERMINATE

#define SS_TH_TERMINATE 0x10
halted at termination

macroSS_TH_TERMINATE2

#define SS_TH_TERMINATE2 0x20
added to termination queue

macroSS_TH_IDLE

#define SS_TH_IDLE 0x80
idling processor

structthread_snapshot_v2

size 104, align 1 · packed
uint64_tths_thread_id
uint64_tths_wait_event
uint64_tths_continuation
uint64_tths_total_syscalls
uint64_tths_voucher_identifier
uint64_tths_dqserialnum
uint64_tths_user_time
uint64_tths_sys_time
uint64_tths_ss_flags
uint64_tths_last_run_time
uint64_tths_last_made_runnable_time
uint32_tths_state
uint32_tths_sched_flags
int16_tths_base_priority
int16_tths_sched_priority
uint8_tths_eqos
uint8_tths_rqos
uint8_tths_rqos_override
uint8_tths_io_tier

structthread_snapshot_v3

size 112, align 1 · packed
uint64_tths_thread_id
uint64_tths_wait_event
uint64_tths_continuation
uint64_tths_total_syscalls
uint64_tths_voucher_identifier
uint64_tths_dqserialnum
uint64_tths_user_time
uint64_tths_sys_time
uint64_tths_ss_flags
uint64_tths_last_run_time
uint64_tths_last_made_runnable_time
uint32_tths_state
uint32_tths_sched_flags
int16_tths_base_priority
int16_tths_sched_priority
uint8_tths_eqos
uint8_tths_rqos
uint8_tths_rqos_override
uint8_tths_io_tier
uint64_tths_thread_t

structthread_snapshot_v4

size 128, align 1 · packed
uint64_tths_thread_id
uint64_tths_wait_event
uint64_tths_continuation
uint64_tths_total_syscalls
uint64_tths_voucher_identifier
uint64_tths_dqserialnum
uint64_tths_user_time
uint64_tths_sys_time
uint64_tths_ss_flags
uint64_tths_last_run_time
uint64_tths_last_made_runnable_time
uint32_tths_state
uint32_tths_sched_flags
int16_tths_base_priority
int16_tths_sched_priority
uint8_tths_eqos
uint8_tths_rqos
uint8_tths_rqos_override
uint8_tths_io_tier
uint64_tths_thread_t
uint64_tths_requested_policy
uint64_tths_effective_policy

structthread_group_snapshot

size 24, align 1 · packed
uint64_ttgs_id
char[16]tgs_name

enumthread_group_flags

In general these flags mirror their THREAD_GROUP_FLAGS_ counterparts. THREAD_GROUP_FLAGS_UI_APP was repurposed and THREAD_GROUP_FLAGS_APPLICATION introduced to take its place. To remain compatible, kThreadGroupUIApp is kept around and kThreadGroupUIApplication introduced.
underlying type unsigned int
kThreadGroupEfficient1
kThreadGroupApplication2
kThreadGroupUIApp2
kThreadGroupCritical4
kThreadGroupBestEffort8
kThreadGroupUIApplication256
kThreadGroupManaged512
kThreadGroupStrictTimers1024
Note: Add any new flags to kcdata.py (tgs_flags)

structthread_group_snapshot_v2

size 32, align 1 · packed
uint64_ttgs_id
char[16]tgs_name
uint64_ttgs_flags

structthread_group_snapshot_v3

size 48, align 1 · packed
uint64_ttgs_id
char[16]tgs_name
uint64_ttgs_flags
char[16]tgs_name_cont

enumcoalition_flags

underlying type unsigned int
kCoalitionTermRequested1
kCoalitionTerminated2
kCoalitionReaped4
kCoalitionPrivileged8
Note: Add any new flags to kcdata.py (jcs_flags)

structjetsam_coalition_snapshot

size 32, align 1 · packed
uint64_tjcs_id
uint64_tjcs_flags
uint64_tjcs_thread_group
uint64_tjcs_leader_task_uniqueid

structinstrs_cycles_snapshot

size 16, align 1 · packed
uint64_tics_instructions
uint64_tics_cycles

structinstrs_cycles_snapshot_v2

size 32, align 1 · packed
uint64_tics_instructions
uint64_tics_cycles
uint64_tics_p_instructions
uint64_tics_p_cycles

structthread_delta_snapshot_v2

size 48, align 1 · packed
uint64_ttds_thread_id
uint64_ttds_voucher_identifier
uint64_ttds_ss_flags
uint64_ttds_last_made_runnable_time
uint32_ttds_state
uint32_ttds_sched_flags
int16_ttds_base_priority
int16_ttds_sched_priority
uint8_ttds_eqos
uint8_ttds_rqos
uint8_ttds_rqos_override
uint8_ttds_io_tier

structthread_delta_snapshot_v3

size 64, align 1 · packed
uint64_ttds_thread_id
uint64_ttds_voucher_identifier
uint64_ttds_ss_flags
uint64_ttds_last_made_runnable_time
uint32_ttds_state
uint32_ttds_sched_flags
int16_ttds_base_priority
int16_ttds_sched_priority
uint8_ttds_eqos
uint8_ttds_rqos
uint8_ttds_rqos_override
uint8_ttds_io_tier
uint64_ttds_requested_policy
uint64_ttds_effective_policy

structio_stats_snapshot

size 160, align 1 · packed
uint64_tss_disk_reads_countI/O Statistics XXX: These fields must be together.
uint64_tss_disk_reads_size
uint64_tss_disk_writes_count
uint64_tss_disk_writes_size
uint64_t[4]ss_io_priority_count
uint64_t[4]ss_io_priority_size
uint64_tss_paging_count
uint64_tss_paging_size
uint64_tss_non_paging_count
uint64_tss_non_paging_size
uint64_tss_data_count
uint64_tss_data_size
uint64_tss_metadata_count
uint64_tss_metadata_size

structtask_snapshot_v2

size 120, align 1 · packed
uint64_tts_unique_pid
uint64_tts_ss_flags
uint64_tts_user_time_in_terminated_threads
uint64_tts_system_time_in_terminated_threads
uint64_tts_p_start_sec
uint64_tts_task_size
uint64_tts_max_resident_size
uint32_tts_suspend_count
uint32_tts_faults
uint32_tts_pageins
uint32_tts_cow_faults
uint32_tts_was_throttled
uint32_tts_did_throttle
uint32_tts_latency_qos
int32_tts_pid
char[32]ts_p_comm

structtask_snapshot_v3

size 128, align 1 · packed
uint64_tts_unique_pid
uint64_tts_ss_flags
uint64_tts_user_time_in_terminated_threads
uint64_tts_system_time_in_terminated_threads
uint64_tts_p_start_sec
uint64_tts_task_size
uint64_tts_max_resident_size
uint32_tts_suspend_count
uint32_tts_faults
uint32_tts_pageins
uint32_tts_cow_faults
uint32_tts_was_throttled
uint32_tts_did_throttle
uint32_tts_latency_qos
int32_tts_pid
char[32]ts_p_comm
uint32_tts_uid
uint32_tts_gid

structtransitioning_task_snapshot

size 60, align 1 · packed
uint64_ttts_unique_pid
uint64_ttts_ss_flags
uint64_ttts_transition_type
int32_ttts_pid
char[32]tts_p_comm

structtask_delta_snapshot_v2

size 76, align 1 · packed
uint64_ttds_unique_pid
uint64_ttds_ss_flags
uint64_ttds_user_time_in_terminated_threads
uint64_ttds_system_time_in_terminated_threads
uint64_ttds_task_size
uint64_ttds_max_resident_size
uint32_ttds_suspend_count
uint32_ttds_faults
uint32_ttds_pageins
uint32_ttds_cow_faults
uint32_ttds_was_throttled
uint32_ttds_did_throttle
uint32_ttds_latency_qos

structtask_memorystatus_snapshot

size 16, align 1 · packed
int32_ttms_current_memlimit
int32_ttms_effectivepriority
int32_ttms_requestedpriority
int32_ttms_assertionpriority

macroKCDATA_INVALID_CS_TRUST_LEVEL

#define KCDATA_INVALID_CS_TRUST_LEVEL 0xffffffff

structstackshot_task_codesigning_info

size 12, align 1 · packed
uint64_tcsflags
uint32_tcs_trust_level

structstackshot_cpu_times

size 16, align 1 · packed
uint64_tuser_usec
uint64_tsystem_usec

structstackshot_cpu_times_v2

size 24, align 1 · packed
uint64_tuser_usec
uint64_tsystem_usec
uint64_trunnable_usec

structstackshot_duration

size 16, align 1 · packed
uint64_tstackshot_duration
uint64_tstackshot_duration_outer

structstackshot_duration_v2

size 24, align 1 · packed
uint64_tstackshot_duration
uint64_tstackshot_duration_outer
uint64_tstackshot_duration_prior

structstackshot_fault_stats

size 21, align 1 · packed
uint32_tsfs_pages_faulted_innumber of pages faulted in using KDP fault path
uint64_tsfs_time_spent_faultingMATUs spent faulting
uint64_tsfs_system_max_fault_timeMATUs fault time limit per stackshot
uint8_tsfs_stopped_faultingwe stopped decompressing because we hit the limit

structstackshot_thread_waitinfo

size 25, align 1 · packed
uint64_townerThe thread that owns the object
uint64_twaiterThe thread that's waiting on the object
uint64_tcontextA context uniquely identifying the object
uint8_twait_typeThe type of object that the thread is waiting on

typedefthread_waitinfo_t

typedef struct stackshot_thread_waitinfo thread_waitinfo_t;

structstackshot_thread_waitinfo_v2

size 31, align 1 · packed
uint64_townerThe thread that owns the object
uint64_twaiterThe thread that's waiting on the object
uint64_tcontextA context uniquely identifying the object
uint8_twait_typeThe type of object that the thread is waiting on
int16_tportlabel_idmatches to a stackshot_portlabel, or NONE or MISSING
uint32_twait_flagsinfo about the wait

typedefthread_waitinfo_v2_t

typedef struct stackshot_thread_waitinfo_v2 thread_waitinfo_v2_t;

macroSTACKSHOT_WAITINFO_FLAGS_SPECIALREPLY

#define STACKSHOT_WAITINFO_FLAGS_SPECIALREPLY 0x1
We're waiting on a special reply port

macroSTACKSHOT_WAITINFO_FLAGS_BOOTSTRAP

#define STACKSHOT_WAITINFO_FLAGS_BOOTSTRAP 0x2
We're waiting on a bootstrap port

structstackshot_vmrl_blocking_relationship

size 28, align 1 · packed
uint64_twaiter_tid
uint64_tblocker_tid
uint64_tentry_hash
uint32_tflags

typedefvmrl_blocking_relationship_t

typedef struct stackshot_vmrl_blocking_relationship vmrl_blocking_relationship_t;

macroSTACKSHOT_WAITER_VMRL_SHARED

#define STACKSHOT_WAITER_VMRL_SHARED 0x01

macroSTACKSHOT_BLOCKER_VMRL_SHARED

#define STACKSHOT_BLOCKER_VMRL_SHARED 0x02

macroSTACKSHOT_WAITER_VMRL_EXCLUSIVE

#define STACKSHOT_WAITER_VMRL_EXCLUSIVE 0x04

macroSTACKSHOT_BLOCKER_VMRL_EXCLUSIVE

#define STACKSHOT_BLOCKER_VMRL_EXCLUSIVE 0x08

macroSTACKSHOT_WAITER_VMRL_STREAMING

#define STACKSHOT_WAITER_VMRL_STREAMING 0x10

macroSTACKSHOT_BLOCKER_VMRL_STREAMING

#define STACKSHOT_BLOCKER_VMRL_STREAMING 0x20

macroSTACKSHOT_WAITER_VMRL_ATOMIC

#define STACKSHOT_WAITER_VMRL_ATOMIC 0x40

macroSTACKSHOT_BLOCKER_VMRL_ATOMIC

#define STACKSHOT_BLOCKER_VMRL_ATOMIC 0x80

structstackshot_thread_turnstileinfo

size 26, align 1 · packed
uint64_twaiterThe thread that's waiting on the object
uint64_tturnstile_contextAssociated data (either thread id, or workq addr)
uint8_tturnstile_priority
uint8_tnumber_of_hops
uint64_tturnstile_flagssee below

typedefthread_turnstileinfo_t

typedef struct stackshot_thread_turnstileinfo thread_turnstileinfo_t;

structstackshot_thread_turnstileinfo_v2

size 28, align 1 · packed
uint64_twaiterThe thread that's waiting on the object
uint64_tturnstile_contextAssociated data (either thread id, or workq addr)
uint8_tturnstile_priority
uint8_tnumber_of_hops
uint64_tturnstile_flagsNote: Add any new flags to kcdata.py (turnstile_flags)
int16_tportlabel_idmatches to a stackshot_portlabel, or NONE or MISSING

typedefthread_turnstileinfo_v2_t

typedef struct stackshot_thread_turnstileinfo_v2 thread_turnstileinfo_v2_t;

macroSTACKSHOT_TURNSTILE_STATUS_UNKNOWN

#define STACKSHOT_TURNSTILE_STATUS_UNKNOWN 0x01
The final inheritor is unknown (bug?)

macroSTACKSHOT_TURNSTILE_STATUS_LOCKED_WAITQ

#define STACKSHOT_TURNSTILE_STATUS_LOCKED_WAITQ 0x02
A waitq was found to be locked

macroSTACKSHOT_TURNSTILE_STATUS_WORKQUEUE

#define STACKSHOT_TURNSTILE_STATUS_WORKQUEUE 0x04
The final inheritor is a workqueue

macroSTACKSHOT_TURNSTILE_STATUS_THREAD

#define STACKSHOT_TURNSTILE_STATUS_THREAD 0x08
The final inheritor is a thread

macroSTACKSHOT_TURNSTILE_STATUS_BLOCKED_ON_TASK

#define STACKSHOT_TURNSTILE_STATUS_BLOCKED_ON_TASK 0x10
blocked on task, dind't find thread

macroSTACKSHOT_TURNSTILE_STATUS_HELD_IPLOCK

#define STACKSHOT_TURNSTILE_STATUS_HELD_IPLOCK 0x20
the ip_lock was held

macroSTACKSHOT_TURNSTILE_STATUS_SENDPORT

#define STACKSHOT_TURNSTILE_STATUS_SENDPORT 0x40
port_labelid was from a send port

macroSTACKSHOT_TURNSTILE_STATUS_RECEIVEPORT

#define STACKSHOT_TURNSTILE_STATUS_RECEIVEPORT 0x80
port_labelid was from a receive port

macroSTACKSHOT_PORTLABELID_NONE

#define STACKSHOT_PORTLABELID_NONE (0)
No port label found

macroSTACKSHOT_PORTLABELID_MISSING

#define STACKSHOT_PORTLABELID_MISSING (-1)
portlabel found, but stackshot ran out of space to track it

macroSTACKSHOT_WAITOWNER_KERNEL

#define STACKSHOT_WAITOWNER_KERNEL (UINT64_MAX - 1)

macroSTACKSHOT_WAITOWNER_PORT_LOCKED

#define STACKSHOT_WAITOWNER_PORT_LOCKED (UINT64_MAX - 2)

macroSTACKSHOT_WAITOWNER_PSET_LOCKED

#define STACKSHOT_WAITOWNER_PSET_LOCKED (UINT64_MAX - 3)

macroSTACKSHOT_WAITOWNER_INTRANSIT

#define STACKSHOT_WAITOWNER_INTRANSIT (UINT64_MAX - 4)

macroSTACKSHOT_WAITOWNER_MTXSPIN

#define STACKSHOT_WAITOWNER_MTXSPIN (UINT64_MAX - 5)

macroSTACKSHOT_WAITOWNER_THREQUESTED

#define STACKSHOT_WAITOWNER_THREQUESTED (UINT64_MAX - 6)
workloop waiting for a new worker thread

macroSTACKSHOT_WAITOWNER_SUSPENDED

#define STACKSHOT_WAITOWNER_SUSPENDED (UINT64_MAX - 7)
workloop is suspended

macroSTACKSHOT_PORTLABEL_READFAILED

#define STACKSHOT_PORTLABEL_READFAILED 0x1
could not read port information

macroSTACKSHOT_PORTLABEL_THROTTLED

#define STACKSHOT_PORTLABEL_THROTTLED 0x2
service port is marked as throttled

structportlabel_info

size 5, align 1 · packed
int16_tportlabel_idkcdata-specific ID for this port label
uint16_tportlabel_flagsSTACKSHOT_PORTLABEL_*
uint8_tportlabel_domainlaunchd domain

structstackshot_cpu_architecture

size 8, align 1 · packed
int32_tcputype
int32_tcpusubtype

structstack_snapshot_stacktop

size 16, align 8
uint64_tsp
uint8_t[8]stack_contents

structstackshot_latency_collection

only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0
size 32, align 1 · packed
uint64_tlatency_version
uint64_tsetup_latency
uint64_ttotal_task_iteration_latency
uint64_ttotal_terminated_task_iteration_latency

structstackshot_latency_collection_v2

only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0
size 96, align 1 · packed
uint64_tlatency_version
uint64_tsetup_latency_mt
uint64_ttotal_task_iteration_latency_mt
uint64_ttotal_terminated_task_iteration_latency_mt
uint64_ttask_queue_building_latency_mt
uint64_tterminated_task_queue_building_latency_mt
uint64_tcpu_wait_latency_mt
int32_tmain_cpu_number
int32_tcalling_cpu_number
uint64_tbuffer_size
uint64_tbuffer_used
uint64_tbuffer_overhead
uint64_tbuffer_count

structstackshot_latency_cpu

only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0
size 88, align 1 · packed
int32_tcpu_number
int32_tcluster_type
uint64_tinit_latency_mt
uint64_tworkqueue_latency_mt
uint64_ttotal_latency_mt
uint64_ttotal_cycles
uint64_ttotal_instrs
uint64_ttasks_processed
uint64_tthreads_processed
uint64_tfaulting_time_mt
uint64_ttotal_buf
uint64_tintercluster_buf_used

structstackshot_latency_buffer

only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0
size 28, align 1 · packed
int32_tcluster_type
uint64_tsize
uint64_tused
uint64_toverhead

structstackshot_latency_task

only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0
size 80, align 1 · packed
uint64_ttask_uniqueid
uint64_tsetup_latency
uint64_ttask_thread_count_loop_latency
uint64_ttask_thread_data_loop_latency
uint64_tcur_tsnap_latency
uint64_tpmap_latency
uint64_tbsd_proc_ids_latency
uint64_tmisc_latency
uint64_tmisc2_latency
uint64_tend_latency

structstackshot_latency_thread

only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0
size 80, align 1 · packed
uint64_tthread_id
uint64_tcur_thsnap1_latency
uint64_tdispatch_serial_latency
uint64_tdispatch_label_latency
uint64_tcur_thsnap2_latency
uint64_tthread_name_latency
uint64_tsur_times_latency
uint64_tuser_stack_latency
uint64_tkernel_stack_latency
uint64_tmisc_latency

structstackshot_suspension_info

size 32, align 1 · packed
uint64_ttss_last_startmach_absolute_time of beginning of last suspension
uint64_ttss_last_endmach_absolute_time of end of last suspension
uint64_ttss_countnumber of times this task has been suspended
uint64_ttss_durationsum(mach_absolute_time) of time spend suspended

structstackshot_suspension_source

size 85, align 1 · packed
uint64_ttss_timemach_absolute_time of suspend
uint64_ttss_tidtid of suspending thread
inttss_pidpid of suspending task
char[65]tss_procnamename of suspending task

structstackshot_device_lock_state

size 3, align 1 · packed
uint8_tflagsinterpret as a stackshot_device_lock_flags_t
uint8_tpasscode_statusinterpret as a passcode_status_t
uint8_tlock_stateinterpret as a device_lock_state_t

enumthread_exclaves_flags

underlying type uint32_t
kExclaveRPCActive1Thread is handling RPC call in secure world
kExclaveUpcallActive2Thread has upcalled back into xnu while handling RPC
kExclaveSchedulerRequest4Thread is handling scheduler request

structthread_exclaves_info

size 16, align 1 · packed
uint64_ttei_scid
uint32_ttei_thread_offset
uint32_ttei_flags

structthread_crash_exclaves_info

size 20, align 1 · packed
uint64_ttcei_scid
uint64_ttcei_thread_idCorresponding xnu thread id
uint32_ttcei_flags

enumexclave_scresult_flags

underlying type uint64_t
kExclaveScresultHaveIPCStack1

structexclave_scresult_info

size 16, align 1 · packed
uint64_tesc_id
uint64_tesc_flags

enumexclave_ipcstackentry_flags

underlying type uint64_t
kExclaveIpcStackEntryHaveInvocationID1
kExclaveIpcStackEntryHaveStack2

structexclave_ipcstackentry_info

size 32, align 1 · packed
uint64_teise_asidASID
uint64_teise_tnidThread numeric ID, may be UINT64_MAX if ommitted
uint64_teise_invocationidInvocation ID, may be UINT64_MAX if ommitted
uint64_teise_flags

typedefexclave_ecstackentry_addr_t

typedef uint64_t exclave_ecstackentry_addr_t

enumexclave_addressspace_flags

underlying type uint64_t
kExclaveAddressSpaceHaveSlide1slide info provided

structexclave_addressspace_info

size 40, align 1 · packed
uint64_teas_idASID
uint64_teas_flags
uint64_teas_layoutidtextLayout for this address space
uint64_teas_slideslide to apply to textlayout, or UINT64_MAX if omitted
uint64_teas_asrootASRoot/TTBR0 value used as an identifier for the address space by cL4

enumexclave_textlayout_flags

underlying type uint64_t
kExclaveTextLayoutLoadAddressesSynthetic1Load Addresses are synthetic
kExclaveTextLayoutLoadAddressesUnslid2Load Addresses are accurate and unslid
kExclaveTextLayoutHasSharedCache4

structexclave_textlayout_info_v1

size 16, align 1 · packed
uint64_tlayout_id
uint64_tetl_flags

structexclave_textlayout_info

size 20, align 1 · packed
uint64_tlayout_id
uint64_tetl_flags
uint32_tsharedcache_indexindex in SEGMENTs, or UINT32_MAX

structexclave_textlayout_segment

size 24, align 1 · packed
uuid_tlayoutSegment_uuid
uint64_tlayoutSegment_loadAddressSynthetic Load Address

structexclave_textlayout_segment_v2

size 32, align 1 · packed
uuid_tlayoutSegment_uuid
uint64_tlayoutSegment_loadAddressSynthetic Load Address
uint64_tlayoutSegment_rawLoadAddressRaw Load Address when unslided

structcrashinfo_proc_uniqidentifierinfo

size 56, align 1 · packed
uint8_t[16]p_uuidUUID of the main executable
uint64_tp_uniqueid64 bit unique identifier for process
uint64_tp_puniqueidunique identifier for process's parent
uint64_tp_reserve2reserved for future use
uint64_tp_reserve3reserved for future use
uint64_tp_reserve4reserved for future use

macroMAX_TRIAGE_STRING_LEN

#define MAX_TRIAGE_STRING_LEN (128)

structkernel_triage_info_v1

size 640, align 1 · packed
char[128]triage_string1
char[128]triage_string2
char[128]triage_string3
char[128]triage_string4
char[128]triage_string5

structcrashinfo_jit_address_range

size 16, align 1 · packed
uint64_tstart_address
uint64_tend_address

structcrashinfo_mb

size 520, align 1 · packed
uint64_tstart_address
uint64_t[64]data

structcrashinfo_task_security_config

size 4, align 1 · packed
uint32_ttask_security_configstruct task_security_config

structcrashinfo_voucher

size 16, align 1 · packed
uint64_tthread_id
uint32_toriginator_pid
uint32_tproximate_pid

macroMAX_CRASHINFO_SIGNING_ID_LEN

#define MAX_CRASHINFO_SIGNING_ID_LEN 64

macroMAX_CRASHINFO_TEAM_ID_LEN

#define MAX_CRASHINFO_TEAM_ID_LEN 32

macroMAX_CRASHINFO_SANDBOX_PROFILE_LEN

#define MAX_CRASHINFO_SANDBOX_PROFILE_LEN 32

macroTASK_CRASHINFO_BEGIN

#define TASK_CRASHINFO_BEGIN KCDATA_BUFFER_BEGIN_CRASHINFO

macroTASK_CRASHINFO_STRING_DESC

#define TASK_CRASHINFO_STRING_DESC KCDATA_TYPE_STRING_DESC

macroTASK_CRASHINFO_UINT32_DESC

#define TASK_CRASHINFO_UINT32_DESC KCDATA_TYPE_UINT32_DESC

macroTASK_CRASHINFO_UINT64_DESC

#define TASK_CRASHINFO_UINT64_DESC KCDATA_TYPE_UINT64_DESC

macroTASK_CRASHINFO_EXTMODINFO

#define TASK_CRASHINFO_EXTMODINFO 0x801

macroTASK_CRASHINFO_BSDINFOWITHUNIQID

#define TASK_CRASHINFO_BSDINFOWITHUNIQID 0x802

macroTASK_CRASHINFO_TASKDYLD_INFO

#define TASK_CRASHINFO_TASKDYLD_INFO 0x803

macroTASK_CRASHINFO_UUID

#define TASK_CRASHINFO_UUID 0x804

macroTASK_CRASHINFO_PID

#define TASK_CRASHINFO_PID 0x805

macroTASK_CRASHINFO_PPID

#define TASK_CRASHINFO_PPID 0x806

macroTASK_CRASHINFO_RUSAGE

#define TASK_CRASHINFO_RUSAGE 0x807
struct rusage DEPRECATED do not use. This struct has longs in it

macroTASK_CRASHINFO_RUSAGE_INFO

#define TASK_CRASHINFO_RUSAGE_INFO 0x808
struct rusage_info_v3 from resource.h

macroTASK_CRASHINFO_PROC_NAME

#define TASK_CRASHINFO_PROC_NAME 0x809
char *

macroTASK_CRASHINFO_PROC_STARTTIME

#define TASK_CRASHINFO_PROC_STARTTIME 0x80B
struct timeval64

macroTASK_CRASHINFO_USERSTACK

#define TASK_CRASHINFO_USERSTACK 0x80C
uint64_t

macroTASK_CRASHINFO_ARGSLEN

#define TASK_CRASHINFO_ARGSLEN 0x80D

macroTASK_CRASHINFO_EXCEPTION_CODES

#define TASK_CRASHINFO_EXCEPTION_CODES 0x80E

macroTASK_CRASHINFO_PROC_PATH

#define TASK_CRASHINFO_PROC_PATH 0x80F
string of len MAXPATHLEN

macroTASK_CRASHINFO_PROC_CSFLAGS

#define TASK_CRASHINFO_PROC_CSFLAGS 0x810
uint32_t

macroTASK_CRASHINFO_PROC_STATUS

#define TASK_CRASHINFO_PROC_STATUS 0x811
char

macroTASK_CRASHINFO_UID

#define TASK_CRASHINFO_UID 0x812

macroTASK_CRASHINFO_GID

#define TASK_CRASHINFO_GID 0x813

macroTASK_CRASHINFO_PROC_ARGC

#define TASK_CRASHINFO_PROC_ARGC 0x814
int

macroTASK_CRASHINFO_PROC_FLAGS

#define TASK_CRASHINFO_PROC_FLAGS 0x815
unsigned int

macroTASK_CRASHINFO_CPUTYPE

#define TASK_CRASHINFO_CPUTYPE 0x816

macroTASK_CRASHINFO_WORKQUEUEINFO

#define TASK_CRASHINFO_WORKQUEUEINFO 0x817

macroTASK_CRASHINFO_RESPONSIBLE_PID

#define TASK_CRASHINFO_RESPONSIBLE_PID 0x818

macroTASK_CRASHINFO_DIRTY_FLAGS

#define TASK_CRASHINFO_DIRTY_FLAGS 0x819
int

macroTASK_CRASHINFO_CRASHED_THREADID

#define TASK_CRASHINFO_CRASHED_THREADID 0x81A
uint64_t

macroTASK_CRASHINFO_COALITION_ID

#define TASK_CRASHINFO_COALITION_ID 0x81B
uint64_t

macroTASK_CRASHINFO_UDATA_PTRS

#define TASK_CRASHINFO_UDATA_PTRS 0x81C
uint64_t

macroTASK_CRASHINFO_MEMORY_LIMIT

#define TASK_CRASHINFO_MEMORY_LIMIT 0x81D
uint64_t

macroTASK_CRASHINFO_LEDGER_INTERNAL

#define TASK_CRASHINFO_LEDGER_INTERNAL 0x81E
uint64_t

macroTASK_CRASHINFO_LEDGER_INTERNAL_COMPRESSED

#define TASK_CRASHINFO_LEDGER_INTERNAL_COMPRESSED 0x81F
uint64_t

macroTASK_CRASHINFO_LEDGER_IOKIT_MAPPED

#define TASK_CRASHINFO_LEDGER_IOKIT_MAPPED 0x820
uint64_t

macroTASK_CRASHINFO_LEDGER_ALTERNATE_ACCOUNTING

#define TASK_CRASHINFO_LEDGER_ALTERNATE_ACCOUNTING 0x821
uint64_t

macroTASK_CRASHINFO_LEDGER_ALTERNATE_ACCOUNTING_COMPRESSED

#define TASK_CRASHINFO_LEDGER_ALTERNATE_ACCOUNTING_COMPRESSED 0x822
uint64_t

macroTASK_CRASHINFO_LEDGER_PURGEABLE_NONVOLATILE

#define TASK_CRASHINFO_LEDGER_PURGEABLE_NONVOLATILE 0x823
uint64_t

macroTASK_CRASHINFO_LEDGER_PURGEABLE_NONVOLATILE_COMPRESSED

#define TASK_CRASHINFO_LEDGER_PURGEABLE_NONVOLATILE_COMPRESSED 0x824
uint64_t

macroTASK_CRASHINFO_LEDGER_PAGE_TABLE

#define TASK_CRASHINFO_LEDGER_PAGE_TABLE 0x825
uint64_t

macroTASK_CRASHINFO_LEDGER_PHYS_FOOTPRINT

#define TASK_CRASHINFO_LEDGER_PHYS_FOOTPRINT 0x826
uint64_t

macroTASK_CRASHINFO_LEDGER_PHYS_FOOTPRINT_LIFETIME_MAX

#define TASK_CRASHINFO_LEDGER_PHYS_FOOTPRINT_LIFETIME_MAX 0x827
uint64_t

macroTASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE

#define TASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE 0x828
uint64_t

macroTASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE_COMPRESSED

#define TASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE_COMPRESSED 0x829
uint64_t

macroTASK_CRASHINFO_LEDGER_WIRED_MEM

#define TASK_CRASHINFO_LEDGER_WIRED_MEM 0x82A
uint64_t

macroTASK_CRASHINFO_PROC_PERSONA_ID

#define TASK_CRASHINFO_PROC_PERSONA_ID 0x82B

macroTASK_CRASHINFO_MEMORY_LIMIT_INCREASE

#define TASK_CRASHINFO_MEMORY_LIMIT_INCREASE 0x82C
uint32_t

macroTASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT

#define TASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT 0x82D
uint64_t

macroTASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT_COMPRESSED

#define TASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT_COMPRESSED 0x82E
uint64_t

macroTASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT

#define TASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT 0x82F
uint64_t

macroTASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT_COMPRESSED

#define TASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT_COMPRESSED 0x830
uint64_t

macroTASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT

#define TASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT 0x831
uint64_t

macroTASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT_COMPRESSED

#define TASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT_COMPRESSED 0x832
uint64_t

macroTASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT

#define TASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT 0x833
uint64_t

macroTASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT_COMPRESSED

#define TASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT_COMPRESSED 0x834
uint64_t

macroTASK_CRASHINFO_MEMORYSTATUS_EFFECTIVE_PRIORITY

#define TASK_CRASHINFO_MEMORYSTATUS_EFFECTIVE_PRIORITY 0x835

macroTASK_CRASHINFO_KERNEL_TRIAGE_INFO_V1

#define TASK_CRASHINFO_KERNEL_TRIAGE_INFO_V1 0x836

macroTASK_CRASHINFO_TASK_IS_CORPSE_FORK

#define TASK_CRASHINFO_TASK_IS_CORPSE_FORK 0x837

macroTASK_CRASHINFO_EXCEPTION_TYPE

#define TASK_CRASHINFO_EXCEPTION_TYPE 0x838
int

macroTASK_CRASHINFO_CRASH_COUNT

#define TASK_CRASHINFO_CRASH_COUNT 0x839
int

macroTASK_CRASHINFO_THROTTLE_TIMEOUT

#define TASK_CRASHINFO_THROTTLE_TIMEOUT 0x83A
int

macroTASK_CRASHINFO_CS_SIGNING_ID

#define TASK_CRASHINFO_CS_SIGNING_ID 0x83B

macroTASK_CRASHINFO_CS_TEAM_ID

#define TASK_CRASHINFO_CS_TEAM_ID 0x83C

macroTASK_CRASHINFO_CS_VALIDATION_CATEGORY

#define TASK_CRASHINFO_CS_VALIDATION_CATEGORY 0x83D
uint32_t

macroTASK_CRASHINFO_CS_TRUST_LEVEL

#define TASK_CRASHINFO_CS_TRUST_LEVEL 0x83E
uint32_t

macroTASK_CRASHINFO_PROC_CPUTYPE

#define TASK_CRASHINFO_PROC_CPUTYPE 0x83F

macroTASK_CRASHINFO_JIT_ADDRESS_RANGE

#define TASK_CRASHINFO_JIT_ADDRESS_RANGE 0x840

macroTASK_CRASHINFO_MB

#define TASK_CRASHINFO_MB 0x841

macroTASK_CRASHINFO_CS_AUXILIARY_INFO

#define TASK_CRASHINFO_CS_AUXILIARY_INFO 0x842
uint64_t

macroTASK_CRASHINFO_RLIM_CORE

#define TASK_CRASHINFO_RLIM_CORE 0x843

macroTASK_CRASHINFO_CORE_ALLOWED

#define TASK_CRASHINFO_CORE_ALLOWED 0x844
uint8_t

macroTASK_CRASHINFO_TASK_SECURITY_CONFIG

#define TASK_CRASHINFO_TASK_SECURITY_CONFIG 0x845
struct task_security_config

macroTASK_CRASHINFO_VOUCHER_INFO

#define TASK_CRASHINFO_VOUCHER_INFO 0x846

macroTASK_CRASHINFO_SANDBOX_PROFILE

#define TASK_CRASHINFO_SANDBOX_PROFILE 0x847

macroTASK_CRASHINFO_END

#define TASK_CRASHINFO_END KCDATA_TYPE_BUFFER_END

structbtinfo_thread_state_data_t

tstate is variable length with count elements
size 8, align 4
uint32_tflavor
uint32_tcount
int[]tstate

structbtinfo_sc_load_info64

size 32, align 8
uint64_tsharedCacheSlide
uuid_tsharedCacheUUID
uint64_tsharedCacheBaseAddress

structbtinfo_sc_load_info

size 24, align 4
uint32_tsharedCacheSlide
uuid_tsharedCacheUUID
uint32_tsharedCacheBaseAddress

macroTASK_BTINFO_BEGIN

#define TASK_BTINFO_BEGIN KCDATA_BUFFER_BEGIN_BTINFO

macroTASK_BTINFO_PID

Shared keys with CRASHINFO
#define TASK_BTINFO_PID 0xA01

macroTASK_BTINFO_PPID

#define TASK_BTINFO_PPID 0xA02

macroTASK_BTINFO_PROC_NAME

#define TASK_BTINFO_PROC_NAME 0xA03

macroTASK_BTINFO_PROC_PATH

#define TASK_BTINFO_PROC_PATH 0xA04

macroTASK_BTINFO_UID

#define TASK_BTINFO_UID 0xA05

macroTASK_BTINFO_GID

#define TASK_BTINFO_GID 0xA06

macroTASK_BTINFO_PROC_FLAGS

#define TASK_BTINFO_PROC_FLAGS 0xA07

macroTASK_BTINFO_CPUTYPE

#define TASK_BTINFO_CPUTYPE 0xA08

macroTASK_BTINFO_EXCEPTION_CODES

#define TASK_BTINFO_EXCEPTION_CODES 0xA09

macroTASK_BTINFO_EXCEPTION_TYPE

#define TASK_BTINFO_EXCEPTION_TYPE 0xA0A

macroTASK_BTINFO_RUSAGE_INFO

#define TASK_BTINFO_RUSAGE_INFO 0xA0B

macroTASK_BTINFO_COALITION_ID

#define TASK_BTINFO_COALITION_ID 0xA0C

macroTASK_BTINFO_CRASH_COUNT

#define TASK_BTINFO_CRASH_COUNT 0xA0D

macroTASK_BTINFO_THROTTLE_TIMEOUT

#define TASK_BTINFO_THROTTLE_TIMEOUT 0xA0E

macroTASK_BTINFO_THREAD_ID

Only in BTINFO
#define TASK_BTINFO_THREAD_ID 0xA20
uint64_t

macroTASK_BTINFO_THREAD_NAME

#define TASK_BTINFO_THREAD_NAME 0xA21
string of len MAXTHREADNAMESIZE

macroTASK_BTINFO_THREAD_STATE

#define TASK_BTINFO_THREAD_STATE 0xA22

macroTASK_BTINFO_THREAD_EXCEPTION_STATE

#define TASK_BTINFO_THREAD_EXCEPTION_STATE 0xA23

macroTASK_BTINFO_BACKTRACE

#define TASK_BTINFO_BACKTRACE 0xA24
array of uintptr_t

macroTASK_BTINFO_BACKTRACE64

#define TASK_BTINFO_BACKTRACE64 0xA25
array of uintptr_t

macroTASK_BTINFO_ASYNC_BACKTRACE64

#define TASK_BTINFO_ASYNC_BACKTRACE64 0xA26
array of uintptr_t

macroTASK_BTINFO_ASYNC_START_INDEX

#define TASK_BTINFO_ASYNC_START_INDEX 0xA27
uint32_t

macroTASK_BTINFO_PLATFORM

#define TASK_BTINFO_PLATFORM 0xA28
uint32_t

macroTASK_BTINFO_SC_LOADINFO

#define TASK_BTINFO_SC_LOADINFO 0xA29

macroTASK_BTINFO_SC_LOADINFO64

#define TASK_BTINFO_SC_LOADINFO64 0xA2A

macroTASK_BTINFO_DYLD_LOADINFO

#define TASK_BTINFO_DYLD_LOADINFO KCDATA_TYPE_LIBRARY_LOADINFO

macroTASK_BTINFO_DYLD_LOADINFO64

#define TASK_BTINFO_DYLD_LOADINFO64 KCDATA_TYPE_LIBRARY_LOADINFO64

macroTASK_BTINFO_FLAGS

Last one
#define TASK_BTINFO_FLAGS 0xAFF
uint32_t

macroTASK_BTINFO_FLAG_BT_TRUNCATED

#define TASK_BTINFO_FLAG_BT_TRUNCATED 0x1

macroTASK_BTINFO_FLAG_ASYNC_BT_TRUNCATED

#define TASK_BTINFO_FLAG_ASYNC_BT_TRUNCATED 0x2

macroTASK_BTINFO_FLAG_TASK_TERMINATED

#define TASK_BTINFO_FLAG_TASK_TERMINATED 0x4
task is terminated

macroTASK_BTINFO_FLAG_KCDATA_INCOMPLETE

#define TASK_BTINFO_FLAG_KCDATA_INCOMPLETE 0x8
lw corpse collection is incomplete

macroTASK_BTINFO_END

#define TASK_BTINFO_END KCDATA_TYPE_BUFFER_END

macroEXIT_REASON_SNAPSHOT

#define EXIT_REASON_SNAPSHOT 0x1001

macroEXIT_REASON_USER_DESC

#define EXIT_REASON_USER_DESC 0x1002
string description of reason

macroEXIT_REASON_USER_PAYLOAD

#define EXIT_REASON_USER_PAYLOAD 0x1003
user payload data

macroEXIT_REASON_CODESIGNING_INFO

#define EXIT_REASON_CODESIGNING_INFO 0x1004

macroEXIT_REASON_WORKLOOP_ID

#define EXIT_REASON_WORKLOOP_ID 0x1005

macroEXIT_REASON_DISPATCH_QUEUE_NO

#define EXIT_REASON_DISPATCH_QUEUE_NO 0x1006

structexit_reason_snapshot

size 20, align 1 · packed
uint32_ters_namespace
uint64_ters_code
uint64_ters_flagsend of version 1 of exit_reason_snapshot. sizeof v1 was 12

macroEXIT_REASON_CODESIG_PATH_MAX

#define EXIT_REASON_CODESIG_PATH_MAX 1024

structcodesigning_exit_reason_info

size 2108, align 1 · packed
uint64_tceri_virt_addr
uint64_tceri_file_offset
char[1024]ceri_pathname
char[1024]ceri_filename
uint64_tceri_codesig_modtime_secs
uint64_tceri_codesig_modtime_nsecs
uint64_tceri_page_modtime_secs
uint64_tceri_page_modtime_nsecs
uint8_tceri_path_truncated
uint8_tceri_object_codesigned
uint8_tceri_page_codesig_validated
uint8_tceri_page_codesig_tainted
uint8_tceri_page_codesig_nx
uint8_tceri_page_wpmapped
uint8_tceri_page_slid
uint8_tceri_page_dirty
uint32_tceri_page_shadow_depth

macroEXIT_REASON_USER_DESC_MAX_LEN

#define EXIT_REASON_USER_DESC_MAX_LEN 1024

macroEXIT_REASON_PAYLOAD_MAX_LEN

#define EXIT_REASON_PAYLOAD_MAX_LEN 2048

structkcdata_iter

size 16, align 8
kcdata_item_titem
void *end

typedefkcdata_iter_t

typedef struct kcdata_iter kcdata_iter_t;

functionkcdata_iter

static inline kcdata_iter_t kcdata_iter(void *buffer, unsigned long size)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns an iterator over a kcdata buffer of the given size, positioned at the first item. kcdata is the self-describing, type-tagged serialization format produced by stackshot, corpse/crash info, and the kern_cdata interfaces. Check the position with kcdata_iter_valid, advance with kcdata_iter_next or the KCDATA_ITER_FOREACH macro, and inspect items with kcdata_iter_type / kcdata_iter_size / kcdata_iter_payload.

functionkcdata_iter_unsafe

__attribute__((deprecated))
static inline kcdata_iter_t kcdata_iter_unsafe(void *buffer)
deprecated
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Deprecated. Returns an iterator over the kcdata buffer with no end bound, so kcdata_iter_valid can never detect a runaway or truncated buffer. Use kcdata_iter with an explicit buffer size instead.

functionkcdata_iter_unsafe

static inline kcdata_iter_t kcdata_iter_unsafe(void *buffer)
deprecated
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Deprecated. Returns an iterator over the kcdata buffer with no end bound, so kcdata_iter_valid can never detect a runaway or truncated buffer. Use kcdata_iter with an explicit buffer size instead.

variablekcdata_invalid_iter

static const kcdata_iter_t kcdata_invalid_iter = { .item = NULL, .end = NULL }

functionkcdata_iter_valid

static inline int kcdata_iter_valid(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns nonzero if the iterator points at a complete item: both the kcdata_item header and the payload length it declares lie within the buffer bounds. Must be checked before any other accessor and after each kcdata_iter_next.

functionkcdata_iter_next

static inline kcdata_iter_t kcdata_iter_next(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns an iterator advanced past the current item (header plus declared payload size). The result must be validated with kcdata_iter_valid before use; iteration normally ends at a KCDATA_TYPE_BUFFER_END item.

functionkcdata_iter_type

static inline uint32_t kcdata_iter_type(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the type tag of the current item. The KCDATA_TYPE_ARRAY_PAD0 through _PADf variants, which encode the array padding in the low nibble of the type, are all reported as KCDATA_TYPE_ARRAY.

functionkcdata_calc_padding

static inline uint32_t kcdata_calc_padding(uint32_t size)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the number of bytes that must be added to size to round it up to a 16-byte boundary, the alignment kcdata items are padded to.

functionkcdata_flags_get_padding

static inline uint32_t kcdata_flags_get_padding(uint64_t flags)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Extracts the trailing struct padding byte count from an item's flags word (KCDATA_FLAGS_STRUCT_PADDING_MASK, the low 4 bits). kcdata_iter_size subtracts this from the stored size to recover the unpadded payload size.

functionkcdata_iter_is_legacy_item

static inline int kcdata_iter_is_legacy_item(kcdata_iter_t iter, uint32_t legacy_size)
see comment above about has_padding

functionkcdata_iter_size

static inline uint32_t kcdata_iter_size(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the payload size in bytes of the current item, with the trailing padding recorded in the item flags subtracted out. Array and container-begin items report their stored size unchanged. STACKSHOT_KCTYPE_THREAD_SNAPSHOT and STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO are special-cased to their legacy struct sizes for buffers from kernels that predate the padding flags.

functionkcdata_iter_flags

static inline uint64_t kcdata_iter_flags(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the 64-bit flags word of the current item. Its meaning is type-dependent: padding bits for struct items, element type and count for arrays, container ID for containers.

functionkcdata_iter_payload

static inline void * kcdata_iter_payload(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns a pointer to the payload of the current item, immediately following the kcdata_item header.

functionkcdata_iter_array_elem_type

static inline uint32_t kcdata_iter_array_elem_type(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the element type of the current array item, stored in the upper 32 bits of the item's flags word.

functionkcdata_iter_array_elem_count

static inline uint32_t kcdata_iter_array_elem_count(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the number of elements in the current array item, stored in the lower 32 bits of the item's flags word.

functionkcdata_iter_array_size_switch

static inline uint32_t kcdata_iter_array_size_switch(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the fixed element size for legacy KCDATA_TYPE_ARRAY items, keyed by element type (dyld_uuid_info_32/64 load info, 32- and 64-bit stack frames, thread delta snapshots, ...), or 0 for any type not in the fixed list. Legacy arrays padded their total size without recording the padding, so element size cannot be derived from the item size; an array whose element type is unknown to this switch must be treated as invalid. Newer kernels emit KCDATA_TYPE_ARRAY_PAD* instead, which records the padding explicitly.

functionkcdata_iter_array_valid

static inline int kcdata_iter_array_valid(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns nonzero if the current item is a well-formed array: the iterator is valid, the type is KCDATA_TYPE_ARRAY, and the recorded element count is consistent with the item size and padding. Legacy KCDATA_TYPE_ARRAY items must additionally have an element type with a known fixed size (kcdata_iter_array_size_switch); for KCDATA_TYPE_ARRAY_PAD* items the padding recorded in the type nibble is checked instead.

functionkcdata_iter_array_elem_size

static inline uint32_t kcdata_iter_array_elem_size(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the size in bytes of one element of the current array item: the fixed legacy size for KCDATA_TYPE_ARRAY items, otherwise the item size minus the padding recorded in the type nibble, divided by the element count.

functionkcdata_iter_container_valid

static inline int kcdata_iter_container_valid(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns nonzero if the current item is a valid KCDATA_TYPE_CONTAINER_BEGIN item whose payload holds at least the uint32_t container type.

functionkcdata_iter_container_type

static inline uint32_t kcdata_iter_container_type(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the container type (e.g. STACKSHOT_KCCONTAINER_TASK, STACKSHOT_KCCONTAINER_THREAD) stored in the payload of the current KCDATA_TYPE_CONTAINER_BEGIN item.

functionkcdata_iter_container_id

static inline uint64_t kcdata_iter_container_id(kcdata_iter_t iter)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns the 64-bit container identifier of the current container-begin item, taken from its flags word. The matching KCDATA_TYPE_CONTAINER_END item carries the same identifier, allowing nested containers to be paired.

macroKCDATA_ITER_FOREACH

#define KCDATA_ITER_FOREACH(iter) for(; kcdata_iter_valid(iter) && iter.item->type != KCDATA_TYPE_BUFFER_END; iter = kcdata_iter_next(iter))

macroKCDATA_ITER_FOREACH_FAILED

#define KCDATA_ITER_FOREACH_FAILED(iter) (!kcdata_iter_valid(iter) || (iter).item->type != KCDATA_TYPE_BUFFER_END)

functionkcdata_iter_find_type

static inline kcdata_iter_t kcdata_iter_find_type(kcdata_iter_t iter, uint32_t type)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Scans forward from the iterator's current position and returns an iterator positioned at the first item whose type matches type. Returns an invalid iterator if no match is found before KCDATA_TYPE_BUFFER_END or the end of the buffer.

functionkcdata_iter_data_with_desc_valid

static inline int kcdata_iter_data_with_desc_valid(kcdata_iter_t iter, uint32_t minsize)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns nonzero if the current item is a valid description-tagged item (KCDATA_TYPE_STRING_DESC, KCDATA_TYPE_UINT64_DESC, KCDATA_TYPE_BINDATA_DESC, ...): its payload holds at least KCDATA_DESC_MAXLEN (32) bytes of NUL-terminated description followed by at least minsize bytes of data.

functionkcdata_iter_string

static inline char * kcdata_iter_string(kcdata_iter_t iter, uint32_t offset)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
Returns a pointer to the NUL-terminated string beginning at offset within the current item's payload, or NULL if offset is beyond the item or the string is not terminated within the item's bounds.

functionkcdata_iter_get_data_with_desc

static inline void kcdata_iter_get_data_with_desc(
	kcdata_iter_t iter,
	char **desc_ptr,
	void **data_ptr,
	uint32_t *size_ptr
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kcdata.h
For a description-tagged item, returns through the non-NULL out parameters the description string (the first KCDATA_DESC_MAXLEN bytes of the payload), a pointer to the data that follows it, and the size of that data. Validate the item with kcdata_iter_data_with_desc_valid first; any of desc_ptr, data_ptr, and size_ptr may be NULL.