static void ktrace_set_owning_proc(proc_t p) { lck_mtx_assert(ktrace_lock, LCK_MTX_ASSERT_OWNED); assert(p); if (ktrace_state != KTRACE_STATE_FG) { if (proc_uniqueid(p) == ktrace_bg_unique_id) { ktrace_state = KTRACE_STATE_BG; } else { if (ktrace_state == KTRACE_STATE_BG) { if (ktrace_active_mask & KTRACE_KPERF) { kperf_reset(); } if (ktrace_active_mask & KTRACE_KDEBUG) { kdebug_reset(); } ktrace_active_mask = 0; } ktrace_state = KTRACE_STATE_FG; should_notify_on_init = FALSE; } } ktrace_owning_unique_id = proc_uniqueid(p); ktrace_owning_pid = proc_pid(p); strlcpy(ktrace_last_owner_execname, proc_name_address(p), sizeof(ktrace_last_owner_execname)); }
void ktrace_kernel_configure(uint32_t config_mask) { lck_mtx_assert(ktrace_lock, LCK_MTX_ASSERT_OWNED); if (ktrace_state != KTRACE_STATE_OFF) { if (ktrace_active_mask & KTRACE_KPERF) { kperf_reset(); } if (ktrace_active_mask & KTRACE_KDEBUG) { kdebug_reset(); } } ktrace_active_mask = config_mask; ktrace_state = KTRACE_STATE_FG; ktrace_release_ownership(); strlcpy(ktrace_last_owner_execname, "kernel_task", sizeof(ktrace_last_owner_execname)); }
void ktrace_reset(uint32_t reset_mask) { lck_mtx_assert(ktrace_lock, LCK_MTX_ASSERT_OWNED); assert(reset_mask != 0); if (ktrace_active_mask == 0) { if (!ktrace_keep_ownership_on_reset) { assert(ktrace_state == KTRACE_STATE_OFF); } return; } if (!ktrace_keep_ownership_on_reset) { ktrace_active_mask &= ~reset_mask; } if (reset_mask & KTRACE_KPERF) { kperf_reset(); } if (reset_mask & KTRACE_KDEBUG) { kdebug_reset(); } if (ktrace_active_mask == 0) { if (ktrace_state == KTRACE_STATE_FG) { /* transition from foreground to background */ ktrace_promote_background(); } else if (ktrace_state == KTRACE_STATE_BG) { /* background tool is resetting ktrace */ should_notify_on_init = TRUE; ktrace_release_ownership(); ktrace_state = KTRACE_STATE_OFF; } } }
static void reset_ktrace(void) { kperf_reset(); }