Set the thread name when running under windbg or Visual Studio debugger.

git-svn-id: http://yate.null.ro/svn/yate/trunk@2755 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2009-07-09 15:34:54 +00:00
parent 4850f9077d
commit 259f204d39
1 changed files with 18 additions and 0 deletions

View File

@ -317,6 +317,24 @@ void ThreadPrivate::run()
if (m_name)
prctl(PR_SET_NAME,(unsigned long)m_name,0,0,0);
#endif
#endif
#ifdef _WINDOWS
#ifndef NDEBUG
if (m_name) {
struct {
DWORD dwType;
LPCSTR szName;
DWORD dwThreadID;
DWORD dwFlags;
} threadInfo;
threadInfo.dwType = 0x1000;
threadInfo.szName = m_name;
threadInfo.dwThreadID = (DWORD)-1;
threadInfo.dwFlags = 0;
__try { RaiseException(0x406D1388, 0, sizeof(threadInfo)/sizeof(DWORD), (DWORD*)&threadInfo); }
__except (EXCEPTION_CONTINUE_EXECUTION) { }
}
#endif
#endif
// FIXME: possible race if public object is destroyed during thread startup