void telemetry_task_ctl_locked(task_t task, uint32_t reasons, int enable_disable) { uint32_t origflags; assert((reasons != 0) && ((reasons | TF_TELEMETRY) == TF_TELEMETRY)); task_lock_assert_owned(task); origflags = task->t_flags; if (enable_disable == 1) { task->t_flags |= reasons; if ((origflags & TF_TELEMETRY) == 0) { OSIncrementAtomic(&telemetry_active_tasks); #if TELEMETRY_DEBUG printf("%s: telemetry OFF -> ON (%d active)\n", proc_name_address(task->bsd_info), telemetry_active_tasks); #endif } } else { task->t_flags &= ~reasons; if (((origflags & TF_TELEMETRY) != 0) && ((task->t_flags & TF_TELEMETRY) == 0)) { /* * If this task went from having at least one telemetry bit to having none, * the net change was to disable telemetry for the task. */ OSDecrementAtomic(&telemetry_active_tasks); #if TELEMETRY_DEBUG printf("%s: telemetry ON -> OFF (%d active)\n", proc_name_address(task->bsd_info), telemetry_active_tasks); #endif } } }
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)); }
static void panic_display_process_name(void) { char proc_name[32] = "Unknown"; task_t ctask = 0; void *cbsd_info = 0; if (ml_nofault_copy((vm_offset_t)¤t_thread()->task, (vm_offset_t) &ctask, sizeof(task_t)) == sizeof(task_t)) if(ml_nofault_copy((vm_offset_t)&ctask->bsd_info, (vm_offset_t)&cbsd_info, sizeof(&ctask->bsd_info)) == sizeof(&ctask->bsd_info)) if (cbsd_info && (ml_nofault_copy((vm_offset_t) proc_name_address(cbsd_info), (vm_offset_t) &proc_name, sizeof(proc_name)) > 0)) proc_name[sizeof(proc_name) - 1] = '\0'; kdb_printf("\nBSD process name corresponding to current thread: %s\n", proc_name); }
static void panic_display_process_name(void) { /* because of scoping issues len(p_comm) from proc_t is hard coded here */ char proc_name[17] = "Unknown"; task_t ctask = 0; void *cbsd_info = 0; if (ml_nofault_copy((vm_offset_t)¤t_thread()->task, (vm_offset_t) &ctask, sizeof(task_t)) == sizeof(task_t)) if(ml_nofault_copy((vm_offset_t)&ctask->bsd_info, (vm_offset_t)&cbsd_info, sizeof(cbsd_info)) == sizeof(cbsd_info)) if (cbsd_info && (ml_nofault_copy((vm_offset_t) proc_name_address(cbsd_info), (vm_offset_t) &proc_name, sizeof(proc_name)) > 0)) proc_name[sizeof(proc_name) - 1] = '\0'; kdb_printf("\nBSD process name corresponding to current thread: %s\n", proc_name); }
/** * panic_backlog */ void panic_backlog(uint32_t stackptr) { #ifndef __LP64__ thread_t currthr = current_thread(); /* * Make sure the crash is after we set the first thread. */ if (!currthr) { kprintf("panicked thread: %p, backtrace: 0x%08x\n", currthr, stackptr); panic_arm_thread_backtrace(stackptr, 32, NULL, FALSE, NULL, TRUE, ""); return; } task_t task = currthr->task; /* * If the task is null, return... */ if (!task) { kprintf("panicked thread: %p, backtrace: 0x%08x\n", currthr, stackptr); panic_arm_thread_backtrace(stackptr, 32, NULL, FALSE, NULL, TRUE, ""); return; } char *name; if (task->bsd_info && (name = proc_name_address(task->bsd_info))) { /* */ } else { name = (char *) "unknown task"; } kext_dump_panic_lists(&kdb_printf); kdb_printf("\nPanicked task %p: %d pages, %d threads: pid %d: %s\n" "panicked thread: %p, backtrace: 0x%08x\n", task, task->all_image_info_size, task->thread_count, (task->bsd_info != NULL) ? proc_pid(task->bsd_info) : 0, name, currthr, stackptr); panic_arm_thread_backtrace(stackptr, 32, NULL, FALSE, NULL, TRUE, ""); if ((currthr->machine.uss == &currthr->machine.user_regs) && currthr->machine.uss->pc) { kdb_printf("%s\tuser state:\n", ""); kdb_printf("%s\t r0: 0x%08x r1: 0x%08x r2: 0x%08x r3: 0x%08x\n" "%s\t r4: 0x%08x r5: 0x%08x r6: 0x%08x r7: 0x%08x\n" "%s\t r8: 0x%08x r9: 0x%08x r10: 0x%08x r11: 0x%08x\n" "%s\t r12: 0x%08x sp: 0x%08x lr: 0x%08x pc: 0x%08x\n" "%s\tcpsr: 0x%08x fsr: 0x%08x far: 0x%08x\n", "", currthr->machine.uss->r[0], currthr->machine.uss->r[1], currthr->machine.uss->r[2], currthr->machine.uss->r[3], "", currthr->machine.uss->r[4], currthr->machine.uss->r[5], currthr->machine.uss->r[6], currthr->machine.uss->r[7], "", currthr->machine.uss->r[8], currthr->machine.uss->r[9], currthr->machine.uss->r[10], currthr->machine.uss->r[11], "", currthr->machine.uss->r[12], currthr->machine.uss->sp, currthr->machine.uss->lr, currthr->machine.uss->pc, "", currthr->machine.uss->cpsr, 0, 0); } if (panicDebugging) { print_threads(stackptr); } else { kdb_printf("\n"); queue_head_t *task_list = &tasks; task_t task = TASK_NULL; queue_iterate(task_list, task, task_t, tasks) { char *name; if (task->bsd_info && (name = proc_name_address(task->bsd_info))) { /* */ } else { name = (char *) "unknown task"; } if (task == currthr->task) continue; kdb_printf("Task 0x%x: %d pages, %d threads: pid %d: %s\n", task, task->all_image_info_size, task->thread_count, (task->bsd_info != NULL) ? proc_pid(task->bsd_info) : 0, name); } }