1*1b191cb5SApple OSS Distributions /*
2*1b191cb5SApple OSS Distributions * Copyright (c) 2015 Apple Inc. All rights reserved.
3*1b191cb5SApple OSS Distributions *
4*1b191cb5SApple OSS Distributions * @APPLE_LICENSE_HEADER_START@
5*1b191cb5SApple OSS Distributions *
6*1b191cb5SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*1b191cb5SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*1b191cb5SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*1b191cb5SApple OSS Distributions * compliance with the License. Please obtain a copy of the License at
10*1b191cb5SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this
11*1b191cb5SApple OSS Distributions * file.
12*1b191cb5SApple OSS Distributions *
13*1b191cb5SApple OSS Distributions * The Original Code and all software distributed under the License are
14*1b191cb5SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15*1b191cb5SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16*1b191cb5SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17*1b191cb5SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18*1b191cb5SApple OSS Distributions * Please see the License for the specific language governing rights and
19*1b191cb5SApple OSS Distributions * limitations under the License.
20*1b191cb5SApple OSS Distributions *
21*1b191cb5SApple OSS Distributions * @APPLE_LICENSE_HEADER_END@
22*1b191cb5SApple OSS Distributions */
23*1b191cb5SApple OSS Distributions
24*1b191cb5SApple OSS Distributions #include <kcdata.h>
25*1b191cb5SApple OSS Distributions #include <sys/time.h>
26*1b191cb5SApple OSS Distributions #include <stdlib.h>
27*1b191cb5SApple OSS Distributions #include <stddef.h>
28*1b191cb5SApple OSS Distributions #include <string.h>
29*1b191cb5SApple OSS Distributions #include <assert.h>
30*1b191cb5SApple OSS Distributions #include <stdio.h>
31*1b191cb5SApple OSS Distributions #include <mach/mach_time.h>
32*1b191cb5SApple OSS Distributions #include <assert.h>
33*1b191cb5SApple OSS Distributions
34*1b191cb5SApple OSS Distributions /*!
35*1b191cb5SApple OSS Distributions * @function kcdata_get_typedescription
36*1b191cb5SApple OSS Distributions *
37*1b191cb5SApple OSS Distributions * @abstract
38*1b191cb5SApple OSS Distributions * Search the known type definitions for type with id type_id.
39*1b191cb5SApple OSS Distributions *
40*1b191cb5SApple OSS Distributions * @param type_id
41*1b191cb5SApple OSS Distributions * A unsinged int type specified by the KCDATA.
42*1b191cb5SApple OSS Distributions *
43*1b191cb5SApple OSS Distributions * @param buffer
44*1b191cb5SApple OSS Distributions * pointer to data area where type definition will be saved.
45*1b191cb5SApple OSS Distributions *
46*1b191cb5SApple OSS Distributions * @param buffer_size
47*1b191cb5SApple OSS Distributions * size of the buffer provided.
48*1b191cb5SApple OSS Distributions *
49*1b191cb5SApple OSS Distributions * @return struct kcdata_type_definition *
50*1b191cb5SApple OSS Distributions * pointer to a malloc'ed buffer holding the type definition and each subtype defintion for its fields.
51*1b191cb5SApple OSS Distributions * It may return NULL if no type with id == type_id is found.
52*1b191cb5SApple OSS Distributions * Note: The caller is responsible to free() the memory when its no longer used.
53*1b191cb5SApple OSS Distributions *
54*1b191cb5SApple OSS Distributions * @discussion
55*1b191cb5SApple OSS Distributions * This function queries the known type definitions table. If found the defintion data is returned
56*1b191cb5SApple OSS Distributions * else NULL is returned. It is advised to cache the return value from this function since the data
57*1b191cb5SApple OSS Distributions * is always going to be the same for same type_id. The definition setup requires memory on heap.
58*1b191cb5SApple OSS Distributions * The caller should make sure to free() the data once its done with using it.
59*1b191cb5SApple OSS Distributions *
60*1b191cb5SApple OSS Distributions */
61*1b191cb5SApple OSS Distributions struct kcdata_type_definition * kcdata_get_typedescription(unsigned type_id, uint8_t * buffer, uint32_t buffer_size);
62*1b191cb5SApple OSS Distributions
63*1b191cb5SApple OSS Distributions /* forward declarations for helper routines */
64*1b191cb5SApple OSS Distributions static uint32_t get_kctype_subtype_size(kctype_subtype_t type);
65*1b191cb5SApple OSS Distributions static void setup_subtype_description(kcdata_subtype_descriptor_t desc, kctype_subtype_t type, uint32_t offset, char * name);
66*1b191cb5SApple OSS Distributions static void setup_subtype_array_description(
67*1b191cb5SApple OSS Distributions kcdata_subtype_descriptor_t desc, kctype_subtype_t type, uint32_t offset, uint32_t count, char * name);
68*1b191cb5SApple OSS Distributions static void setup_type_definition(struct kcdata_type_definition * d, uint32_t type, uint32_t num_elems, char * name);
69*1b191cb5SApple OSS Distributions
70*1b191cb5SApple OSS Distributions struct kcdata_type_definition *
kcdata_get_typedescription(unsigned type_id,uint8_t * buffer,uint32_t buffer_size)71*1b191cb5SApple OSS Distributions kcdata_get_typedescription(unsigned type_id, uint8_t * buffer, uint32_t buffer_size)
72*1b191cb5SApple OSS Distributions {
73*1b191cb5SApple OSS Distributions unsigned int i = 0;
74*1b191cb5SApple OSS Distributions #define _STR_VALUE(x) #x
75*1b191cb5SApple OSS Distributions #define _SUBTYPE_TRUNC(t, s, f, name) do { \
76*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], (t), offsetof(s, f), name); \
77*1b191cb5SApple OSS Distributions _Static_assert(sizeof(name) == sizeof ((struct kcdata_subtype_descriptor *)0)->kcs_name, "\"" name "\" should fit exactly in kcs_name"); \
78*1b191cb5SApple OSS Distributions } while (0)
79*1b191cb5SApple OSS Distributions #define _SUBTYPE(t, s, f) do { \
80*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], (t), offsetof(s, f), _STR_VALUE(f)); \
81*1b191cb5SApple OSS Distributions _Static_assert(sizeof(_STR_VALUE(f)) <= sizeof ((struct kcdata_subtype_descriptor *)0)->kcs_name, "\"" _STR_VALUE(f) "\" should fit in kcs_name"); \
82*1b191cb5SApple OSS Distributions } while (0)
83*1b191cb5SApple OSS Distributions
84*1b191cb5SApple OSS Distributions #define _SUBTYPE_ARRAY(t, s, f, c) setup_subtype_array_description(&subtypes[i++], (t), offsetof(s, f), (c), _STR_VALUE(f))
85*1b191cb5SApple OSS Distributions #define _STRINGTYPE(f) setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, UINT16_MAX, f)
86*1b191cb5SApple OSS Distributions
87*1b191cb5SApple OSS Distributions if (buffer_size < sizeof(struct kcdata_type_definition) || buffer == NULL) {
88*1b191cb5SApple OSS Distributions return NULL;
89*1b191cb5SApple OSS Distributions }
90*1b191cb5SApple OSS Distributions
91*1b191cb5SApple OSS Distributions struct kcdata_type_definition * retval = (struct kcdata_type_definition *)&buffer[0];
92*1b191cb5SApple OSS Distributions kcdata_subtype_descriptor_t subtypes = (kcdata_subtype_descriptor_t)&buffer[sizeof(struct kcdata_type_definition)];
93*1b191cb5SApple OSS Distributions switch (type_id) {
94*1b191cb5SApple OSS Distributions case KCDATA_TYPE_STRING_DESC: {
95*1b191cb5SApple OSS Distributions i = 0;
96*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, KCDATA_DESC_MAXLEN, "desc");
97*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, KCDATA_DESC_MAXLEN, UINT16_MAX, "data");
98*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "string_desc");
99*1b191cb5SApple OSS Distributions break;
100*1b191cb5SApple OSS Distributions }
101*1b191cb5SApple OSS Distributions
102*1b191cb5SApple OSS Distributions case KCDATA_TYPE_UINT32_DESC: {
103*1b191cb5SApple OSS Distributions i = 0;
104*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, KCDATA_DESC_MAXLEN, "desc");
105*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, KCDATA_DESC_MAXLEN, "data");
106*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "uint32_desc");
107*1b191cb5SApple OSS Distributions break;
108*1b191cb5SApple OSS Distributions }
109*1b191cb5SApple OSS Distributions
110*1b191cb5SApple OSS Distributions case KCDATA_TYPE_UINT64_DESC: {
111*1b191cb5SApple OSS Distributions i = 0;
112*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, KCDATA_DESC_MAXLEN, "desc");
113*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT64, KCDATA_DESC_MAXLEN, "data");
114*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "uint64_desc");
115*1b191cb5SApple OSS Distributions break;
116*1b191cb5SApple OSS Distributions }
117*1b191cb5SApple OSS Distributions
118*1b191cb5SApple OSS Distributions case KCDATA_TYPE_INT32_DESC: {
119*1b191cb5SApple OSS Distributions i = 0;
120*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, KCDATA_DESC_MAXLEN, "desc");
121*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_INT32, KCDATA_DESC_MAXLEN, "data");
122*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "int32_desc");
123*1b191cb5SApple OSS Distributions break;
124*1b191cb5SApple OSS Distributions }
125*1b191cb5SApple OSS Distributions
126*1b191cb5SApple OSS Distributions case KCDATA_TYPE_INT64_DESC: {
127*1b191cb5SApple OSS Distributions i = 0;
128*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, KCDATA_DESC_MAXLEN, "desc");
129*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_INT64, KCDATA_DESC_MAXLEN, "data");
130*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "int64_desc");
131*1b191cb5SApple OSS Distributions break;
132*1b191cb5SApple OSS Distributions }
133*1b191cb5SApple OSS Distributions
134*1b191cb5SApple OSS Distributions case KCDATA_TYPE_TYPEDEFINTION: {
135*1b191cb5SApple OSS Distributions i = 0;
136*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, offsetof(struct kcdata_type_definition, kct_type_identifier), "typeID");
137*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, offsetof(struct kcdata_type_definition, kct_num_elements), "numOfFields");
138*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, offsetof(struct kcdata_type_definition, kct_name), KCDATA_DESC_MAXLEN, "name");
139*1b191cb5SApple OSS Distributions // Note "fields" is an array of run time defined length. So we populate fields at parsing time.
140*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "typedef");
141*1b191cb5SApple OSS Distributions break;
142*1b191cb5SApple OSS Distributions }
143*1b191cb5SApple OSS Distributions
144*1b191cb5SApple OSS Distributions case KCDATA_TYPE_CONTAINER_BEGIN: {
145*1b191cb5SApple OSS Distributions i = 0;
146*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, 0, "kcContainerType");
147*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "container_begin");
148*1b191cb5SApple OSS Distributions break;
149*1b191cb5SApple OSS Distributions }
150*1b191cb5SApple OSS Distributions
151*1b191cb5SApple OSS Distributions case KCDATA_TYPE_LIBRARY_LOADINFO: {
152*1b191cb5SApple OSS Distributions i = 0;
153*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct user32_dyld_uuid_info, imageLoadAddress);
154*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct user32_dyld_uuid_info, imageUUID, 16);
155*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "dyld_load_info");
156*1b191cb5SApple OSS Distributions break;
157*1b191cb5SApple OSS Distributions }
158*1b191cb5SApple OSS Distributions
159*1b191cb5SApple OSS Distributions case KCDATA_TYPE_LIBRARY_LOADINFO64: {
160*1b191cb5SApple OSS Distributions i = 0;
161*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct user64_dyld_uuid_info, imageLoadAddress);
162*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct user64_dyld_uuid_info, imageUUID, 16);
163*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "dyld_load_info");
164*1b191cb5SApple OSS Distributions break;
165*1b191cb5SApple OSS Distributions }
166*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_LOADINFO64_TEXT_EXEC: {
167*1b191cb5SApple OSS Distributions i = 0;
168*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct user64_dyld_uuid_info, imageLoadAddress);
169*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct user64_dyld_uuid_info, imageUUID, 16);
170*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "dyld_load_info_text_exec");
171*1b191cb5SApple OSS Distributions break;
172*1b191cb5SApple OSS Distributions }
173*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_SHAREDCACHE_LOADINFO: {
174*1b191cb5SApple OSS Distributions i = 0;
175*1b191cb5SApple OSS Distributions /*
176*1b191cb5SApple OSS Distributions * for backwards compatibility, we keep the old field names, but the
177*1b191cb5SApple OSS Distributions * new data is being put in dyld_shared_cache_loadinfo
178*1b191cb5SApple OSS Distributions */
179*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_uuid_info_64_v2, imageLoadAddress);
180*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct dyld_uuid_info_64_v2, imageUUID, 16);
181*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_uuid_info_64_v2, imageSlidBaseAddress);
182*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_shared_cache_loadinfo, sharedCacheSlidFirstMapping);
183*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct dyld_shared_cache_loadinfo_v2, sharedCacheID);
184*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct dyld_shared_cache_loadinfo_v2, sharedCacheFlags);
185*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "shared_cache_dyld_load_info");
186*1b191cb5SApple OSS Distributions break;
187*1b191cb5SApple OSS Distributions }
188*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_SHAREDCACHE_INFO: {
189*1b191cb5SApple OSS Distributions i = 0;
190*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_shared_cache_loadinfo_v2, sharedCacheSlide);
191*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct dyld_shared_cache_loadinfo_v2, sharedCacheUUID, 16);
192*1b191cb5SApple OSS Distributions _SUBTYPE_TRUNC(KC_ST_UINT64, struct dyld_shared_cache_loadinfo_v2, sharedCacheUnreliableSlidBaseAddress, "sharedCacheUnreliableSlidBaseAd");
193*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_shared_cache_loadinfo_v2, sharedCacheSlidFirstMapping);
194*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct dyld_shared_cache_loadinfo_v2, sharedCacheID);
195*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct dyld_shared_cache_loadinfo_v2, sharedCacheFlags);
196*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "shared_cache_dyld_load_info");
197*1b191cb5SApple OSS Distributions break;
198*1b191cb5SApple OSS Distributions }
199*1b191cb5SApple OSS Distributions
200*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_KERNELCACHE_LOADINFO: {
201*1b191cb5SApple OSS Distributions i = 0;
202*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_uuid_info_64, imageLoadAddress);
203*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct dyld_uuid_info_64, imageUUID, 16);
204*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "kernelcache_load_info");
205*1b191cb5SApple OSS Distributions break;
206*1b191cb5SApple OSS Distributions }
207*1b191cb5SApple OSS Distributions
208*1b191cb5SApple OSS Distributions case KCDATA_TYPE_TIMEBASE: {
209*1b191cb5SApple OSS Distributions i = 0;
210*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mach_timebase_info, numer);
211*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mach_timebase_info, denom);
212*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "mach_timebase_info");
213*1b191cb5SApple OSS Distributions break;
214*1b191cb5SApple OSS Distributions }
215*1b191cb5SApple OSS Distributions
216*1b191cb5SApple OSS Distributions case KCDATA_TYPE_MACH_ABSOLUTE_TIME:
217*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "mach_absolute_time");
218*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "mach_absolute_time");
219*1b191cb5SApple OSS Distributions break;
220*1b191cb5SApple OSS Distributions
221*1b191cb5SApple OSS Distributions case KCDATA_TYPE_TIMEVAL: {
222*1b191cb5SApple OSS Distributions i = 0;
223*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT64, struct timeval64, tv_sec);
224*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT64, struct timeval64, tv_usec);
225*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "timeval");
226*1b191cb5SApple OSS Distributions break;
227*1b191cb5SApple OSS Distributions }
228*1b191cb5SApple OSS Distributions
229*1b191cb5SApple OSS Distributions case KCDATA_TYPE_USECS_SINCE_EPOCH:
230*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "usecs_since_epoch");
231*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "usecs_since_epoch");
232*1b191cb5SApple OSS Distributions break;
233*1b191cb5SApple OSS Distributions
234*1b191cb5SApple OSS Distributions case KCDATA_TYPE_PID:
235*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "pid");
236*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "pid");
237*1b191cb5SApple OSS Distributions break;
238*1b191cb5SApple OSS Distributions
239*1b191cb5SApple OSS Distributions case KCDATA_TYPE_PROCNAME:
240*1b191cb5SApple OSS Distributions i = 0;
241*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, 64, "proc_name");
242*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "proc_name");
243*1b191cb5SApple OSS Distributions break;
244*1b191cb5SApple OSS Distributions
245*1b191cb5SApple OSS Distributions case KCDATA_TYPE_LIBRARY_AOTINFO: {
246*1b191cb5SApple OSS Distributions i = 0;
247*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct user64_dyld_aot_info, x86LoadAddress);
248*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct user64_dyld_aot_info, aotLoadAddress);
249*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct user64_dyld_aot_info, aotImageSize);
250*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct user64_dyld_aot_info, aotImageKey, DYLD_AOT_IMAGE_KEY_SIZE);
251*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "dyld_aot_info");
252*1b191cb5SApple OSS Distributions break;
253*1b191cb5SApple OSS Distributions }
254*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_AOTCACHE_LOADINFO: {
255*1b191cb5SApple OSS Distributions i = 0;
256*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_aot_cache_uuid_info, x86SlidBaseAddress);
257*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct dyld_aot_cache_uuid_info, x86UUID, 16);
258*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_aot_cache_uuid_info, aotSlidBaseAddress);
259*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct dyld_aot_cache_uuid_info, aotUUID, 16);
260*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "dyld_aot_cache_uuid_info");
261*1b191cb5SApple OSS Distributions break;
262*1b191cb5SApple OSS Distributions }
263*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_SHAREDCACHE_AOTINFO: {
264*1b191cb5SApple OSS Distributions i = 0;
265*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_aot_cache_uuid_info, x86SlidBaseAddress);
266*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct dyld_aot_cache_uuid_info, x86UUID, 16);
267*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct dyld_aot_cache_uuid_info, aotSlidBaseAddress);
268*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct dyld_aot_cache_uuid_info, aotUUID, 16);
269*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "dyld_aot_cache_uuid_info");
270*1b191cb5SApple OSS Distributions break;
271*1b191cb5SApple OSS Distributions }
272*1b191cb5SApple OSS Distributions
273*1b191cb5SApple OSS Distributions /* stackshot specific types */
274*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_IOSTATS: {
275*1b191cb5SApple OSS Distributions i = 0;
276*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_disk_reads_count);
277*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_disk_reads_size);
278*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_disk_writes_count);
279*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_disk_writes_size);
280*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT64, struct io_stats_snapshot, ss_io_priority_count, STACKSHOT_IO_NUM_PRIORITIES);
281*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT64, struct io_stats_snapshot, ss_io_priority_size, STACKSHOT_IO_NUM_PRIORITIES);
282*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_paging_count);
283*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_paging_size);
284*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_non_paging_count);
285*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_non_paging_size);
286*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_data_count);
287*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_data_size);
288*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_metadata_count);
289*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct io_stats_snapshot, ss_metadata_size);
290*1b191cb5SApple OSS Distributions
291*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "io_statistics");
292*1b191cb5SApple OSS Distributions break;
293*1b191cb5SApple OSS Distributions }
294*1b191cb5SApple OSS Distributions
295*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_GLOBAL_MEM_STATS: {
296*1b191cb5SApple OSS Distributions i = 0;
297*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, snapshot_magic);
298*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, free_pages);
299*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, active_pages);
300*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, inactive_pages);
301*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, purgeable_pages);
302*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, wired_pages);
303*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, speculative_pages);
304*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, throttled_pages);
305*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, filebacked_pages);
306*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, compressions);
307*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, decompressions);
308*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, compressor_size);
309*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, busy_buffer_count);
310*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, pages_wanted);
311*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct mem_and_io_snapshot, pages_reclaimed);
312*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct mem_and_io_snapshot, pages_wanted_reclaimed_valid);
313*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "mem_and_io_snapshot");
314*1b191cb5SApple OSS Distributions break;
315*1b191cb5SApple OSS Distributions }
316*1b191cb5SApple OSS Distributions
317*1b191cb5SApple OSS Distributions case STACKSHOT_KCCONTAINER_SHAREDCACHE:
318*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 0, "shared_caches");
319*1b191cb5SApple OSS Distributions break;
320*1b191cb5SApple OSS Distributions
321*1b191cb5SApple OSS Distributions case STACKSHOT_KCCONTAINER_TASK:
322*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 0, "task_snapshots");
323*1b191cb5SApple OSS Distributions break;
324*1b191cb5SApple OSS Distributions
325*1b191cb5SApple OSS Distributions case STACKSHOT_KCCONTAINER_TRANSITIONING_TASK:
326*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 0, "transitioning_task_snapshots");
327*1b191cb5SApple OSS Distributions break;
328*1b191cb5SApple OSS Distributions
329*1b191cb5SApple OSS Distributions case STACKSHOT_KCCONTAINER_THREAD:
330*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 0, "thread_snapshots");
331*1b191cb5SApple OSS Distributions break;
332*1b191cb5SApple OSS Distributions
333*1b191cb5SApple OSS Distributions case STACKSHOT_KCCONTAINER_PORTLABEL:
334*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 0, "portlabels");
335*1b191cb5SApple OSS Distributions break;
336*1b191cb5SApple OSS Distributions
337*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_TASK_SNAPSHOT: {
338*1b191cb5SApple OSS Distributions i = 0;
339*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_snapshot_v2, ts_unique_pid);
340*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_snapshot_v2, ts_ss_flags);
341*1b191cb5SApple OSS Distributions _SUBTYPE_TRUNC(KC_ST_UINT64, struct task_snapshot_v2, ts_user_time_in_terminated_threads, "ts_user_time_in_terminated_thre");
342*1b191cb5SApple OSS Distributions _SUBTYPE_TRUNC(KC_ST_UINT64, struct task_snapshot_v2, ts_system_time_in_terminated_threads, "ts_system_time_in_terminated_th");
343*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_snapshot_v2, ts_p_start_sec);
344*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_snapshot_v2, ts_task_size);
345*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_snapshot_v2, ts_max_resident_size);
346*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_snapshot_v2, ts_suspend_count);
347*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_snapshot_v2, ts_faults);
348*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_snapshot_v2, ts_pageins);
349*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_snapshot_v2, ts_cow_faults);
350*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_snapshot_v2, ts_was_throttled);
351*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_snapshot_v2, ts_did_throttle);
352*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_snapshot_v2, ts_latency_qos);
353*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT32, struct task_snapshot_v2, ts_pid);
354*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct task_snapshot_v2, ts_p_comm, 32);
355*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "task_snapshot");
356*1b191cb5SApple OSS Distributions break;
357*1b191cb5SApple OSS Distributions }
358*1b191cb5SApple OSS Distributions
359*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_TRANSITIONING_TASK_SNAPSHOT: {
360*1b191cb5SApple OSS Distributions i = 0;
361*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct transitioning_task_snapshot, tts_unique_pid);
362*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct transitioning_task_snapshot, tts_ss_flags);
363*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct transitioning_task_snapshot, tts_transition_type);
364*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT32, struct transitioning_task_snapshot, tts_pid);
365*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct transitioning_task_snapshot, tts_p_comm, 32);
366*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "transitioning_task_snapshot");
367*1b191cb5SApple OSS Distributions break;
368*1b191cb5SApple OSS Distributions }
369*1b191cb5SApple OSS Distributions
370*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_TASK_DELTA_SNAPSHOT: {
371*1b191cb5SApple OSS Distributions i = 0;
372*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_delta_snapshot_v2, tds_unique_pid);
373*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_delta_snapshot_v2, tds_ss_flags);
374*1b191cb5SApple OSS Distributions _SUBTYPE_TRUNC(KC_ST_UINT64, struct task_delta_snapshot_v2, tds_user_time_in_terminated_threads, "tds_user_time_in_terminated_thr");
375*1b191cb5SApple OSS Distributions _SUBTYPE_TRUNC(KC_ST_UINT64, struct task_delta_snapshot_v2, tds_system_time_in_terminated_threads, "tds_system_time_in_terminated_t");
376*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_delta_snapshot_v2, tds_task_size);
377*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct task_delta_snapshot_v2, tds_max_resident_size);
378*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_delta_snapshot_v2, tds_suspend_count);
379*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_delta_snapshot_v2, tds_faults);
380*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_delta_snapshot_v2, tds_pageins);
381*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_delta_snapshot_v2, tds_cow_faults);
382*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_delta_snapshot_v2, tds_was_throttled);
383*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_delta_snapshot_v2, tds_did_throttle);
384*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct task_delta_snapshot_v2, tds_latency_qos);
385*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "task_delta_snapshot");
386*1b191cb5SApple OSS Distributions break;
387*1b191cb5SApple OSS Distributions }
388*1b191cb5SApple OSS Distributions
389*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_SNAPSHOT: {
390*1b191cb5SApple OSS Distributions i = 0;
391*1b191cb5SApple OSS Distributions
392*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_thread_id);
393*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_wait_event);
394*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_continuation);
395*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_total_syscalls);
396*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_voucher_identifier);
397*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_dqserialnum);
398*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_user_time);
399*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_sys_time);
400*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_ss_flags);
401*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_last_run_time);
402*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_last_made_runnable_time);
403*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct thread_snapshot_v3, ths_state);
404*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct thread_snapshot_v3, ths_sched_flags);
405*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT16, struct thread_snapshot_v3, ths_base_priority);
406*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT16, struct thread_snapshot_v3, ths_sched_priority);
407*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_snapshot_v3, ths_eqos);
408*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_snapshot_v3, ths_rqos);
409*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_snapshot_v3, ths_rqos_override);
410*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_snapshot_v3, ths_io_tier);
411*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v3, ths_thread_t);
412*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v4, ths_requested_policy);
413*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_snapshot_v4, ths_effective_policy);
414*1b191cb5SApple OSS Distributions
415*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "thread_snapshot");
416*1b191cb5SApple OSS Distributions break;
417*1b191cb5SApple OSS Distributions }
418*1b191cb5SApple OSS Distributions
419*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_DELTA_SNAPSHOT: {
420*1b191cb5SApple OSS Distributions i = 0;
421*1b191cb5SApple OSS Distributions
422*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_delta_snapshot_v2, tds_thread_id);
423*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_delta_snapshot_v2, tds_voucher_identifier);
424*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_delta_snapshot_v2, tds_ss_flags);
425*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_delta_snapshot_v2, tds_last_made_runnable_time);
426*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct thread_delta_snapshot_v2, tds_state);
427*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct thread_delta_snapshot_v2, tds_sched_flags);
428*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT16, struct thread_delta_snapshot_v2, tds_base_priority);
429*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT16, struct thread_delta_snapshot_v2, tds_sched_priority);
430*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_delta_snapshot_v2, tds_eqos);
431*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_delta_snapshot_v2, tds_rqos);
432*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_delta_snapshot_v2, tds_rqos_override);
433*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct thread_delta_snapshot_v2, tds_io_tier);
434*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_delta_snapshot_v3, tds_requested_policy);
435*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_delta_snapshot_v3, tds_effective_policy);
436*1b191cb5SApple OSS Distributions
437*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "thread_delta_snapshot");
438*1b191cb5SApple OSS Distributions
439*1b191cb5SApple OSS Distributions break;
440*1b191cb5SApple OSS Distributions }
441*1b191cb5SApple OSS Distributions
442*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_DONATING_PIDS:
443*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "donating_pids");
444*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "donating_pids");
445*1b191cb5SApple OSS Distributions break;
446*1b191cb5SApple OSS Distributions
447*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_NAME: {
448*1b191cb5SApple OSS Distributions i = 0;
449*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_CHAR, 0, 64, "pth_name");
450*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "pth_name");
451*1b191cb5SApple OSS Distributions break;
452*1b191cb5SApple OSS Distributions }
453*1b191cb5SApple OSS Distributions
454*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_KERN_STACKFRAME:
455*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 2, "kernel_stack_frames");
456*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "lr");
457*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[1], KC_ST_UINT32, sizeof(uint32_t), "sp");
458*1b191cb5SApple OSS Distributions break;
459*1b191cb5SApple OSS Distributions
460*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_KERN_STACKFRAME64:
461*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 2, "kernel_stack_frames");
462*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "lr");
463*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[1], KC_ST_UINT64, sizeof(uint64_t), "sp");
464*1b191cb5SApple OSS Distributions break;
465*1b191cb5SApple OSS Distributions
466*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_USER_STACKFRAME:
467*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 2, "user_stack_frames");
468*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "lr");
469*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[1], KC_ST_UINT32, sizeof(uint32_t), "sp");
470*1b191cb5SApple OSS Distributions break;
471*1b191cb5SApple OSS Distributions
472*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_USER_STACKFRAME64:
473*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 2, "user_stack_frames");
474*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "lr");
475*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[1], KC_ST_UINT64, sizeof(uint64_t), "sp");
476*1b191cb5SApple OSS Distributions break;
477*1b191cb5SApple OSS Distributions
478*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_KERN_STACKLR:
479*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "kernel_stack_frames");
480*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "lr");
481*1b191cb5SApple OSS Distributions subtypes[0].kcs_flags |= KCS_SUBTYPE_FLAGS_STRUCT;
482*1b191cb5SApple OSS Distributions break;
483*1b191cb5SApple OSS Distributions
484*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_KERN_STACKLR64:
485*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "kernel_stack_frames");
486*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "lr");
487*1b191cb5SApple OSS Distributions subtypes[0].kcs_flags |= KCS_SUBTYPE_FLAGS_STRUCT;
488*1b191cb5SApple OSS Distributions break;
489*1b191cb5SApple OSS Distributions
490*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_USER_STACKLR:
491*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "user_stack_frames");
492*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "lr");
493*1b191cb5SApple OSS Distributions subtypes[0].kcs_flags |= KCS_SUBTYPE_FLAGS_STRUCT;
494*1b191cb5SApple OSS Distributions break;
495*1b191cb5SApple OSS Distributions
496*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_USER_STACKLR64:
497*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "user_stack_frames");
498*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "lr");
499*1b191cb5SApple OSS Distributions subtypes[0].kcs_flags |= KCS_SUBTYPE_FLAGS_STRUCT;
500*1b191cb5SApple OSS Distributions break;
501*1b191cb5SApple OSS Distributions
502*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_USER_ASYNC_START_INDEX:
503*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "user_async_start_index");
504*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "user_async_start_index");
505*1b191cb5SApple OSS Distributions break;
506*1b191cb5SApple OSS Distributions
507*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_USER_ASYNC_STACKLR64:
508*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "user_async_stack_frames");
509*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "lr");
510*1b191cb5SApple OSS Distributions subtypes[0].kcs_flags |= KCS_SUBTYPE_FLAGS_STRUCT;
511*1b191cb5SApple OSS Distributions break;
512*1b191cb5SApple OSS Distributions
513*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_NONRUNNABLE_TIDS:
514*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "nonrunnable_threads");
515*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT64, 0, "nonrunnable_threads");
516*1b191cb5SApple OSS Distributions break;
517*1b191cb5SApple OSS Distributions
518*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_NONRUNNABLE_TASKS:
519*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "nonrunnable_tasks");
520*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT64, 0, "nonrunnable_tasks");
521*1b191cb5SApple OSS Distributions break;
522*1b191cb5SApple OSS Distributions
523*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_SHAREDCACHE_ID:
524*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "sharedCacheID");
525*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "sharedCacheID");
526*1b191cb5SApple OSS Distributions break;
527*1b191cb5SApple OSS Distributions
528*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_CODESIGNING_INFO:
529*1b191cb5SApple OSS Distributions i = 0;
530*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_task_codesigning_info, csflags);
531*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct stackshot_task_codesigning_info, cs_trust_level);
532*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "stackshot_task_codesigning_info");
533*1b191cb5SApple OSS Distributions break;
534*1b191cb5SApple OSS Distributions
535*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_BOOTARGS: {
536*1b191cb5SApple OSS Distributions i = 0;
537*1b191cb5SApple OSS Distributions _STRINGTYPE("boot_args");
538*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "boot_args");
539*1b191cb5SApple OSS Distributions break;
540*1b191cb5SApple OSS Distributions }
541*1b191cb5SApple OSS Distributions
542*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_OSVERSION: {
543*1b191cb5SApple OSS Distributions i = 0;
544*1b191cb5SApple OSS Distributions _STRINGTYPE("osversion");
545*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "osversion");
546*1b191cb5SApple OSS Distributions break;
547*1b191cb5SApple OSS Distributions }
548*1b191cb5SApple OSS Distributions
549*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_KERN_PAGE_SIZE: {
550*1b191cb5SApple OSS Distributions i = 0;
551*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, 0, "kernel_page_size");
552*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "kernel_page_size");
553*1b191cb5SApple OSS Distributions break;
554*1b191cb5SApple OSS Distributions }
555*1b191cb5SApple OSS Distributions
556*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_POLICY_VERSION: {
557*1b191cb5SApple OSS Distributions i = 0;
558*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, 0, "thread_policy_version");
559*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "thread_policy_version");
560*1b191cb5SApple OSS Distributions break;
561*1b191cb5SApple OSS Distributions }
562*1b191cb5SApple OSS Distributions
563*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_JETSAM_LEVEL: {
564*1b191cb5SApple OSS Distributions i = 0;
565*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, 0, "jetsam_level");
566*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "jetsam_level");
567*1b191cb5SApple OSS Distributions break;
568*1b191cb5SApple OSS Distributions }
569*1b191cb5SApple OSS Distributions
570*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_DELTA_SINCE_TIMESTAMP: {
571*1b191cb5SApple OSS Distributions i = 0;
572*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT64, 0, "stackshot_delta_since_timestamp");
573*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "stackshot_delta_since_timestamp");
574*1b191cb5SApple OSS Distributions break;
575*1b191cb5SApple OSS Distributions }
576*1b191cb5SApple OSS Distributions
577*1b191cb5SApple OSS Distributions /* crashinfo types */
578*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_BSDINFOWITHUNIQID: {
579*1b191cb5SApple OSS Distributions i = 0;
580*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct crashinfo_proc_uniqidentifierinfo, p_uuid, 16);
581*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct crashinfo_proc_uniqidentifierinfo, p_uniqueid);
582*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct crashinfo_proc_uniqidentifierinfo, p_puniqueid);
583*1b191cb5SApple OSS Distributions /* Ignore the p_reserve fields */
584*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "proc_uniqidentifierinfo");
585*1b191cb5SApple OSS Distributions break;
586*1b191cb5SApple OSS Distributions }
587*1b191cb5SApple OSS Distributions
588*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PID: {
589*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "pid");
590*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "pid");
591*1b191cb5SApple OSS Distributions break;
592*1b191cb5SApple OSS Distributions }
593*1b191cb5SApple OSS Distributions
594*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PPID: {
595*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "ppid");
596*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "ppid");
597*1b191cb5SApple OSS Distributions break;
598*1b191cb5SApple OSS Distributions }
599*1b191cb5SApple OSS Distributions
600*1b191cb5SApple OSS Distributions /* case TASK_CRASHINFO_RUSAGE: { */
601*1b191cb5SApple OSS Distributions /* /\* */
602*1b191cb5SApple OSS Distributions /* * rusage is a complex structure and is only for legacy use for crashed processes rusage info. */
603*1b191cb5SApple OSS Distributions /* * So we just consider it as opaque data. */
604*1b191cb5SApple OSS Distributions /* *\/ */
605*1b191cb5SApple OSS Distributions /* i = 0; */
606*1b191cb5SApple OSS Distributions /* setup_subtype_array_description(&subtypes[i++], KC_ST_UINT8, 0, sizeof(struct rusage), "rusage"); */
607*1b191cb5SApple OSS Distributions /* setup_type_definition(retval, type_id, i, "rusage"); */
608*1b191cb5SApple OSS Distributions /* break; */
609*1b191cb5SApple OSS Distributions /* } */
610*1b191cb5SApple OSS Distributions
611*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_RUSAGE_INFO: {
612*1b191cb5SApple OSS Distributions i = 0;
613*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct rusage_info_v3, ri_uuid, 16);
614*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_user_time);
615*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_system_time);
616*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_pkg_idle_wkups);
617*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_interrupt_wkups);
618*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_pageins);
619*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_wired_size);
620*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_resident_size);
621*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_phys_footprint);
622*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_proc_start_abstime);
623*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_proc_exit_abstime);
624*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_child_user_time);
625*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_child_system_time);
626*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_child_pkg_idle_wkups);
627*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_child_interrupt_wkups);
628*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_child_pageins);
629*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_child_elapsed_abstime);
630*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_diskio_bytesread);
631*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_diskio_byteswritten);
632*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_cpu_time_qos_default);
633*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_cpu_time_qos_maintenance);
634*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_cpu_time_qos_background);
635*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_cpu_time_qos_utility);
636*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_cpu_time_qos_legacy);
637*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_cpu_time_qos_user_initiated);
638*1b191cb5SApple OSS Distributions _SUBTYPE_TRUNC(KC_ST_UINT64, struct rusage_info_v3, ri_cpu_time_qos_user_interactive, "ri_cpu_time_qos_user_interactiv");
639*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_billed_system_time);
640*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct rusage_info_v3, ri_serviced_system_time);
641*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "rusage_info");
642*1b191cb5SApple OSS Distributions break;
643*1b191cb5SApple OSS Distributions }
644*1b191cb5SApple OSS Distributions
645*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_CPU_TIMES: {
646*1b191cb5SApple OSS Distributions i = 0;
647*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_cpu_times_v2, user_usec);
648*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_cpu_times_v2, system_usec);
649*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_cpu_times_v2, runnable_usec);
650*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "cpu_times");
651*1b191cb5SApple OSS Distributions break;
652*1b191cb5SApple OSS Distributions }
653*1b191cb5SApple OSS Distributions
654*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_STACKSHOT_DURATION: {
655*1b191cb5SApple OSS Distributions i = 0;
656*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_duration_v2, stackshot_duration);
657*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_duration_v2, stackshot_duration_outer);
658*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_duration_v2, stackshot_duration_prior);
659*1b191cb5SApple OSS Distributions subtypes[0].kcs_flags |= KCS_SUBTYPE_FLAGS_MERGE;
660*1b191cb5SApple OSS Distributions subtypes[1].kcs_flags |= KCS_SUBTYPE_FLAGS_MERGE;
661*1b191cb5SApple OSS Distributions subtypes[2].kcs_flags |= KCS_SUBTYPE_FLAGS_MERGE;
662*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "stackshot_duration");
663*1b191cb5SApple OSS Distributions break;
664*1b191cb5SApple OSS Distributions }
665*1b191cb5SApple OSS Distributions
666*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_STACKSHOT_FAULT_STATS: {
667*1b191cb5SApple OSS Distributions i = 0;
668*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct stackshot_fault_stats, sfs_pages_faulted_in);
669*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_fault_stats, sfs_time_spent_faulting);
670*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_fault_stats, sfs_system_max_fault_time);
671*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct stackshot_fault_stats, sfs_stopped_faulting);
672*1b191cb5SApple OSS Distributions
673*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "stackshot_fault_stats");
674*1b191cb5SApple OSS Distributions break;
675*1b191cb5SApple OSS Distributions }
676*1b191cb5SApple OSS Distributions
677*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_WAITINFO: {
678*1b191cb5SApple OSS Distributions i = 0;
679*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_thread_waitinfo_v2, owner);
680*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_thread_waitinfo_v2, waiter);
681*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_thread_waitinfo_v2, context);
682*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct stackshot_thread_waitinfo_v2, wait_type);
683*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT16, struct stackshot_thread_waitinfo_v2, portlabel_id);
684*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct stackshot_thread_waitinfo_v2, wait_flags);
685*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "thread_waitinfo");
686*1b191cb5SApple OSS Distributions break;
687*1b191cb5SApple OSS Distributions }
688*1b191cb5SApple OSS Distributions
689*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_GROUP_SNAPSHOT: {
690*1b191cb5SApple OSS Distributions i = 0;
691*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_group_snapshot_v3, tgs_id);
692*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct thread_group_snapshot_v3, tgs_name, 16);
693*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct thread_group_snapshot_v3, tgs_flags);
694*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct thread_group_snapshot_v3, tgs_name_cont, 16);
695*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "thread_group_snapshot");
696*1b191cb5SApple OSS Distributions break;
697*1b191cb5SApple OSS Distributions }
698*1b191cb5SApple OSS Distributions
699*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_GROUP: {
700*1b191cb5SApple OSS Distributions i = 0;
701*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT64, 0, "thread_group");
702*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "thread_group");
703*1b191cb5SApple OSS Distributions break;
704*1b191cb5SApple OSS Distributions };
705*1b191cb5SApple OSS Distributions
706*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_JETSAM_COALITION_SNAPSHOT: {
707*1b191cb5SApple OSS Distributions i = 0;
708*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct jetsam_coalition_snapshot, jcs_id);
709*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct jetsam_coalition_snapshot, jcs_flags);
710*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct jetsam_coalition_snapshot, jcs_thread_group);
711*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct jetsam_coalition_snapshot, jcs_leader_task_uniqueid);
712*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "jetsam_coalition_snapshot");
713*1b191cb5SApple OSS Distributions break;
714*1b191cb5SApple OSS Distributions }
715*1b191cb5SApple OSS Distributions
716*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_JETSAM_COALITION: {
717*1b191cb5SApple OSS Distributions i = 0;
718*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT64, 0, "jetsam_coalition");
719*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "jetsam_coalition");
720*1b191cb5SApple OSS Distributions break;
721*1b191cb5SApple OSS Distributions };
722*1b191cb5SApple OSS Distributions
723*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_INSTRS_CYCLES: {
724*1b191cb5SApple OSS Distributions i = 0;
725*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct instrs_cycles_snapshot_v2, ics_instructions);
726*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct instrs_cycles_snapshot_v2, ics_cycles);
727*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct instrs_cycles_snapshot_v2, ics_p_instructions);
728*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct instrs_cycles_snapshot_v2, ics_p_cycles);
729*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "instrs_cycles_snapshot");
730*1b191cb5SApple OSS Distributions break;
731*1b191cb5SApple OSS Distributions }
732*1b191cb5SApple OSS Distributions
733*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_USER_STACKTOP: {
734*1b191cb5SApple OSS Distributions i = 0;
735*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stack_snapshot_stacktop, sp);
736*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct stack_snapshot_stacktop, stack_contents, 8);
737*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "user_stacktop");
738*1b191cb5SApple OSS Distributions break;
739*1b191cb5SApple OSS Distributions }
740*1b191cb5SApple OSS Distributions
741*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PROC_STARTTIME: {
742*1b191cb5SApple OSS Distributions i = 0;
743*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT64, struct timeval64, tv_sec);
744*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT64, struct timeval64, tv_usec);
745*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "proc_starttime");
746*1b191cb5SApple OSS Distributions break;
747*1b191cb5SApple OSS Distributions }
748*1b191cb5SApple OSS Distributions
749*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_EXCEPTION_CODES: {
750*1b191cb5SApple OSS Distributions i = 0;
751*1b191cb5SApple OSS Distributions char codenum[100];
752*1b191cb5SApple OSS Distributions for (i = 0; i < EXCEPTION_CODE_MAX; i++) {
753*1b191cb5SApple OSS Distributions snprintf(codenum, sizeof(codenum), "code_%d", i);
754*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i], KC_ST_UINT64, i * (sizeof(uint64_t)), codenum);
755*1b191cb5SApple OSS Distributions }
756*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "mach_exception_data_t");
757*1b191cb5SApple OSS Distributions break;
758*1b191cb5SApple OSS Distributions }
759*1b191cb5SApple OSS Distributions
760*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PROC_NAME: {
761*1b191cb5SApple OSS Distributions i = 0;
762*1b191cb5SApple OSS Distributions _STRINGTYPE("p_comm");
763*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "p_comm");
764*1b191cb5SApple OSS Distributions break;
765*1b191cb5SApple OSS Distributions }
766*1b191cb5SApple OSS Distributions
767*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_USERSTACK: {
768*1b191cb5SApple OSS Distributions i = 0;
769*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "userstack_ptr");
770*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "userstack_ptr");
771*1b191cb5SApple OSS Distributions break;
772*1b191cb5SApple OSS Distributions }
773*1b191cb5SApple OSS Distributions
774*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_ARGSLEN: {
775*1b191cb5SApple OSS Distributions i = 0;
776*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "p_argslen");
777*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "p_argslen");
778*1b191cb5SApple OSS Distributions break;
779*1b191cb5SApple OSS Distributions }
780*1b191cb5SApple OSS Distributions
781*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PROC_PATH: {
782*1b191cb5SApple OSS Distributions i = 0;
783*1b191cb5SApple OSS Distributions _STRINGTYPE("p_path");
784*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "p_path");
785*1b191cb5SApple OSS Distributions break;
786*1b191cb5SApple OSS Distributions }
787*1b191cb5SApple OSS Distributions
788*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PROC_CSFLAGS: {
789*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "p_csflags");
790*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "p_csflags");
791*1b191cb5SApple OSS Distributions break;
792*1b191cb5SApple OSS Distributions }
793*1b191cb5SApple OSS Distributions
794*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PROC_STATUS: {
795*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT8, 0, "p_status");
796*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "p_status");
797*1b191cb5SApple OSS Distributions break;
798*1b191cb5SApple OSS Distributions }
799*1b191cb5SApple OSS Distributions
800*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_UID: {
801*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "uid");
802*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "uid");
803*1b191cb5SApple OSS Distributions break;
804*1b191cb5SApple OSS Distributions }
805*1b191cb5SApple OSS Distributions
806*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_GID: {
807*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "gid");
808*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "gid");
809*1b191cb5SApple OSS Distributions break;
810*1b191cb5SApple OSS Distributions }
811*1b191cb5SApple OSS Distributions
812*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PROC_ARGC: {
813*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "argc");
814*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "argc");
815*1b191cb5SApple OSS Distributions break;
816*1b191cb5SApple OSS Distributions }
817*1b191cb5SApple OSS Distributions
818*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_PROC_FLAGS: {
819*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "p_flags");
820*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "p_flags");
821*1b191cb5SApple OSS Distributions break;
822*1b191cb5SApple OSS Distributions }
823*1b191cb5SApple OSS Distributions
824*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_CPUTYPE: {
825*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "cputype");
826*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "cputype");
827*1b191cb5SApple OSS Distributions break;
828*1b191cb5SApple OSS Distributions }
829*1b191cb5SApple OSS Distributions
830*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_RESPONSIBLE_PID: {
831*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_INT32, 0, "responsible_pid");
832*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "responsible_pid");
833*1b191cb5SApple OSS Distributions break;
834*1b191cb5SApple OSS Distributions }
835*1b191cb5SApple OSS Distributions
836*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_DIRTY_FLAGS: {
837*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "dirty_flags");
838*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "dirty_flags");
839*1b191cb5SApple OSS Distributions break;
840*1b191cb5SApple OSS Distributions }
841*1b191cb5SApple OSS Distributions
842*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_CRASHED_THREADID: {
843*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "crashed_threadid");
844*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "crashed_threadid");
845*1b191cb5SApple OSS Distributions break;
846*1b191cb5SApple OSS Distributions }
847*1b191cb5SApple OSS Distributions
848*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_COALITION_ID: {
849*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "coalition_id");
850*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "coalition_id");
851*1b191cb5SApple OSS Distributions break;
852*1b191cb5SApple OSS Distributions }
853*1b191cb5SApple OSS Distributions
854*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_UDATA_PTRS: {
855*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "udata_ptrs");
856*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "udata_ptrs");
857*1b191cb5SApple OSS Distributions break;
858*1b191cb5SApple OSS Distributions }
859*1b191cb5SApple OSS Distributions
860*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_MEMORY_LIMIT: {
861*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT64, 0, "task_phys_mem_limit");
862*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "task_phys_mem_limit");
863*1b191cb5SApple OSS Distributions break;
864*1b191cb5SApple OSS Distributions }
865*1b191cb5SApple OSS Distributions
866*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_TASK_IS_CORPSE_FORK: {
867*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "task_is_corpse_fork");
868*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "task_is_corpse_fork");
869*1b191cb5SApple OSS Distributions break;
870*1b191cb5SApple OSS Distributions }
871*1b191cb5SApple OSS Distributions
872*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_EXCEPTION_TYPE: {
873*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "exception_type");
874*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "exception_type");
875*1b191cb5SApple OSS Distributions break;
876*1b191cb5SApple OSS Distributions }
877*1b191cb5SApple OSS Distributions
878*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_CS_SIGNING_ID: {
879*1b191cb5SApple OSS Distributions i = 0;
880*1b191cb5SApple OSS Distributions _STRINGTYPE("cs_signing_id");
881*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "cs_signing_id");
882*1b191cb5SApple OSS Distributions break;
883*1b191cb5SApple OSS Distributions }
884*1b191cb5SApple OSS Distributions
885*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_CS_TEAM_ID: {
886*1b191cb5SApple OSS Distributions i = 0;
887*1b191cb5SApple OSS Distributions _STRINGTYPE("cs_team_id");
888*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "cs_team_id");
889*1b191cb5SApple OSS Distributions break;
890*1b191cb5SApple OSS Distributions }
891*1b191cb5SApple OSS Distributions
892*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_CS_VALIDATION_CATEGORY: {
893*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "cs_validation_category");
894*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "cs_validation_category");
895*1b191cb5SApple OSS Distributions break;
896*1b191cb5SApple OSS Distributions }
897*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_CS_TRUST_LEVEL: {
898*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[0], KC_ST_UINT32, 0, "cs_trust_level");
899*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, 1, "cs_trust_level");
900*1b191cb5SApple OSS Distributions break;
901*1b191cb5SApple OSS Distributions }
902*1b191cb5SApple OSS Distributions
903*1b191cb5SApple OSS Distributions case EXIT_REASON_SNAPSHOT: {
904*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct exit_reason_snapshot, ers_namespace);
905*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct exit_reason_snapshot, ers_code);
906*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct exit_reason_snapshot, ers_flags);
907*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "exit_reason_basic_info");
908*1b191cb5SApple OSS Distributions
909*1b191cb5SApple OSS Distributions break;
910*1b191cb5SApple OSS Distributions }
911*1b191cb5SApple OSS Distributions
912*1b191cb5SApple OSS Distributions case EXIT_REASON_USER_DESC: {
913*1b191cb5SApple OSS Distributions i = 0;
914*1b191cb5SApple OSS Distributions
915*1b191cb5SApple OSS Distributions _STRINGTYPE("exit_reason_user_description");
916*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "exit_reason_user_description");
917*1b191cb5SApple OSS Distributions break;
918*1b191cb5SApple OSS Distributions }
919*1b191cb5SApple OSS Distributions
920*1b191cb5SApple OSS Distributions case EXIT_REASON_USER_PAYLOAD: {
921*1b191cb5SApple OSS Distributions i = 0;
922*1b191cb5SApple OSS Distributions
923*1b191cb5SApple OSS Distributions setup_subtype_array_description(&subtypes[i++], KC_ST_UINT8, 0, EXIT_REASON_PAYLOAD_MAX_LEN, "exit_reason_user_payload");
924*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "exit_reason_user_payload");
925*1b191cb5SApple OSS Distributions break;
926*1b191cb5SApple OSS Distributions }
927*1b191cb5SApple OSS Distributions
928*1b191cb5SApple OSS Distributions case EXIT_REASON_CODESIGNING_INFO: {
929*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct codesigning_exit_reason_info, ceri_virt_addr);
930*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct codesigning_exit_reason_info, ceri_file_offset);
931*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct codesigning_exit_reason_info, ceri_pathname, EXIT_REASON_CODESIG_PATH_MAX);
932*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct codesigning_exit_reason_info, ceri_filename, EXIT_REASON_CODESIG_PATH_MAX);
933*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct codesigning_exit_reason_info, ceri_codesig_modtime_secs);
934*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct codesigning_exit_reason_info, ceri_codesig_modtime_nsecs);
935*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct codesigning_exit_reason_info, ceri_page_modtime_secs);
936*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct codesigning_exit_reason_info, ceri_page_modtime_nsecs);
937*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_path_truncated);
938*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_object_codesigned);
939*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_page_codesig_validated);
940*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_page_codesig_tainted);
941*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_page_codesig_nx);
942*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_page_wpmapped);
943*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_page_slid);
944*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct codesigning_exit_reason_info, ceri_page_dirty);
945*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT32, struct codesigning_exit_reason_info, ceri_page_shadow_depth);
946*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "exit_reason_codesigning_info");
947*1b191cb5SApple OSS Distributions break;
948*1b191cb5SApple OSS Distributions }
949*1b191cb5SApple OSS Distributions
950*1b191cb5SApple OSS Distributions case EXIT_REASON_WORKLOOP_ID: {
951*1b191cb5SApple OSS Distributions i = 0;
952*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT64, 0, "exit_reason_workloop_id");
953*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "exit_reason_workloop_id");
954*1b191cb5SApple OSS Distributions break;
955*1b191cb5SApple OSS Distributions }
956*1b191cb5SApple OSS Distributions
957*1b191cb5SApple OSS Distributions case EXIT_REASON_DISPATCH_QUEUE_NO: {
958*1b191cb5SApple OSS Distributions i = 0;
959*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT64, 0, "exit_reason_dispatch_queue_no");
960*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "exit_reason_dispatch_queue_no");
961*1b191cb5SApple OSS Distributions break;
962*1b191cb5SApple OSS Distributions }
963*1b191cb5SApple OSS Distributions
964*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_ASID: {
965*1b191cb5SApple OSS Distributions i = 0;
966*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT32, 0, "ts_asid");
967*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "ts_asid");
968*1b191cb5SApple OSS Distributions break;
969*1b191cb5SApple OSS Distributions }
970*1b191cb5SApple OSS Distributions
971*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_PAGE_TABLES: {
972*1b191cb5SApple OSS Distributions i = 0;
973*1b191cb5SApple OSS Distributions setup_subtype_description(&subtypes[i++], KC_ST_UINT64, 0, "ts_pagetable");
974*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "ts_pagetable");
975*1b191cb5SApple OSS Distributions break;
976*1b191cb5SApple OSS Distributions }
977*1b191cb5SApple OSS Distributions
978*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_SYS_SHAREDCACHE_LAYOUT: {
979*1b191cb5SApple OSS Distributions i = 0;
980*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct user64_dyld_uuid_info, imageLoadAddress);
981*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_UINT8, struct user64_dyld_uuid_info, imageUUID, 16);
982*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "system_shared_cache_layout");
983*1b191cb5SApple OSS Distributions break;
984*1b191cb5SApple OSS Distributions }
985*1b191cb5SApple OSS Distributions
986*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_DISPATCH_QUEUE_LABEL: {
987*1b191cb5SApple OSS Distributions i = 0;
988*1b191cb5SApple OSS Distributions _STRINGTYPE("dispatch_queue_label");
989*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "dispatch_queue_label");
990*1b191cb5SApple OSS Distributions break;
991*1b191cb5SApple OSS Distributions }
992*1b191cb5SApple OSS Distributions
993*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_THREAD_TURNSTILEINFO: {
994*1b191cb5SApple OSS Distributions i = 0;
995*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_thread_turnstileinfo_v2, waiter);
996*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_thread_turnstileinfo_v2, turnstile_context);
997*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct stackshot_thread_turnstileinfo_v2, turnstile_priority);
998*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT8, struct stackshot_thread_turnstileinfo_v2, number_of_hops);
999*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_thread_turnstileinfo_v2, turnstile_flags);
1000*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT16, struct stackshot_thread_turnstileinfo_v2, portlabel_id);
1001*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "thread_turnstileinfo");
1002*1b191cb5SApple OSS Distributions break;
1003*1b191cb5SApple OSS Distributions }
1004*1b191cb5SApple OSS Distributions
1005*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_PORTLABEL: {
1006*1b191cb5SApple OSS Distributions i = 0;
1007*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT16, struct portlabel_info, portlabel_id);
1008*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT16, struct portlabel_info, portlabel_flags);
1009*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT8, struct portlabel_info, portlabel_domain);
1010*1b191cb5SApple OSS Distributions subtypes[0].kcs_flags |= KCS_SUBTYPE_FLAGS_MERGE;
1011*1b191cb5SApple OSS Distributions subtypes[1].kcs_flags |= KCS_SUBTYPE_FLAGS_MERGE;
1012*1b191cb5SApple OSS Distributions subtypes[2].kcs_flags |= KCS_SUBTYPE_FLAGS_MERGE;
1013*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "portlabel_info");
1014*1b191cb5SApple OSS Distributions break;
1015*1b191cb5SApple OSS Distributions }
1016*1b191cb5SApple OSS Distributions
1017*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_PORTLABEL_NAME:
1018*1b191cb5SApple OSS Distributions i = 0;
1019*1b191cb5SApple OSS Distributions _STRINGTYPE("portlabel_name");
1020*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "portlabel_name");
1021*1b191cb5SApple OSS Distributions break;
1022*1b191cb5SApple OSS Distributions
1023*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_TASK_CPU_ARCHITECTURE: {
1024*1b191cb5SApple OSS Distributions i = 0;
1025*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT32, struct stackshot_cpu_architecture, cputype);
1026*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_INT32, struct stackshot_cpu_architecture, cpusubtype);
1027*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "task_cpu_architecture");
1028*1b191cb5SApple OSS Distributions break;
1029*1b191cb5SApple OSS Distributions }
1030*1b191cb5SApple OSS Distributions
1031*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_LATENCY_INFO: {
1032*1b191cb5SApple OSS Distributions i = 0;
1033*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_collection, latency_version);
1034*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_collection, setup_latency);
1035*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_collection, total_task_iteration_latency);
1036*1b191cb5SApple OSS Distributions _SUBTYPE_TRUNC(KC_ST_UINT64, struct stackshot_latency_collection, total_terminated_task_iteration_latency, "total_terminated_task_iteration");
1037*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "stackshot_latency_collection");
1038*1b191cb5SApple OSS Distributions break;
1039*1b191cb5SApple OSS Distributions }
1040*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_LATENCY_INFO_TASK: {
1041*1b191cb5SApple OSS Distributions i = 0;
1042*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, task_uniqueid);
1043*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, setup_latency);
1044*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, task_thread_count_loop_latency);
1045*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, task_thread_data_loop_latency);
1046*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, cur_tsnap_latency);
1047*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, pmap_latency);
1048*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, bsd_proc_ids_latency);
1049*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, misc_latency);
1050*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, misc2_latency);
1051*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_task, end_latency);
1052*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "stackshot_latency_task");
1053*1b191cb5SApple OSS Distributions break;
1054*1b191cb5SApple OSS Distributions }
1055*1b191cb5SApple OSS Distributions case STACKSHOT_KCTYPE_LATENCY_INFO_THREAD: {
1056*1b191cb5SApple OSS Distributions i = 0;
1057*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, thread_id);
1058*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, cur_thsnap1_latency);
1059*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, dispatch_serial_latency);
1060*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, dispatch_label_latency);
1061*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, cur_thsnap2_latency);
1062*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, thread_name_latency);
1063*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, sur_times_latency);
1064*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, user_stack_latency);
1065*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, kernel_stack_latency);
1066*1b191cb5SApple OSS Distributions _SUBTYPE(KC_ST_UINT64, struct stackshot_latency_thread, misc_latency);
1067*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "stackshot_latency_thread");
1068*1b191cb5SApple OSS Distributions break;
1069*1b191cb5SApple OSS Distributions }
1070*1b191cb5SApple OSS Distributions
1071*1b191cb5SApple OSS Distributions case TASK_CRASHINFO_KERNEL_TRIAGE_INFO_V1: {
1072*1b191cb5SApple OSS Distributions i = 0;
1073*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct kernel_triage_info_v1, triage_string1, MAX_TRIAGE_STRING_LEN);
1074*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct kernel_triage_info_v1, triage_string2, MAX_TRIAGE_STRING_LEN);
1075*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct kernel_triage_info_v1, triage_string3, MAX_TRIAGE_STRING_LEN);
1076*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct kernel_triage_info_v1, triage_string4, MAX_TRIAGE_STRING_LEN);
1077*1b191cb5SApple OSS Distributions _SUBTYPE_ARRAY(KC_ST_CHAR, struct kernel_triage_info_v1, triage_string5, MAX_TRIAGE_STRING_LEN);
1078*1b191cb5SApple OSS Distributions setup_type_definition(retval, type_id, i, "kernel_triage_info_v1");
1079*1b191cb5SApple OSS Distributions break;
1080*1b191cb5SApple OSS Distributions }
1081*1b191cb5SApple OSS Distributions
1082*1b191cb5SApple OSS Distributions default:
1083*1b191cb5SApple OSS Distributions retval = NULL;
1084*1b191cb5SApple OSS Distributions break;
1085*1b191cb5SApple OSS Distributions }
1086*1b191cb5SApple OSS Distributions
1087*1b191cb5SApple OSS Distributions assert(retval == NULL || (buffer_size > sizeof(struct kcdata_type_definition) +
1088*1b191cb5SApple OSS Distributions (retval->kct_num_elements * sizeof(struct kcdata_subtype_descriptor))));
1089*1b191cb5SApple OSS Distributions return retval;
1090*1b191cb5SApple OSS Distributions }
1091*1b191cb5SApple OSS Distributions
1092*1b191cb5SApple OSS Distributions static void
setup_type_definition(struct kcdata_type_definition * d,uint32_t type,uint32_t num_elems,char * name)1093*1b191cb5SApple OSS Distributions setup_type_definition(struct kcdata_type_definition * d, uint32_t type, uint32_t num_elems, char * name)
1094*1b191cb5SApple OSS Distributions {
1095*1b191cb5SApple OSS Distributions d->kct_type_identifier = type;
1096*1b191cb5SApple OSS Distributions d->kct_num_elements = num_elems;
1097*1b191cb5SApple OSS Distributions memcpy(d->kct_name, name, sizeof(d->kct_name));
1098*1b191cb5SApple OSS Distributions d->kct_name[sizeof(d->kct_name) - 1] = '\0';
1099*1b191cb5SApple OSS Distributions }
1100*1b191cb5SApple OSS Distributions
1101*1b191cb5SApple OSS Distributions static uint32_t
get_kctype_subtype_size(kctype_subtype_t type)1102*1b191cb5SApple OSS Distributions get_kctype_subtype_size(kctype_subtype_t type)
1103*1b191cb5SApple OSS Distributions {
1104*1b191cb5SApple OSS Distributions switch (type) {
1105*1b191cb5SApple OSS Distributions case KC_ST_CHAR:
1106*1b191cb5SApple OSS Distributions case KC_ST_INT8:
1107*1b191cb5SApple OSS Distributions case KC_ST_UINT8:
1108*1b191cb5SApple OSS Distributions return sizeof(uint8_t);
1109*1b191cb5SApple OSS Distributions break;
1110*1b191cb5SApple OSS Distributions case KC_ST_INT16:
1111*1b191cb5SApple OSS Distributions case KC_ST_UINT16:
1112*1b191cb5SApple OSS Distributions return sizeof(uint16_t);
1113*1b191cb5SApple OSS Distributions break;
1114*1b191cb5SApple OSS Distributions case KC_ST_INT32:
1115*1b191cb5SApple OSS Distributions case KC_ST_UINT32:
1116*1b191cb5SApple OSS Distributions return sizeof(uint32_t);
1117*1b191cb5SApple OSS Distributions break;
1118*1b191cb5SApple OSS Distributions case KC_ST_INT64:
1119*1b191cb5SApple OSS Distributions case KC_ST_UINT64:
1120*1b191cb5SApple OSS Distributions return sizeof(uint64_t);
1121*1b191cb5SApple OSS Distributions break;
1122*1b191cb5SApple OSS Distributions
1123*1b191cb5SApple OSS Distributions default:
1124*1b191cb5SApple OSS Distributions assert(0);
1125*1b191cb5SApple OSS Distributions break;
1126*1b191cb5SApple OSS Distributions }
1127*1b191cb5SApple OSS Distributions return 0;
1128*1b191cb5SApple OSS Distributions }
1129*1b191cb5SApple OSS Distributions
1130*1b191cb5SApple OSS Distributions static void
setup_subtype_array_description(kcdata_subtype_descriptor_t desc,kctype_subtype_t type,uint32_t offset,uint32_t count,char * name)1131*1b191cb5SApple OSS Distributions setup_subtype_array_description(
1132*1b191cb5SApple OSS Distributions kcdata_subtype_descriptor_t desc, kctype_subtype_t type, uint32_t offset, uint32_t count, char * name)
1133*1b191cb5SApple OSS Distributions {
1134*1b191cb5SApple OSS Distributions desc->kcs_flags = KCS_SUBTYPE_FLAGS_ARRAY;
1135*1b191cb5SApple OSS Distributions desc->kcs_elem_type = type;
1136*1b191cb5SApple OSS Distributions desc->kcs_elem_offset = offset;
1137*1b191cb5SApple OSS Distributions desc->kcs_elem_size = KCS_SUBTYPE_PACK_SIZE(count, get_kctype_subtype_size(type));
1138*1b191cb5SApple OSS Distributions memcpy(desc->kcs_name, name, sizeof(desc->kcs_name));
1139*1b191cb5SApple OSS Distributions desc->kcs_name[sizeof(desc->kcs_name) - 1] = '\0';
1140*1b191cb5SApple OSS Distributions }
1141*1b191cb5SApple OSS Distributions
1142*1b191cb5SApple OSS Distributions static void
setup_subtype_description(kcdata_subtype_descriptor_t desc,kctype_subtype_t type,uint32_t offset,char * name)1143*1b191cb5SApple OSS Distributions setup_subtype_description(kcdata_subtype_descriptor_t desc, kctype_subtype_t type, uint32_t offset, char * name)
1144*1b191cb5SApple OSS Distributions {
1145*1b191cb5SApple OSS Distributions desc->kcs_flags = KCS_SUBTYPE_FLAGS_NONE;
1146*1b191cb5SApple OSS Distributions desc->kcs_elem_type = type;
1147*1b191cb5SApple OSS Distributions desc->kcs_elem_offset = offset;
1148*1b191cb5SApple OSS Distributions desc->kcs_elem_size = get_kctype_subtype_size(type);
1149*1b191cb5SApple OSS Distributions memcpy(desc->kcs_name, name, sizeof(desc->kcs_name));
1150*1b191cb5SApple OSS Distributions desc->kcs_name[sizeof(desc->kcs_name) - 1] = '\0';
1151*1b191cb5SApple OSS Distributions }
1152