summaryrefslogtreecommitdiff
path: root/indra/llcommon/llthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llthread.cpp')
-rwxr-xr-xindra/llcommon/llthread.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index 166a4eb26d..e0f53fb9c4 100755
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -39,6 +39,39 @@
#include <sched.h>
#endif
+
+#ifdef LL_WINDOWS
+const DWORD MS_VC_EXCEPTION=0x406D1388;
+
+#pragma pack(push,8)
+typedef struct tagTHREADNAME_INFO
+{
+ DWORD dwType; // Must be 0x1000.
+ const char* szName; // Pointer to name (in user addr space).
+ DWORD dwThreadID; // Thread ID (-1=caller thread).
+ DWORD dwFlags; // Reserved for future use, must be zero.
+} THREADNAME_INFO;
+#pragma pack(pop)
+
+void SetThreadName( DWORD dwThreadID, const char* threadName)
+{
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = threadName;
+ info.dwThreadID = dwThreadID;
+ info.dwFlags = 0;
+
+ __try
+ {
+ RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info );
+ }
+ __except(EXCEPTION_CONTINUE_EXECUTION)
+ {
+ }
+}
+#endif
+
+
//----------------------------------------------------------------------------
// Usage:
// void run_func(LLThread* thread)
@@ -93,6 +126,11 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap
{
LLThread *threadp = (LLThread *)datap;
+#ifdef LL_WINDOWS
+ SetThreadName(-1, threadp->mName.c_str());
+#endif
+
+
LLTrace::ThreadRecorder thread_recorder(*LLTrace::get_master_thread_recorder());
#if !LL_DARWIN
@@ -224,6 +262,7 @@ void LLThread::start()
llwarns << "failed to start thread " << mName << llendl;
ll_apr_warn_status(status);
}
+
}
//============================================================================