diff options
author | Jan Kotas <jkotas@microsoft.com> | 2017-10-11 13:04:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-11 13:04:43 -0700 |
commit | 27a25bd37fa1fe6201c27709b1884e1b328f8beb (patch) | |
tree | 18b7773a7d8e18cca609417940804d8dff491da2 /src/debug/di | |
parent | d07f1b24c4a69e6a205f8510f3dcfae0ad96aae8 (diff) | |
download | coreclr-27a25bd37fa1fe6201c27709b1884e1b328f8beb.tar.gz coreclr-27a25bd37fa1fe6201c27709b1884e1b328f8beb.tar.bz2 coreclr-27a25bd37fa1fe6201c27709b1884e1b328f8beb.zip |
Delete !FEATURE_IMPLICIT_TLS (#14398)
Linux and Windows arm64 are using the regular C/C++ thread local statics. This change unifies the remaining Windows architectures to be on the same plan.
Diffstat (limited to 'src/debug/di')
-rw-r--r-- | src/debug/di/rspriv.h | 3 | ||||
-rw-r--r-- | src/debug/di/rsthread.cpp | 173 |
2 files changed, 3 insertions, 173 deletions
diff --git a/src/debug/di/rspriv.h b/src/debug/di/rspriv.h index e0489c53ad..de821f26a6 100644 --- a/src/debug/di/rspriv.h +++ b/src/debug/di/rspriv.h @@ -10609,11 +10609,10 @@ private: void CacheEEDebuggerWord(); HRESULT SetEEThreadValue(REMOTE_PTR EETlsValue); -#ifdef FEATURE_IMPLICIT_TLS + DWORD_PTR GetEEThreadValue(); REMOTE_PTR GetClrModuleTlsDataAddress(); REMOTE_PTR GetEETlsDataBlock(); -#endif public: HRESULT GetEEDebuggerWord(REMOTE_PTR *pValue); diff --git a/src/debug/di/rsthread.cpp b/src/debug/di/rsthread.cpp index aa85de83d8..cd5e62932a 100644 --- a/src/debug/di/rsthread.cpp +++ b/src/debug/di/rsthread.cpp @@ -2996,12 +2996,7 @@ HRESULT CordbUnmanagedThread::RestoreLeafSeh() // return value == 0 (assumed default, *pRead = false REMOTE_PTR CordbUnmanagedThread::GetPreDefTlsSlot(SIZE_T slot, bool * pRead) { -#ifdef FEATURE_IMPLICIT_TLS REMOTE_PTR pBlock = (REMOTE_PTR) GetEETlsDataBlock(); -#else - DebuggerIPCRuntimeOffsets *pRO = &(GetProcess()->m_runtimeOffsets); - REMOTE_PTR pBlock = (REMOTE_PTR) GetTlsSlot(pRO->m_TLSIndexOfPredefs); -#endif REMOTE_PTR data = 0; @@ -3036,164 +3031,6 @@ REMOTE_PTR CordbUnmanagedThread::GetPreDefTlsSlot(SIZE_T slot, bool * pRead) return 0; } -#ifndef FEATURE_IMPLICIT_TLS - -// Read the contents from a LS threads's TLS slot. -DWORD_PTR CordbUnmanagedThread::GetTlsSlot(SIZE_T slot) -{ - DWORD_PTR ret = 0; - - // Compute the address of the necessary TLS value. - if (FAILED(LoadTLSArrayPtr())) - { - return NULL; - } - - - void * pBase = NULL; - SIZE_T slotAdjusted = slot; - - if (slot < TLS_MINIMUM_AVAILABLE) - { - pBase = m_pTLSArray; - } - else if (slot < TLS_MINIMUM_AVAILABLE + TLS_EXPANSION_SLOTS) - { - pBase = m_pTLSExtendedArray; - slotAdjusted -= TLS_MINIMUM_AVAILABLE; - - // Expansion slot is lazily allocated. If we're trying to read from it, but hasn't been allocated, - // then the TLS slot is still the default value, which is 0 (NULL). - if (pBase == NULL) - { - return NULL; - } - } - else - { - // Slot is out of range. Shouldn't happen unless debuggee is corrupted. - _ASSERTE(!"Invalid TLS slot"); - return NULL; - } - - void *pEEThreadTLS = (BYTE*) pBase + (slotAdjusted * sizeof(void*)); - - - // Read the thread's TLS value. - HRESULT hr = GetProcess()->SafeReadStruct(PTR_TO_CORDB_ADDRESS(pEEThreadTLS), &ret); - if (FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CUT::GEETV: failed to read TLS value: computed addr=0x%p index=%d, err=%x\n", - pEEThreadTLS, slot, hr)); - - return NULL; - } - - LOG((LF_CORDB, LL_INFO1000000, "CUT::GEETV: EE Thread TLS value is 0x%p for thread 0x%x, slot 0x%x\n", ret, m_id, slot)); - - return ret; -} - -// This does a WriteProcessMemory to write to the debuggee's TLS slot allotted to EEThread -// -// Arguments: -// EETlsValue - the value to write to the remote TLS slot. -// -// Notes: -// The TLS slot is m_TLSIndex. -// -// This is very brittle because the OS can lazily allocates storage for TLS slots. -// In order to gaurantee the storage is available, it must have been written to by the debuggee. -// For managed threads, that's easy because the Thread* is already written to the slot. -// But for pure native threads where GetThread() == NULL, the storage may not yet be allocated. -// -// The saving grace is that the debuggee's hijack filters will force the TLS to be allocated before it -// sends a flare. -// -// Therefore, this function can only be called: -// 1) on a managed thread -// 2) on a native thread after that thread has been hijacked and sent a flare. -// -// This is brittle reasoning, but so is the rest of interop-debugging. -// -HRESULT CordbUnmanagedThread::SetEEThreadValue(REMOTE_PTR EETlsValue) -{ - FAIL_IF_NEUTERED(this); - - // Compute the address of the necessary TLS value. - DebuggerIPCRuntimeOffsets *pRO = &(GetProcess()->m_runtimeOffsets); - - // Compute the address of the necessary TLS value. - HRESULT hr = LoadTLSArrayPtr(); - if (FAILED(hr)) - { - return hr; - } - - - DWORD slot = (DWORD) pRO->m_TLSIndex; - - void * pBase = NULL; - SIZE_T slotAdjusted = slot; - if (slot < TLS_MINIMUM_AVAILABLE) - { - pBase = m_pTLSArray; - } - else if (slot < TLS_MINIMUM_AVAILABLE+TLS_EXPANSION_SLOTS) - { - pBase = m_pTLSExtendedArray; - slotAdjusted -= TLS_MINIMUM_AVAILABLE; - - // Expansion slot is lazily allocated. If we're trying to read from it, but hasn't been allocated, - // then the TLS slot is still the default value, which is 0. - if (pBase == NULL) - { - // See reasoning in header for why this should succeed. - _ASSERTE(!"Can't set to expansion slots because they haven't been allocated"); - return E_FAIL; - } - } - else - { - // Slot is out of range. Shouldn't happen unless debuggee is corrupted. - _ASSERTE(!"Invalid TLS slot"); - return E_INVALIDARG; - } - - - void *pEEThreadTLS = (BYTE*) pBase + (slotAdjusted * sizeof(void*)); - - - // Write the thread's TLS value. - hr = GetProcess()->SafeWriteStruct(PTR_TO_CORDB_ADDRESS(pEEThreadTLS), &EETlsValue); - - if (FAILED(hr)) - { - LOG((LF_CORDB, LL_INFO1000, "CUT::SEETV: failed to set TLS value: " - "computed addr=0x%p index=%d, err=%x\n", - pEEThreadTLS, pRO->m_TLSIndex, hr)); - - return hr; - } - - LOG((LF_CORDB, LL_INFO1000000, - "CUT::SEETV: EE Thread TLS value is now 0x%p for thread 0x%x\n", - EETlsValue, m_id)); - - return S_OK; -} -#else // FEATURE_IMPLICIT_TLS - -#ifdef DBG_TARGET_X86 -#define WINNT_OFFSETOF__TEB__ThreadLocalStoragePointer 0x2c -#elif defined(DBG_TARGET_AMD64) -#define WINNT_OFFSETOF__TEB__ThreadLocalStoragePointer 0x58 -#elif defined(DBG_TARGET_ARM) -#define WINNT_OFFSETOF__TEB__ThreadLocalStoragePointer 0x2c -#elif defined(DBG_TARGET_ARM64) -#define WINNT_OFFSETOF__TEB__ThreadLocalStoragePointer 0x58 -#endif - // sets the value of gCurrentThreadInfo.m_pThread HRESULT CordbUnmanagedThread::SetEEThreadValue(REMOTE_PTR EETlsValue) { @@ -3275,7 +3112,7 @@ REMOTE_PTR CordbUnmanagedThread::GetClrModuleTlsDataAddress() DWORD slot = (DWORD)(GetProcess()->m_runtimeOffsets.m_TLSIndex); REMOTE_PTR clrModuleTlsDataAddr; - hr = GetProcess()->SafeReadStruct(PTR_TO_CORDB_ADDRESS((BYTE*)tlsArrayAddr + slot * sizeof(void*)), &clrModuleTlsDataAddr); + hr = GetProcess()->SafeReadStruct(PTR_TO_CORDB_ADDRESS((BYTE*)tlsArrayAddr + (slot & 0xFFFF) * sizeof(void*)), &clrModuleTlsDataAddr); if (FAILED(hr)) { return NULL; @@ -3287,7 +3124,7 @@ REMOTE_PTR CordbUnmanagedThread::GetClrModuleTlsDataAddress() return NULL; } - return clrModuleTlsDataAddr; + return (BYTE*) clrModuleTlsDataAddr + ((slot & 0x7FFF0000) >> 16); } // gets the value of gCurrentThreadInfo.m_EETlsData @@ -3312,8 +3149,6 @@ REMOTE_PTR CordbUnmanagedThread::GetEETlsDataBlock() return ret; } -#endif // FEATURE_IMPLICIT_TLS - /* * CacheEEDebuggerWord * @@ -3337,11 +3172,7 @@ void CordbUnmanagedThread::CacheEEDebuggerWord() { LOG((LF_CORDB, LL_INFO1000, "CacheEEDW: Entered\n")); -#ifdef FEATURE_IMPLICIT_TLS REMOTE_PTR value = (REMOTE_PTR)GetEEThreadValue(); -#else - REMOTE_PTR value = (REMOTE_PTR)GetTlsSlot(GetProcess()->m_runtimeOffsets.m_TLSIndex); -#endif if ((((DWORD)value) & 0x1) == 1) { |