+void gather_populate_corpse_crashinfo(proc_t p, void *crash_info_ptr, mach_exception_data_type_t code, mach_exception_data_type_t subcode, uint64_t *udata_buffer, int num_udata)
+{
+ struct rusage_superset rup;
+
+ gather_rusage_info(p, &rup.ri, RUSAGE_INFO_CURRENT);
+ rup.ri.ri_phys_footprint = 0;
+ populate_corpse_crashinfo(p, crash_info_ptr, &rup, code, subcode, udata_buffer, num_udata);
+}
+
+static void proc_update_corpse_exception_codes(proc_t p, mach_exception_data_type_t *code, mach_exception_data_type_t *subcode)
+{
+ mach_exception_data_type_t code_update = *code;
+ mach_exception_data_type_t subcode_update = *subcode;
+ if (p->p_exit_reason == OS_REASON_NULL) {
+ return;
+ }
+
+ switch (p->p_exit_reason->osr_namespace) {
+ case OS_REASON_JETSAM:
+ if (p->p_exit_reason->osr_code == JETSAM_REASON_MEMORY_PERPROCESSLIMIT) {
+ /* Update the code with EXC_RESOURCE code for high memory watermark */
+ EXC_RESOURCE_ENCODE_TYPE(code_update, RESOURCE_TYPE_MEMORY);
+ EXC_RESOURCE_ENCODE_FLAVOR(code_update, FLAVOR_HIGH_WATERMARK);
+ EXC_RESOURCE_HWM_ENCODE_LIMIT(code_update, ((get_task_phys_footprint_limit(p->task)) >> 20));
+ subcode_update = 0;
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ *code = code_update;
+ *subcode = subcode_update;
+ return;
+}
+
+mach_exception_data_type_t proc_encode_exit_exception_code(proc_t p)
+{
+ uint64_t subcode = 0;
+
+ if (p->p_exit_reason == OS_REASON_NULL) {
+ return 0;
+ }
+
+ /* Embed first 32 bits of osr_namespace and osr_code in exception code */
+ ENCODE_OSR_NAMESPACE_TO_MACH_EXCEPTION_CODE(subcode, p->p_exit_reason->osr_namespace);
+ ENCODE_OSR_CODE_TO_MACH_EXCEPTION_CODE(subcode, p->p_exit_reason->osr_code);
+ return (mach_exception_data_type_t)subcode;
+}
+
+static void populate_corpse_crashinfo(proc_t p, void *crash_info_ptr, struct rusage_superset *rup, mach_exception_data_type_t code, mach_exception_data_type_t subcode, uint64_t *udata_buffer, int num_udata)