Include host ID in XThread name for easier debugging

This commit is contained in:
Dr. Chat 2015-07-24 18:42:30 -05:00
parent e7def962f3
commit eac3243907
2 changed files with 7 additions and 4 deletions

View File

@ -62,10 +62,6 @@ XThread::XThread(KernelState* kernel_state, uint32_t stack_size,
apc_list_ = new NativeList(kernel_state->memory()); apc_list_ = new NativeList(kernel_state->memory());
char thread_name[32];
snprintf(thread_name, xe::countof(thread_name), "XThread%04X", handle());
set_name(thread_name);
// The kernel does not take a reference. We must unregister in the dtor. // The kernel does not take a reference. We must unregister in the dtor.
kernel_state_->RegisterThread(this); kernel_state_->RegisterThread(this);
} }
@ -92,6 +88,7 @@ XThread::~XThread() {
} }
bool XThread::IsInThread(XThread* other) { return current_thread_tls == other; } bool XThread::IsInThread(XThread* other) { return current_thread_tls == other; }
bool XThread::IsInThread() { return current_thread_tls != nullptr; }
XThread* XThread::GetCurrentThread() { XThread* XThread::GetCurrentThread() {
XThread* thread = current_thread_tls; XThread* thread = current_thread_tls;
@ -322,6 +319,11 @@ X_STATUS XThread::Create() {
} }
thread_->set_affinity_mask(proc_mask); thread_->set_affinity_mask(proc_mask);
// Set the thread name based on host ID (for easier debugging)
char thread_name[32];
snprintf(thread_name, xe::countof(thread_name), "XThread%04X (%04X)", handle(), thread_->id());
set_name(thread_name);
if (creation_params_.creation_flags & 0x60) { if (creation_params_.creation_flags & 0x60) {
thread_->set_priority(creation_params_.creation_flags & 0x20 ? 1 : 0); thread_->set_priority(creation_params_.creation_flags & 0x20 ? 1 : 0);
} }

View File

@ -103,6 +103,7 @@ class XThread : public XObject {
virtual ~XThread(); virtual ~XThread();
static bool IsInThread(XThread* other); static bool IsInThread(XThread* other);
static bool IsInThread();
static XThread* GetCurrentThread(); static XThread* GetCurrentThread();
static uint32_t GetCurrentThreadHandle(); static uint32_t GetCurrentThreadHandle();
static uint32_t GetCurrentThreadId(); static uint32_t GetCurrentThreadId();