VirtualBox

Changeset 52457 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Aug 22, 2014 9:05:42 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95670
Message:

IPRT: Tell the windows debugger the name of our threads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r48935 r52457  
    5858*******************************************************************************/
    5959static unsigned __stdcall rtThreadNativeMain(void *pvArgs);
     60static void rtThreadWinTellDebuggerThreadName(uint32_t idThread, const char *pszName);
    6061
    6162
     
    107108    if (!TlsSetValue(g_dwSelfTLS, pThread))
    108109        return VERR_FAILED_TO_SET_SELF_TLS;
     110    if (IsDebuggerPresent())
     111        rtThreadWinTellDebuggerThreadName(GetCurrentThreadId(), pThread->szName);
    109112    return VINF_SUCCESS;
     113}
     114
     115
     116DECLHIDDEN(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 */
     132static 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    }
    110149}
    111150
     
    208247    if (!TlsSetValue(g_dwSelfTLS, pThread))
    209248        AssertReleaseMsgFailed(("failed to set self TLS. lasterr=%d thread '%s'\n", GetLastError(), pThread->szName));
     249    if (IsDebuggerPresent())
     250        rtThreadWinTellDebuggerThreadName(dwThreadId, &pThread->szName[0]);
    210251
    211252    int rc = rtThreadMain(pThread, dwThreadId, &pThread->szName[0]);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette