1 //===-- MachThread.cpp ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Created by Greg Clayton on 6/19/07.
12 //===----------------------------------------------------------------------===//
14 #include "MachThread.h"
17 #include "MachProcess.h"
18 #include "ThreadInfo.h"
21 #include <mach/thread_policy.h>
23 static uint32_t GetSequenceID() {
24 static uint32_t g_nextID = 0;
28 MachThread::MachThread(MachProcess *process, bool is_64_bit,
29 uint64_t unique_thread_id, thread_t mach_port_num)
30 : m_process(process), m_unique_id(unique_thread_id),
31 m_mach_port_number(mach_port_num), m_seq_id(GetSequenceID()),
32 m_state(eStateUnloaded), m_state_mutex(PTHREAD_MUTEX_RECURSIVE),
33 m_suspend_count(0), m_stop_exception(),
34 m_arch_ap(DNBArchProtocol::Create(this)), m_reg_sets(NULL),
35 m_num_reg_sets(0), m_ident_info(), m_proc_threadinfo(),
36 m_dispatch_queue_name(), m_is_64_bit(is_64_bit),
37 m_pthread_qos_class_decode(nullptr) {
38 nub_size_t num_reg_sets = 0;
39 m_reg_sets = m_arch_ap->GetRegisterSetInfo(&num_reg_sets);
40 m_num_reg_sets = num_reg_sets;
42 m_pthread_qos_class_decode =
43 (unsigned int (*)(unsigned long, int *, unsigned long *))dlsym(
44 RTLD_DEFAULT, "_pthread_qos_class_decode");
46 // Get the thread state so we know if a thread is in a state where we can't
47 // muck with it and also so we get the suspend count correct in case it was
50 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE,
51 "MachThread::MachThread ( process = %p, tid = 0x%8.8" PRIx64
53 &m_process, m_unique_id, m_seq_id);
56 MachThread::~MachThread() {
57 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE,
58 "MachThread::~MachThread() for tid = 0x%8.8" PRIx64 " (%u)",
59 m_unique_id, m_seq_id);
62 void MachThread::Suspend() {
63 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )",
65 if (MachPortNumberIsValid(m_mach_port_number)) {
66 DNBError err(::thread_suspend(m_mach_port_number), DNBError::MachKernel);
69 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
70 err.LogThreaded("::thread_suspend (%4.4" PRIx32 ")", m_mach_port_number);
74 void MachThread::Resume(bool others_stopped) {
75 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )",
77 if (MachPortNumberIsValid(m_mach_port_number)) {
78 SetSuspendCountBeforeResume(others_stopped);
82 bool MachThread::SetSuspendCountBeforeResume(bool others_stopped) {
83 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )",
86 if (MachPortNumberIsValid(m_mach_port_number) == false)
89 integer_t times_to_resume;
93 times_to_resume = m_basic_info.suspend_count;
94 m_suspend_count = -(times_to_resume - m_suspend_count);
98 times_to_resume = m_suspend_count;
102 if (times_to_resume > 0) {
103 while (times_to_resume > 0) {
104 err = ::thread_resume(m_mach_port_number);
105 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
106 err.LogThreaded("::thread_resume (%4.4" PRIx32 ")", m_mach_port_number);
111 times_to_resume = m_basic_info.suspend_count;
120 bool MachThread::RestoreSuspendCountAfterStop() {
121 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )",
124 if (MachPortNumberIsValid(m_mach_port_number) == false)
127 if (m_suspend_count > 0) {
128 while (m_suspend_count > 0) {
129 err = ::thread_resume(m_mach_port_number);
130 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail())
131 err.LogThreaded("::thread_resume (%4.4" PRIx32 ")", m_mach_port_number);
136 m_suspend_count = m_basic_info.suspend_count;
142 } else if (m_suspend_count < 0) {
143 while (m_suspend_count < 0) {
144 err = ::thread_suspend(m_mach_port_number);
147 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) {
148 err.LogThreaded("::thread_suspend (%4.4" PRIx32 ")",
157 const char *MachThread::GetBasicInfoAsString() const {
158 static char g_basic_info_string[1024];
159 struct thread_basic_info basicInfo;
161 if (GetBasicInfo(m_mach_port_number, &basicInfo)) {
163 // char run_state_str[32];
164 // size_t run_state_str_size = sizeof(run_state_str);
165 // switch (basicInfo.run_state)
167 // case TH_STATE_RUNNING: strncpy(run_state_str, "running",
168 // run_state_str_size); break;
169 // case TH_STATE_STOPPED: strncpy(run_state_str, "stopped",
170 // run_state_str_size); break;
171 // case TH_STATE_WAITING: strncpy(run_state_str, "waiting",
172 // run_state_str_size); break;
173 // case TH_STATE_UNINTERRUPTIBLE: strncpy(run_state_str,
174 // "uninterruptible", run_state_str_size); break;
175 // case TH_STATE_HALTED: strncpy(run_state_str, "halted",
176 // run_state_str_size); break;
177 // default: snprintf(run_state_str,
178 // run_state_str_size, "%d", basicInfo.run_state); break; // ???
180 float user = (float)basicInfo.user_time.seconds +
181 (float)basicInfo.user_time.microseconds / 1000000.0f;
182 float system = (float)basicInfo.user_time.seconds +
183 (float)basicInfo.user_time.microseconds / 1000000.0f;
184 snprintf(g_basic_info_string, sizeof(g_basic_info_string),
185 "Thread 0x%8.8" PRIx64 ": user=%f system=%f cpu=%d sleep_time=%d",
186 m_unique_id, user, system, basicInfo.cpu_usage,
187 basicInfo.sleep_time);
189 return g_basic_info_string;
194 // Finds the Mach port number for a given thread in the inferior process' port
196 thread_t MachThread::InferiorThreadID() const {
197 mach_msg_type_number_t i;
198 mach_port_name_array_t names;
199 mach_port_type_array_t types;
200 mach_msg_type_number_t ncount, tcount;
201 thread_t inferior_tid = INVALID_NUB_THREAD;
202 task_t my_task = ::mach_task_self();
203 task_t task = m_process->Task().TaskPort();
206 ::mach_port_names(task, &names, &ncount, &types, &tcount);
207 if (kret == KERN_SUCCESS) {
209 for (i = 0; i < ncount; i++) {
211 mach_msg_type_name_t my_type;
213 kret = ::mach_port_extract_right(task, names[i], MACH_MSG_TYPE_COPY_SEND,
215 if (kret == KERN_SUCCESS) {
216 ::mach_port_deallocate(my_task, my_name);
217 if (my_name == m_mach_port_number) {
218 inferior_tid = names[i];
223 // Free up the names and types
224 ::vm_deallocate(my_task, (vm_address_t)names,
225 ncount * sizeof(mach_port_name_t));
226 ::vm_deallocate(my_task, (vm_address_t)types,
227 tcount * sizeof(mach_port_type_t));
232 bool MachThread::IsUserReady() {
233 if (m_basic_info.run_state == 0)
236 switch (m_basic_info.run_state) {
238 case TH_STATE_UNINTERRUPTIBLE:
241 case TH_STATE_RUNNING:
242 case TH_STATE_STOPPED:
243 case TH_STATE_WAITING:
244 case TH_STATE_HALTED:
250 struct thread_basic_info *MachThread::GetBasicInfo() {
251 if (MachThread::GetBasicInfo(m_mach_port_number, &m_basic_info))
252 return &m_basic_info;
256 bool MachThread::GetBasicInfo(thread_t thread,
257 struct thread_basic_info *basicInfoPtr) {
258 if (MachPortNumberIsValid(thread)) {
259 unsigned int info_count = THREAD_BASIC_INFO_COUNT;
260 kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
261 (thread_info_t)basicInfoPtr, &info_count);
262 if (err == KERN_SUCCESS)
265 ::memset(basicInfoPtr, 0, sizeof(struct thread_basic_info));
269 bool MachThread::ThreadIDIsValid(uint64_t thread) { return thread != 0; }
271 bool MachThread::MachPortNumberIsValid(thread_t thread) {
272 return thread != THREAD_NULL;
275 bool MachThread::GetRegisterState(int flavor, bool force) {
276 return m_arch_ap->GetRegisterState(flavor, force) == KERN_SUCCESS;
279 bool MachThread::SetRegisterState(int flavor) {
280 return m_arch_ap->SetRegisterState(flavor) == KERN_SUCCESS;
283 uint64_t MachThread::GetPC(uint64_t failValue) {
284 // Get program counter
285 return m_arch_ap->GetPC(failValue);
288 bool MachThread::SetPC(uint64_t value) {
289 // Set program counter
290 return m_arch_ap->SetPC(value);
293 uint64_t MachThread::GetSP(uint64_t failValue) {
295 return m_arch_ap->GetSP(failValue);
298 nub_process_t MachThread::ProcessID() const {
300 return m_process->ProcessID();
301 return INVALID_NUB_PROCESS;
304 void MachThread::Dump(uint32_t index) {
305 const char *thread_run_state = NULL;
307 switch (m_basic_info.run_state) {
308 case TH_STATE_RUNNING:
309 thread_run_state = "running";
310 break; // 1 thread is running normally
311 case TH_STATE_STOPPED:
312 thread_run_state = "stopped";
313 break; // 2 thread is stopped
314 case TH_STATE_WAITING:
315 thread_run_state = "waiting";
316 break; // 3 thread is waiting normally
317 case TH_STATE_UNINTERRUPTIBLE:
318 thread_run_state = "uninter";
319 break; // 4 thread is in an uninterruptible wait
320 case TH_STATE_HALTED:
321 thread_run_state = "halted ";
322 break; // 5 thread is halted at a
324 thread_run_state = "???";
329 "[%3u] #%3u tid: 0x%8.8" PRIx64 ", pc: 0x%16.16" PRIx64
330 ", sp: 0x%16.16" PRIx64
331 ", user: %d.%6.6d, system: %d.%6.6d, cpu: %2d, policy: %2d, run_state: "
332 "%2d (%s), flags: %2d, suspend_count: %2d (current %2d), sleep_time: %d",
333 index, m_seq_id, m_unique_id, GetPC(INVALID_NUB_ADDRESS),
334 GetSP(INVALID_NUB_ADDRESS), m_basic_info.user_time.seconds,
335 m_basic_info.user_time.microseconds, m_basic_info.system_time.seconds,
336 m_basic_info.system_time.microseconds, m_basic_info.cpu_usage,
337 m_basic_info.policy, m_basic_info.run_state, thread_run_state,
338 m_basic_info.flags, m_basic_info.suspend_count, m_suspend_count,
339 m_basic_info.sleep_time);
340 // DumpRegisterState(0);
343 void MachThread::ThreadWillResume(const DNBThreadResumeAction *thread_action,
344 bool others_stopped) {
345 if (thread_action->addr != INVALID_NUB_ADDRESS)
346 SetPC(thread_action->addr);
348 SetState(thread_action->state);
349 switch (thread_action->state) {
351 case eStateSuspended:
352 assert(others_stopped == false);
358 Resume(others_stopped);
363 m_arch_ap->ThreadWillResume();
364 m_stop_exception.Clear();
367 DNBBreakpoint *MachThread::CurrentBreakpoint() {
368 return m_process->Breakpoints().FindByAddress(GetPC());
371 bool MachThread::ShouldStop(bool &step_more) {
372 // See if this thread is at a breakpoint?
373 DNBBreakpoint *bp = CurrentBreakpoint();
376 // This thread is sitting at a breakpoint, ask the breakpoint
377 // if we should be stopping here.
380 if (m_arch_ap->StepNotComplete()) {
384 // The thread state is used to let us know what the thread was
385 // trying to do. MachThread::ThreadWillResume() will set the
386 // thread state to various values depending if the thread was
387 // the current thread and if it was to be single stepped, or
389 if (GetState() == eStateRunning) {
390 // If our state is running, then we should continue as we are in
391 // the process of stepping over a breakpoint.
394 // Stop if we have any kind of valid exception for this
396 if (GetStopException().IsValid())
402 bool MachThread::IsStepping() { return GetState() == eStateStepping; }
404 bool MachThread::ThreadDidStop() {
405 // This thread has existed prior to resuming under debug nub control,
406 // and has just been stopped. Do any cleanup that needs to be done
409 // The thread state and breakpoint will still have the same values
410 // as they had prior to resuming the thread, so it makes it easy to check
411 // if we were trying to step a thread, or we tried to resume while being
414 // When this method gets called, the process state is still in the
415 // state it was in while running so we can act accordingly.
416 m_arch_ap->ThreadDidStop();
418 // We may have suspended this thread so the primary thread could step
419 // without worrying about race conditions, so lets restore our suspend
421 RestoreSuspendCountAfterStop();
423 // Update the basic information for a thread
424 MachThread::GetBasicInfo(m_mach_port_number, &m_basic_info);
426 if (m_basic_info.suspend_count > 0)
427 SetState(eStateSuspended);
429 SetState(eStateStopped);
433 bool MachThread::NotifyException(MachException::Data &exc) {
434 // Allow the arch specific protocol to process (MachException::Data &)exc
435 // first before possible reassignment of m_stop_exception with exc.
436 // See also MachThread::GetStopException().
437 bool handled = m_arch_ap->NotifyException(exc);
439 if (m_stop_exception.IsValid()) {
440 // We may have more than one exception for a thread, but we need to
441 // only remember the one that we will say is the reason we stopped.
442 // We may have been single stepping and also gotten a signal exception,
443 // so just remember the most pertinent one.
444 if (m_stop_exception.IsBreakpoint())
445 m_stop_exception = exc;
447 m_stop_exception = exc;
453 nub_state_t MachThread::GetState() {
454 // If any other threads access this we will need a mutex for it
455 PTHREAD_MUTEX_LOCKER(locker, m_state_mutex);
459 void MachThread::SetState(nub_state_t state) {
460 PTHREAD_MUTEX_LOCKER(locker, m_state_mutex);
462 DNBLogThreadedIf(LOG_THREAD,
463 "MachThread::SetState ( %s ) for tid = 0x%8.8" PRIx64 "",
464 DNBStateAsString(state), m_unique_id);
467 nub_size_t MachThread::GetNumRegistersInSet(nub_size_t regSet) const {
468 if (regSet < m_num_reg_sets)
469 return m_reg_sets[regSet].num_registers;
473 const char *MachThread::GetRegisterSetName(nub_size_t regSet) const {
474 if (regSet < m_num_reg_sets)
475 return m_reg_sets[regSet].name;
479 const DNBRegisterInfo *MachThread::GetRegisterInfo(nub_size_t regSet,
480 nub_size_t regIndex) const {
481 if (regSet < m_num_reg_sets)
482 if (regIndex < m_reg_sets[regSet].num_registers)
483 return &m_reg_sets[regSet].registers[regIndex];
486 void MachThread::DumpRegisterState(nub_size_t regSet) {
487 if (regSet == REGISTER_SET_ALL) {
488 for (regSet = 1; regSet < m_num_reg_sets; regSet++)
489 DumpRegisterState(regSet);
491 if (m_arch_ap->RegisterSetStateIsValid((int)regSet)) {
492 const size_t numRegisters = GetNumRegistersInSet(regSet);
493 uint32_t regIndex = 0;
494 DNBRegisterValueClass reg;
495 for (regIndex = 0; regIndex < numRegisters; ++regIndex) {
496 if (m_arch_ap->GetRegisterValue((uint32_t)regSet, regIndex, ®)) {
497 reg.Dump(NULL, NULL);
501 DNBLog("%s: registers are not currently valid.",
502 GetRegisterSetName(regSet));
507 const DNBRegisterSetInfo *
508 MachThread::GetRegisterSetInfo(nub_size_t *num_reg_sets) const {
509 *num_reg_sets = m_num_reg_sets;
510 return &m_reg_sets[0];
513 bool MachThread::GetRegisterValue(uint32_t set, uint32_t reg,
514 DNBRegisterValue *value) {
515 return m_arch_ap->GetRegisterValue(set, reg, value);
518 bool MachThread::SetRegisterValue(uint32_t set, uint32_t reg,
519 const DNBRegisterValue *value) {
520 return m_arch_ap->SetRegisterValue(set, reg, value);
523 nub_size_t MachThread::GetRegisterContext(void *buf, nub_size_t buf_len) {
524 return m_arch_ap->GetRegisterContext(buf, buf_len);
527 nub_size_t MachThread::SetRegisterContext(const void *buf, nub_size_t buf_len) {
528 return m_arch_ap->SetRegisterContext(buf, buf_len);
531 uint32_t MachThread::SaveRegisterState() {
532 return m_arch_ap->SaveRegisterState();
534 bool MachThread::RestoreRegisterState(uint32_t save_id) {
535 return m_arch_ap->RestoreRegisterState(save_id);
538 uint32_t MachThread::EnableHardwareBreakpoint(const DNBBreakpoint *bp) {
539 if (bp != NULL && bp->IsBreakpoint())
540 return m_arch_ap->EnableHardwareBreakpoint(bp->Address(), bp->ByteSize());
541 return INVALID_NUB_HW_INDEX;
544 uint32_t MachThread::EnableHardwareWatchpoint(const DNBBreakpoint *wp,
545 bool also_set_on_task) {
546 if (wp != NULL && wp->IsWatchpoint())
547 return m_arch_ap->EnableHardwareWatchpoint(
548 wp->Address(), wp->ByteSize(), wp->WatchpointRead(),
549 wp->WatchpointWrite(), also_set_on_task);
550 return INVALID_NUB_HW_INDEX;
553 bool MachThread::RollbackTransForHWP() {
554 return m_arch_ap->RollbackTransForHWP();
557 bool MachThread::FinishTransForHWP() { return m_arch_ap->FinishTransForHWP(); }
559 bool MachThread::DisableHardwareBreakpoint(const DNBBreakpoint *bp) {
560 if (bp != NULL && bp->IsHardware())
561 return m_arch_ap->DisableHardwareBreakpoint(bp->GetHardwareIndex());
565 bool MachThread::DisableHardwareWatchpoint(const DNBBreakpoint *wp,
566 bool also_set_on_task) {
567 if (wp != NULL && wp->IsHardware())
568 return m_arch_ap->DisableHardwareWatchpoint(wp->GetHardwareIndex(),
573 uint32_t MachThread::NumSupportedHardwareWatchpoints() const {
574 return m_arch_ap->NumSupportedHardwareWatchpoints();
577 bool MachThread::GetIdentifierInfo() {
578 // Don't try to get the thread info once and cache it for the life of the
579 // thread. It changes over time, for instance
580 // if the thread name changes, then the thread_handle also changes... So you
581 // have to refetch it every time.
582 mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
583 kern_return_t kret = ::thread_info(m_mach_port_number, THREAD_IDENTIFIER_INFO,
584 (thread_info_t)&m_ident_info, &count);
585 return kret == KERN_SUCCESS;
590 const char *MachThread::GetName() {
591 if (GetIdentifierInfo()) {
592 int len = ::proc_pidinfo(m_process->ProcessID(), PROC_PIDTHREADINFO,
593 m_ident_info.thread_handle, &m_proc_threadinfo,
594 sizeof(m_proc_threadinfo));
596 if (len && m_proc_threadinfo.pth_name[0])
597 return m_proc_threadinfo.pth_name;
603 MachThread::GetGloballyUniqueThreadIDForMachPortID(thread_t mach_port_id) {
605 thread_identifier_info_data_t tident;
606 mach_msg_type_number_t tident_count = THREAD_IDENTIFIER_INFO_COUNT;
607 kr = thread_info(mach_port_id, THREAD_IDENTIFIER_INFO, (thread_info_t)&tident,
609 if (kr != KERN_SUCCESS) {
612 return tident.thread_id;
615 nub_addr_t MachThread::GetPThreadT() {
616 nub_addr_t pthread_t_value = INVALID_NUB_ADDRESS;
617 if (MachPortNumberIsValid(m_mach_port_number)) {
619 thread_identifier_info_data_t tident;
620 mach_msg_type_number_t tident_count = THREAD_IDENTIFIER_INFO_COUNT;
621 kr = thread_info(m_mach_port_number, THREAD_IDENTIFIER_INFO,
622 (thread_info_t)&tident, &tident_count);
623 if (kr == KERN_SUCCESS) {
624 // Dereference thread_handle to get the pthread_t value for this thread.
627 if (m_process->ReadMemory(tident.thread_handle, 8, &addr) == 8) {
629 pthread_t_value = addr;
634 if (m_process->ReadMemory(tident.thread_handle, 4, &addr) == 4) {
636 pthread_t_value = addr;
642 return pthread_t_value;
645 // Return this thread's TSD (Thread Specific Data) address.
646 // This is computed based on this thread's pthread_t value.
648 // We compute the TSD from the pthread_t by one of two methods.
650 // If plo_pthread_tsd_base_offset is non-zero, this is a simple offset that we
652 // the pthread_t to get the TSD base address.
654 // Else we read a pointer from memory at pthread_t +
655 // plo_pthread_tsd_base_address_offset and
656 // that gives us the TSD address.
658 // These plo_pthread_tsd_base values must be read out of libpthread by lldb &
659 // provided to debugserver.
662 MachThread::GetTSDAddressForThread(uint64_t plo_pthread_tsd_base_address_offset,
663 uint64_t plo_pthread_tsd_base_offset,
664 uint64_t plo_pthread_tsd_entry_size) {
665 nub_addr_t tsd_addr = INVALID_NUB_ADDRESS;
666 nub_addr_t pthread_t_value = GetPThreadT();
667 if (plo_pthread_tsd_base_offset != 0 &&
668 plo_pthread_tsd_base_offset != INVALID_NUB_ADDRESS) {
669 tsd_addr = pthread_t_value + plo_pthread_tsd_base_offset;
671 if (plo_pthread_tsd_entry_size == 4) {
673 if (m_process->ReadMemory(pthread_t_value +
674 plo_pthread_tsd_base_address_offset,
681 if (plo_pthread_tsd_entry_size == 4) {
683 if (m_process->ReadMemory(pthread_t_value +
684 plo_pthread_tsd_base_address_offset,
695 nub_addr_t MachThread::GetDispatchQueueT() {
696 nub_addr_t dispatch_queue_t_value = INVALID_NUB_ADDRESS;
697 if (MachPortNumberIsValid(m_mach_port_number)) {
699 thread_identifier_info_data_t tident;
700 mach_msg_type_number_t tident_count = THREAD_IDENTIFIER_INFO_COUNT;
701 kr = thread_info(m_mach_port_number, THREAD_IDENTIFIER_INFO,
702 (thread_info_t)&tident, &tident_count);
703 if (kr == KERN_SUCCESS && tident.dispatch_qaddr != 0 &&
704 tident.dispatch_qaddr != INVALID_NUB_ADDRESS) {
705 // Dereference dispatch_qaddr to get the dispatch_queue_t value for this
706 // thread's queue, if any.
709 if (m_process->ReadMemory(tident.dispatch_qaddr, 8, &addr) == 8) {
711 dispatch_queue_t_value = addr;
715 if (m_process->ReadMemory(tident.dispatch_qaddr, 4, &addr) == 4) {
717 dispatch_queue_t_value = addr;
722 return dispatch_queue_t_value;
725 ThreadInfo::QoS MachThread::GetRequestedQoS(nub_addr_t tsd,
726 uint64_t dti_qos_class_index) {
727 ThreadInfo::QoS qos_value;
728 if (MachPortNumberIsValid(m_mach_port_number) &&
729 m_pthread_qos_class_decode != nullptr) {
730 uint64_t pthread_priority_value = 0;
733 if (m_process->ReadMemory(tsd + (dti_qos_class_index * 8), 8, &pri) ==
735 pthread_priority_value = pri;
739 if (m_process->ReadMemory(tsd + (dti_qos_class_index * 4), 4, &pri) ==
741 pthread_priority_value = pri;
745 uint32_t requested_qos =
746 m_pthread_qos_class_decode(pthread_priority_value, NULL, NULL);
748 switch (requested_qos) {
749 // These constants from <pthread/qos.h>
751 qos_value.enum_value = requested_qos;
752 qos_value.constant_name = "QOS_CLASS_USER_INTERACTIVE";
753 qos_value.printable_name = "User Interactive";
756 qos_value.enum_value = requested_qos;
757 qos_value.constant_name = "QOS_CLASS_USER_INITIATED";
758 qos_value.printable_name = "User Initiated";
761 qos_value.enum_value = requested_qos;
762 qos_value.constant_name = "QOS_CLASS_DEFAULT";
763 qos_value.printable_name = "Default";
766 qos_value.enum_value = requested_qos;
767 qos_value.constant_name = "QOS_CLASS_UTILITY";
768 qos_value.printable_name = "Utility";
771 qos_value.enum_value = requested_qos;
772 qos_value.constant_name = "QOS_CLASS_BACKGROUND";
773 qos_value.printable_name = "Background";
776 qos_value.enum_value = requested_qos;
777 qos_value.constant_name = "QOS_CLASS_UNSPECIFIED";
778 qos_value.printable_name = "Unspecified";