2 * Copyright (c) 2012-2013, 2015 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _TASK_CORPSE_H_
30 #define _TASK_CORPSE_H_
33 #include <mach/mach_types.h>
34 #include <kern/kern_cdata.h>
35 #include <kern/kcdata.h>
37 typedef struct kcdata_item
*task_crashinfo_item_t
;
39 /* Deprecated: use the KCDATA_* macros for all future use */
40 #define CRASHINFO_ITEM_TYPE(item) KCDATA_ITEM_TYPE(item)
41 #define CRASHINFO_ITEM_SIZE(item) KCDATA_ITEM_SIZE(item)
42 #define CRASHINFO_ITEM_DATA_PTR(item) KCDATA_ITEM_DATA_PTR(item)
44 #define CRASHINFO_ITEM_NEXT_HEADER(item) KCDATA_ITEM_NEXT_HEADER(item)
46 #define CRASHINFO_ITEM_FOREACH(head) KCDATA_ITEM_FOREACH(head)
50 #define task_crashinfo_get_data_with_desc kcdata_get_data_with_desc
54 #ifdef XNU_KERNEL_PRIVATE
56 #define CORPSEINFO_ALLOCATION_SIZE (1024 * 16)
57 #define TOTAL_CORPSES_ALLOWED 5
58 #define TOTAL_USER_FAULTS_ALLOWED 1
61 extern kern_return_t
task_mark_corpse(task_t task
);
63 extern kern_return_t
task_deliver_crash_notification(task_t
, thread_t
, exception_type_t
, mach_exception_subcode_t
);
65 /* In the corpseinfo kcd_user_flags */
66 __options_closed_decl(corpse_flags_t
, uint16_t, {
67 CORPSE_CRASHINFO_HAS_REF
= 0x1,
68 CORPSE_CRASHINFO_USER_FAULT
= 0x2
71 extern kcdata_descriptor_t
task_get_corpseinfo(task_t task
);
73 extern kcdata_descriptor_t
task_crashinfo_alloc_init(
74 mach_vm_address_t crash_data_p
,
75 unsigned size
, corpse_flags_t kc_u_flags
, unsigned kc_flags
);
76 extern kern_return_t
task_crashinfo_destroy(kcdata_descriptor_t data
);
78 extern void corpses_init(void);
80 extern unsigned long total_corpses_count(void) __attribute__((pure
));
81 extern boolean_t
corpses_enabled(void);
83 extern kern_return_t
task_generate_corpse_internal(
87 exception_type_t etype
,
88 mach_exception_data_type_t code
,
89 mach_exception_data_type_t subcode
,
92 extern void task_clear_corpse(task_t task
);
94 extern kern_return_t
task_duplicate_map_and_threads(
99 uint64_t **udata_buffer
,
103 extern kern_return_t
task_enqueue_exception_with_corpse(
105 exception_type_t etype
,
106 mach_exception_data_t code
,
107 mach_msg_type_number_t codeCnt
,
110 extern void task_add_to_corpse_task_list(task_t corpse_task
);
111 void task_remove_from_corpse_task_list(task_t corpse_task
);
112 void task_purge_all_corpses(void);
113 extern uint64_t task_corpse_get_crashed_thread_id(task_t corpse_task
);
115 #endif /* XNU_KERNEL_PRIVATE */
117 #endif /* _TASK_CORPSE_H_ */