Changeset 52457 in vbox for trunk/src/VBox
- Timestamp:
- Aug 22, 2014 9:05:42 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95670
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/thread.cpp
r48935 r52457 1538 1538 1539 1539 #endif /* IPRT_WITH_GENERIC_TLS */ 1540 1541 1542 #if defined(RT_OS_WINDOWS) && defined(IN_RING3) 1543 1544 /** 1545 * Thread enumeration callback for RTThreadNameThreads 1546 */ 1547 static DECLCALLBACK(int) rtThreadNameThreadCallback(PAVLPVNODECORE pNode, void *pvUser) 1548 { 1549 PRTTHREADINT pThread = (PRTTHREADINT)pNode; 1550 rtThreadNativeInformDebugger(pThread); 1551 return 0; 1552 } 1553 1554 /** 1555 * A function that can be called from the windows debugger to get the names of 1556 * all threads when attaching to a process. 1557 * 1558 * Usage: .call VBoxRT!RTThreadNameThreads() 1559 * 1560 * @returns 0 1561 * @remarks Do not call from source code as it skips locks. 1562 */ 1563 extern "C" RTDECL(int) RTThreadNameThreads(void); 1564 RTDECL(int) RTThreadNameThreads(void) 1565 { 1566 return RTAvlPVDoWithAll(&g_ThreadTree, true /* fFromLeft*/, rtThreadNameThreadCallback, NULL); 1567 } 1568 1569 #endif -
trunk/src/VBox/Runtime/include/internal/thread.h
r46593 r52457 199 199 */ 200 200 DECLHIDDEN(void) rtThreadNativeDetach(void); 201 202 /** 203 * Internal function for informing the debugger about a thread. 204 * @param pThread The thread. May differ from the calling thread. 205 */ 206 DECLHIDDEN(void) rtThreadNativeInformDebugger(PRTTHREADINT pThread); 201 207 # endif 202 #endif /* !IN_RING0*/208 #endif /* IN_RING3 */ 203 209 204 210 -
trunk/src/VBox/Runtime/r3/win/thread-win.cpp
r48935 r52457 58 58 *******************************************************************************/ 59 59 static unsigned __stdcall rtThreadNativeMain(void *pvArgs); 60 static void rtThreadWinTellDebuggerThreadName(uint32_t idThread, const char *pszName); 60 61 61 62 … … 107 108 if (!TlsSetValue(g_dwSelfTLS, pThread)) 108 109 return VERR_FAILED_TO_SET_SELF_TLS; 110 if (IsDebuggerPresent()) 111 rtThreadWinTellDebuggerThreadName(GetCurrentThreadId(), pThread->szName); 109 112 return VINF_SUCCESS; 113 } 114 115 116 DECLHIDDEN(void) rtThreadNativeInformDebugger(PRTTHREADINT pThread) 117 { 118 rtThreadWinTellDebuggerThreadName((uint32_t)(uintptr_t)pThread->Core.Key, pThread->szName); 119 } 120 121 122 /** 123 * Communicates the thread name to the debugger, if we're begin debugged that 124 * is. 125 * 126 * See http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx for debugger 127 * interface details. 128 * 129 * @param idThread The thread ID. UINT32_MAX for current thread. 130 * @param pszName The name. 131 */ 132 static void rtThreadWinTellDebuggerThreadName(uint32_t idThread, const char *pszName) 133 { 134 struct 135 { 136 uint32_t uType; 137 const char *pszName; 138 uint32_t idThread; 139 uint32_t fFlags; 140 } Pkg = { 0x1000, pszName, idThread, 0 }; 141 __try 142 { 143 RaiseException(0x406d1388, 0, sizeof(Pkg)/sizeof(ULONG_PTR), (ULONG_PTR *)&Pkg); 144 } 145 __except(EXCEPTION_CONTINUE_EXECUTION) 146 { 147 148 } 110 149 } 111 150 … … 208 247 if (!TlsSetValue(g_dwSelfTLS, pThread)) 209 248 AssertReleaseMsgFailed(("failed to set self TLS. lasterr=%d thread '%s'\n", GetLastError(), pThread->szName)); 249 if (IsDebuggerPresent()) 250 rtThreadWinTellDebuggerThreadName(dwThreadId, &pThread->szName[0]); 210 251 211 252 int rc = rtThreadMain(pThread, dwThreadId, &pThread->szName[0]);
Note:
See TracChangeset
for help on using the changeset viewer.