]> git.saurik.com Git - apple/xnu.git/blobdiff - libkdd/kcdata.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / libkdd / kcdata.h
index 85cf4998b3792d85ce01eeec8b4f5cb953144e27..d57bd0c27ef979ff79b0014f49f8d6993e024da1 100644 (file)
  * 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 amunt 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 clsoe 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.
+ *
+ * Once you are done with the kcdata buffer, call kcdata_deinit_compress to
+ * free any buffers that may have been allocated internal to the compression
+ * algorithm.
  */
 
 
@@ -401,6 +447,7 @@ struct kcdata_type_definition {
 #define KCDATA_TYPE_PID 0x36u                /* int32_t */
 #define KCDATA_TYPE_PROCNAME 0x37u           /* char * */
 #define KCDATA_TYPE_NESTED_KCDATA 0x38u      /* nested kcdata buffer */
+#define KCDATA_TYPE_LIBRARY_AOTINFO 0x39u    /* struct user64_dyld_aot_info */
 
 #define KCDATA_TYPE_BUFFER_END 0xF19158EDu
 
@@ -410,16 +457,18 @@ struct kcdata_type_definition {
  * numbers are byteswaps of each other
  */
 
-#define KCDATA_BUFFER_BEGIN_CRASHINFO 0xDEADF157u       /* owner: corpses/task_corpse.h */
-                                                        /* type-range: 0x800 - 0x8ff */
-#define KCDATA_BUFFER_BEGIN_STACKSHOT 0x59a25807u       /* owner: sys/stackshot.h */
-                                                        /* type-range: 0x900 - 0x93f */
-#define KCDATA_BUFFER_BEGIN_DELTA_STACKSHOT 0xDE17A59Au /* owner: sys/stackshot.h */
-                                                        /* type-range: 0x940 - 0x9ff */
-#define KCDATA_BUFFER_BEGIN_OS_REASON 0x53A20900u       /* owner: sys/reason.h */
-                                                        /* type-range: 0x1000-0x103f */
-#define KCDATA_BUFFER_BEGIN_XNUPOST_CONFIG 0x1e21c09fu  /* owner: osfmk/tests/kernel_tests.c */
-                                                        /* type-range: 0x1040-0x105f */
+#define KCDATA_BUFFER_BEGIN_CRASHINFO 0xDEADF157u            /* owner: corpses/task_corpse.h */
+                                                             /* type-range: 0x800 - 0x8ff */
+#define KCDATA_BUFFER_BEGIN_STACKSHOT 0x59a25807u            /* owner: sys/stackshot.h */
+                                                             /* type-range: 0x900 - 0x93f */
+#define KCDATA_BUFFER_BEGIN_COMPRESSED 0x434f4d50u           /* owner: sys/stackshot.h */
+                                                             /* type-range: 0x900 - 0x93f */
+#define KCDATA_BUFFER_BEGIN_DELTA_STACKSHOT 0xDE17A59Au      /* owner: sys/stackshot.h */
+                                                             /* type-range: 0x940 - 0x9ff */
+#define KCDATA_BUFFER_BEGIN_OS_REASON 0x53A20900u            /* owner: sys/reason.h */
+                                                             /* type-range: 0x1000-0x103f */
+#define KCDATA_BUFFER_BEGIN_XNUPOST_CONFIG 0x1e21c09fu       /* owner: osfmk/tests/kernel_tests.c */
+                                                             /* type-range: 0x1040-0x105f */
 
 /* next type range number available 0x1060 */
 /**************** definitions for XNUPOST *********************/
@@ -436,45 +485,53 @@ struct kcdata_type_definition {
  * NOTE: Please update kcdata/libkdd/kcdtypes.c if you make any changes
  * in STACKSHOT_KCTYPE_* types.
  */
-#define STACKSHOT_KCTYPE_IOSTATS 0x901u                   /* io_stats_snapshot */
-#define STACKSHOT_KCTYPE_GLOBAL_MEM_STATS 0x902u          /* struct mem_and_io_snapshot */
-#define STACKSHOT_KCCONTAINER_TASK 0x903u
-#define STACKSHOT_KCCONTAINER_THREAD 0x904u
-#define STACKSHOT_KCTYPE_TASK_SNAPSHOT 0x905u             /* task_snapshot_v2 */
-#define STACKSHOT_KCTYPE_THREAD_SNAPSHOT 0x906u           /* thread_snapshot_v2, thread_snapshot_v3 */
-#define STACKSHOT_KCTYPE_DONATING_PIDS 0x907u             /* int[] */
-#define STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO 0x908u      /* same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
-#define STACKSHOT_KCTYPE_THREAD_NAME 0x909u               /* char[] */
-#define STACKSHOT_KCTYPE_KERN_STACKFRAME 0x90Au           /* struct stack_snapshot_frame32 */
-#define STACKSHOT_KCTYPE_KERN_STACKFRAME64 0x90Bu         /* struct stack_snapshot_frame64 */
-#define STACKSHOT_KCTYPE_USER_STACKFRAME 0x90Cu           /* struct stack_snapshot_frame32 */
-#define STACKSHOT_KCTYPE_USER_STACKFRAME64 0x90Du         /* struct stack_snapshot_frame64 */
-#define STACKSHOT_KCTYPE_BOOTARGS 0x90Eu                  /* boot args string */
-#define STACKSHOT_KCTYPE_OSVERSION 0x90Fu                 /* os version string */
-#define STACKSHOT_KCTYPE_KERN_PAGE_SIZE 0x910u            /* kernel page size in uint32_t */
-#define STACKSHOT_KCTYPE_JETSAM_LEVEL 0x911u              /* jetsam level in uint32_t */
-#define STACKSHOT_KCTYPE_DELTA_SINCE_TIMESTAMP 0x912u     /* timestamp used for the delta stackshot */
-#define STACKSHOT_KCTYPE_KERN_STACKLR 0x913u              /* uint32_t */
-#define STACKSHOT_KCTYPE_KERN_STACKLR64 0x914u            /* uint64_t */
-#define STACKSHOT_KCTYPE_USER_STACKLR 0x915u              /* uint32_t */
-#define STACKSHOT_KCTYPE_USER_STACKLR64 0x916u            /* uint64_t */
-#define STACKSHOT_KCTYPE_NONRUNNABLE_TIDS 0x917u          /* uint64_t */
-#define STACKSHOT_KCTYPE_NONRUNNABLE_TASKS 0x918u         /* uint64_t */
-#define STACKSHOT_KCTYPE_CPU_TIMES 0x919u                 /* struct stackshot_cpu_times or stackshot_cpu_times_v2 */
-#define STACKSHOT_KCTYPE_STACKSHOT_DURATION 0x91au        /* struct stackshot_duration */
-#define STACKSHOT_KCTYPE_STACKSHOT_FAULT_STATS 0x91bu     /* struct stackshot_fault_stats */
-#define STACKSHOT_KCTYPE_KERNELCACHE_LOADINFO  0x91cu     /* kernelcache UUID -- same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
-#define STACKSHOT_KCTYPE_THREAD_WAITINFO 0x91du           /* struct stackshot_thread_waitinfo */
-#define STACKSHOT_KCTYPE_THREAD_GROUP_SNAPSHOT 0x91eu     /* struct thread_group_snapshot or thread_group_snapshot_v2 */
-#define STACKSHOT_KCTYPE_THREAD_GROUP 0x91fu              /* uint64_t */
-#define STACKSHOT_KCTYPE_JETSAM_COALITION_SNAPSHOT 0x920u /* struct jetsam_coalition_snapshot */
-#define STACKSHOT_KCTYPE_JETSAM_COALITION 0x921u          /* uint64_t */
-#define STACKSHOT_KCTYPE_THREAD_POLICY_VERSION 0x922u     /* THREAD_POLICY_INTERNAL_STRUCT_VERSION in uint32 */
-#define STACKSHOT_KCTYPE_INSTRS_CYCLES 0x923u             /* struct instrs_cycles_snapshot */
-#define STACKSHOT_KCTYPE_USER_STACKTOP 0x924u             /* struct stack_snapshot_stacktop */
-#define STACKSHOT_KCTYPE_ASID 0x925u                      /* uint32_t */
-#define STACKSHOT_KCTYPE_PAGE_TABLES 0x926u               /* uint64_t */
-#define STACKSHOT_KCTYPE_SYS_SHAREDCACHE_LAYOUT 0x927u    /* same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
+#define STACKSHOT_KCTYPE_IOSTATS                     0x901u /* io_stats_snapshot */
+#define STACKSHOT_KCTYPE_GLOBAL_MEM_STATS            0x902u /* struct mem_and_io_snapshot */
+#define STACKSHOT_KCCONTAINER_TASK                   0x903u
+#define STACKSHOT_KCCONTAINER_THREAD                 0x904u
+#define STACKSHOT_KCTYPE_TASK_SNAPSHOT               0x905u /* task_snapshot_v2 */
+#define STACKSHOT_KCTYPE_THREAD_SNAPSHOT             0x906u /* thread_snapshot_v2, thread_snapshot_v3 */
+#define STACKSHOT_KCTYPE_DONATING_PIDS               0x907u /* int[] */
+#define STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO        0x908u /* dyld_shared_cache_loadinfo */
+#define STACKSHOT_KCTYPE_THREAD_NAME                 0x909u /* char[] */
+#define STACKSHOT_KCTYPE_KERN_STACKFRAME             0x90Au /* struct stack_snapshot_frame32 */
+#define STACKSHOT_KCTYPE_KERN_STACKFRAME64           0x90Bu /* struct stack_snapshot_frame64 */
+#define STACKSHOT_KCTYPE_USER_STACKFRAME             0x90Cu /* struct stack_snapshot_frame32 */
+#define STACKSHOT_KCTYPE_USER_STACKFRAME64           0x90Du /* struct stack_snapshot_frame64 */
+#define STACKSHOT_KCTYPE_BOOTARGS                    0x90Eu /* boot args string */
+#define STACKSHOT_KCTYPE_OSVERSION                   0x90Fu /* os version string */
+#define STACKSHOT_KCTYPE_KERN_PAGE_SIZE              0x910u /* kernel page size in uint32_t */
+#define STACKSHOT_KCTYPE_JETSAM_LEVEL                0x911u /* jetsam level in uint32_t */
+#define STACKSHOT_KCTYPE_DELTA_SINCE_TIMESTAMP       0x912u /* timestamp used for the delta stackshot */
+#define STACKSHOT_KCTYPE_KERN_STACKLR                0x913u /* uint32_t */
+#define STACKSHOT_KCTYPE_KERN_STACKLR64              0x914u /* uint64_t */
+#define STACKSHOT_KCTYPE_USER_STACKLR                0x915u /* uint32_t */
+#define STACKSHOT_KCTYPE_USER_STACKLR64              0x916u /* uint64_t */
+#define STACKSHOT_KCTYPE_NONRUNNABLE_TIDS            0x917u /* uint64_t */
+#define STACKSHOT_KCTYPE_NONRUNNABLE_TASKS           0x918u /* uint64_t */
+#define STACKSHOT_KCTYPE_CPU_TIMES                   0x919u /* struct stackshot_cpu_times or stackshot_cpu_times_v2 */
+#define STACKSHOT_KCTYPE_STACKSHOT_DURATION          0x91au /* struct stackshot_duration */
+#define STACKSHOT_KCTYPE_STACKSHOT_FAULT_STATS       0x91bu /* struct stackshot_fault_stats */
+#define STACKSHOT_KCTYPE_KERNELCACHE_LOADINFO        0x91cu /* kernelcache UUID -- same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
+#define STACKSHOT_KCTYPE_THREAD_WAITINFO             0x91du /* struct stackshot_thread_waitinfo */
+#define STACKSHOT_KCTYPE_THREAD_GROUP_SNAPSHOT       0x91eu /* struct thread_group_snapshot or thread_group_snapshot_v2 */
+#define STACKSHOT_KCTYPE_THREAD_GROUP                0x91fu /* uint64_t */
+#define STACKSHOT_KCTYPE_JETSAM_COALITION_SNAPSHOT   0x920u /* struct jetsam_coalition_snapshot */
+#define STACKSHOT_KCTYPE_JETSAM_COALITION            0x921u /* uint64_t */
+#define STACKSHOT_KCTYPE_THREAD_POLICY_VERSION       0x922u /* THREAD_POLICY_INTERNAL_STRUCT_VERSION in uint32 */
+#define STACKSHOT_KCTYPE_INSTRS_CYCLES               0x923u /* struct instrs_cycles_snapshot */
+#define STACKSHOT_KCTYPE_USER_STACKTOP               0x924u /* struct stack_snapshot_stacktop */
+#define STACKSHOT_KCTYPE_ASID                        0x925u /* uint32_t */
+#define STACKSHOT_KCTYPE_PAGE_TABLES                 0x926u /* uint64_t */
+#define STACKSHOT_KCTYPE_SYS_SHAREDCACHE_LAYOUT      0x927u /* same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
+#define STACKSHOT_KCTYPE_THREAD_DISPATCH_QUEUE_LABEL 0x928u /* dispatch queue label */
+#define STACKSHOT_KCTYPE_THREAD_TURNSTILEINFO        0x929u /* struct stackshot_thread_turnstileinfo */
+#define STACKSHOT_KCTYPE_TASK_CPU_ARCHITECTURE       0x92au /* struct stackshot_cpu_architecture */
+#define STACKSHOT_KCTYPE_LATENCY_INFO                0x92bu /* struct stackshot_latency_collection */
+#define STACKSHOT_KCTYPE_LATENCY_INFO_TASK           0x92cu /* struct stackshot_latency_task */
+#define STACKSHOT_KCTYPE_LATENCY_INFO_THREAD         0x92du /* struct stackshot_latency_thread */
+#define STACKSHOT_KCTYPE_LOADINFO64_TEXT_EXEC        0x92eu /* TEXT_EXEC load info -- same as KCDATA_TYPE_LIBRARY_LOADINFO64 */
+#define STACKSHOT_KCTYPE_AOTCACHE_LOADINFO           0x92fu /* struct dyld_aot_cache_uuid_info */
 
 #define STACKSHOT_KCTYPE_TASK_DELTA_SNAPSHOT 0x940u   /* task_delta_snapshot_v2 */
 #define STACKSHOT_KCTYPE_THREAD_DELTA_SNAPSHOT 0x941u /* thread_delta_snapshot_v* */
@@ -499,11 +556,43 @@ struct dyld_uuid_info_64 {
        uuid_t   imageUUID;
 };
 
+/*
+ * N.B.: Newer kernels output dyld_shared_cache_loadinfo structures
+ * instead of this, since the field names match their contents better.
+ */
 struct dyld_uuid_info_64_v2 {
        uint64_t imageLoadAddress; /* XXX image slide */
        uuid_t   imageUUID;
        /* end of version 1 of dyld_uuid_info_64. sizeof v1 was 24 */
-       uint64_t imageSlidBaseAddress; /* slid base address of image */
+       uint64_t imageSlidBaseAddress; /* slid base address or slid first mapping of image */
+};
+
+/*
+ * 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
+ */
+struct dyld_shared_cache_loadinfo {
+       uint64_t sharedCacheSlide;      /* image slide value */
+       uuid_t   sharedCacheUUID;
+       /* end of version 1 of dyld_uuid_info_64. sizeof v1 was 24 */
+       uint64_t sharedCacheUnreliableSlidBaseAddress;  /* for backwards-compatibility; use sharedCacheSlidFirstMapping if available */
+       /* end of version 2 of dyld_uuid_info_64. sizeof v2 was 32 */
+       uint64_t sharedCacheSlidFirstMapping; /* slid base address of first mapping */
+};
+
+struct dyld_aot_cache_uuid_info {
+       uint64_t x86SlidBaseAddress; /* slid first mapping address of x86 shared cache */
+       uuid_t x86UUID; /* UUID of x86 shared cache */
+       uint64_t aotSlidBaseAddress; /* slide first mapping address of aot cache */
+       uuid_t aotUUID; /* UUID of aot shared cache */
 };
 
 struct user32_dyld_uuid_info {
@@ -516,7 +605,17 @@ struct user64_dyld_uuid_info {
        uuid_t                  imageUUID;                      /* UUID of image */
 };
 
+#define DYLD_AOT_IMAGE_KEY_SIZE 32
+
+struct user64_dyld_aot_info {
+       uint64_t x86LoadAddress;
+       uint64_t aotLoadAddress;
+       uint64_t aotImageSize;
+       uint8_t  aotImageKey[DYLD_AOT_IMAGE_KEY_SIZE];
+};
+
 enum task_snapshot_flags {
+       /* k{User,Kernel}64_p (values 0x1 and 0x2) are defined in generic_snapshot_flags */
        kTaskRsrcFlagged                      = 0x4, // In the EXC_RESOURCE danger zone?
        kTerminatedSnapshot                   = 0x8,
        kPidSuspended                         = 0x10, // true for suspended task
@@ -543,9 +642,14 @@ enum task_snapshot_flags {
        /* 0x2000000 unused */
        kTaskIsDirtyTracked                   = 0x4000000,
        kTaskAllowIdleExit                    = 0x8000000,
+       kTaskIsTranslated                     = 0x10000000,
+       kTaskSharedRegionNone                 = 0x20000000,     /* task doesn't have a shared region */
+       kTaskSharedRegionSystem               = 0x40000000,     /* task is attached to system shared region */
+       kTaskSharedRegionOther                = 0x80000000,     /* task is attached to a different shared region */
 };
 
 enum thread_snapshot_flags {
+       /* k{User,Kernel}64_p (values 0x1 and 0x2) are defined in generic_snapshot_flags */
        kHasDispatchSerial    = 0x4,
        kStacksPCOnly         = 0x8,    /* Stack traces have no frame pointers. */
        kThreadDarwinBG       = 0x10,   /* Thread is darwinbg */
@@ -800,6 +904,12 @@ struct stackshot_duration {
        uint64_t stackshot_duration_outer;
 } __attribute__((packed));
 
+struct stackshot_duration_v2 {
+       uint64_t stackshot_duration;
+       uint64_t stackshot_duration_outer;
+       uint64_t stackshot_duration_prior;
+} __attribute__((packed));
+
 struct stackshot_fault_stats {
        uint32_t sfs_pages_faulted_in;      /* number of pages faulted in using KDP fault path */
        uint64_t sfs_time_spent_faulting;   /* MATUs spent faulting */
@@ -814,6 +924,20 @@ typedef struct stackshot_thread_waitinfo {
        uint8_t wait_type;      /* The type of object that the thread is waiting on */
 } __attribute__((packed)) thread_waitinfo_t;
 
+typedef struct stackshot_thread_turnstileinfo {
+       uint64_t waiter;        /* The thread that's waiting on the object */
+       uint64_t turnstile_context; /* Associated data (either thread id, or workq addr) */
+       uint8_t turnstile_priority;
+       uint8_t number_of_hops;
+#define STACKSHOT_TURNSTILE_STATUS_UNKNOWN         0x01   /* The final inheritor is unknown (bug?) */
+#define STACKSHOT_TURNSTILE_STATUS_LOCKED_WAITQ    0x02   /* A waitq was found to be locked */
+#define STACKSHOT_TURNSTILE_STATUS_WORKQUEUE       0x04   /* The final inheritor is a workqueue */
+#define STACKSHOT_TURNSTILE_STATUS_THREAD          0x08   /* The final inheritor is a thread */
+#define STACKSHOT_TURNSTILE_STATUS_BLOCKED_ON_TASK 0x10   /* blocked on task, dind't find thread */
+#define STACKSHOT_TURNSTILE_STATUS_HELD_IPLOCK     0x20   /* the ip_lock was held */
+       uint64_t turnstile_flags;
+} __attribute__((packed)) thread_turnstileinfo_t;
+
 #define STACKSHOT_WAITOWNER_KERNEL         (UINT64_MAX - 1)
 #define STACKSHOT_WAITOWNER_PORT_LOCKED    (UINT64_MAX - 2)
 #define STACKSHOT_WAITOWNER_PSET_LOCKED    (UINT64_MAX - 3)
@@ -822,12 +946,52 @@ typedef struct stackshot_thread_waitinfo {
 #define STACKSHOT_WAITOWNER_THREQUESTED    (UINT64_MAX - 6) /* workloop waiting for a new worker thread */
 #define STACKSHOT_WAITOWNER_SUSPENDED      (UINT64_MAX - 7) /* workloop is suspended */
 
+struct stackshot_cpu_architecture {
+       int32_t cputype;
+       int32_t cpusubtype;
+} __attribute__((packed));
 
 struct stack_snapshot_stacktop {
        uint64_t sp;
        uint8_t stack_contents[8];
 };
 
+/* only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0 */
+struct stackshot_latency_collection {
+       uint64_t latency_version;
+       uint64_t setup_latency;
+       uint64_t total_task_iteration_latency;
+       uint64_t total_terminated_task_iteration_latency;
+} __attribute__((packed));
+
+/* only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0 */
+struct stackshot_latency_task {
+       uint64_t task_uniqueid;
+       uint64_t setup_latency;
+       uint64_t task_thread_count_loop_latency;
+       uint64_t task_thread_data_loop_latency;
+       uint64_t cur_tsnap_latency;
+       uint64_t pmap_latency;
+       uint64_t bsd_proc_ids_latency;
+       uint64_t misc_latency;
+       uint64_t misc2_latency;
+       uint64_t end_latency;
+} __attribute__((packed));
+
+/* only collected if STACKSHOT_COLLECTS_LATENCY_INFO is set to !0 */
+struct stackshot_latency_thread {
+       uint64_t thread_id;
+       uint64_t cur_thsnap1_latency;
+       uint64_t dispatch_serial_latency;
+       uint64_t dispatch_label_latency;
+       uint64_t cur_thsnap2_latency;
+       uint64_t thread_name_latency;
+       uint64_t sur_times_latency;
+       uint64_t user_stack_latency;
+       uint64_t kernel_stack_latency;
+       uint64_t misc_latency;
+} __attribute__((packed));
+
 
 /**************** definitions for crashinfo *********************/
 
@@ -895,8 +1059,17 @@ struct crashinfo_proc_uniqidentifierinfo {
 #define TASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE               0x828 /* uint64_t */
 #define TASK_CRASHINFO_LEDGER_NETWORK_NONVOLATILE_COMPRESSED    0x829 /* uint64_t */
 #define TASK_CRASHINFO_LEDGER_WIRED_MEM                         0x82A /* uint64_t */
-
-
+#define TASK_CRASHINFO_PROC_PERSONA_ID                          0x82B /* uid_t */
+#define TASK_CRASHINFO_MEMORY_LIMIT_INCREASE                    0x82C /* uint32_t */
+#define TASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT                  0x82D /* uint64_t */
+#define TASK_CRASHINFO_LEDGER_TAGGED_FOOTPRINT_COMPRESSED       0x82E /* uint64_t */
+#define TASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT                   0x82F /* uint64_t */
+#define TASK_CRASHINFO_LEDGER_MEDIA_FOOTPRINT_COMPRESSED        0x830 /* uint64_t */
+#define TASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT                0x831 /* uint64_t */
+#define TASK_CRASHINFO_LEDGER_GRAPHICS_FOOTPRINT_COMPRESSED     0x832 /* uint64_t */
+#define TASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT                  0x833 /* uint64_t */
+#define TASK_CRASHINFO_LEDGER_NEURAL_FOOTPRINT_COMPRESSED       0x834 /* uint64_t */
+#define TASK_CRASHINFO_MEMORYSTATUS_EFFECTIVE_PRIORITY          0x835 /* int32_t */
 
 #define TASK_CRASHINFO_END                  KCDATA_TYPE_BUFFER_END
 
@@ -971,7 +1144,7 @@ kcdata_iter_unsafe(void *buffer)
        return iter;
 }
 
-static const kcdata_iter_t kcdata_invalid_iter = { .item = 0, .end = 0 };
+static const kcdata_iter_t kcdata_invalid_iter = { .item = NULL, .end = NULL };
 
 static inline
 int