Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/coreclr/debug/runtimeinfo/datadescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ CDAC_GLOBAL(MethodDescAlignment, uint64, MethodDesc::ALIGNMENT)
CDAC_GLOBAL(ObjectHeaderSize, uint64, OBJHEADER_SIZE)
CDAC_GLOBAL(SyncBlockValueToObjectOffset, uint16, OBJHEADER_SIZE - cdac_data<ObjHeader>::SyncBlockValue)
CDAC_GLOBAL(StubCodeBlockLast, uint8, STUB_CODE_BLOCK_LAST)
CDAC_GLOBAL(TlsOutOfIndexes, uint32, TLS_OUT_OF_INDEXES)
CDAC_GLOBAL_POINTER(ArrayBoundsZero, cdac_data<ArrayBase>::ArrayBoundsZero)
CDAC_GLOBAL_POINTER(ExceptionMethodTable, &::g_pExceptionClass)
CDAC_GLOBAL_POINTER(FreeObjectMethodTable, &::g_pFreeObjectMethodTable)
Expand All @@ -968,6 +969,10 @@ CDAC_GLOBAL_POINTER(StringMethodTable, &::g_pStringClass)
CDAC_GLOBAL_POINTER(SyncTableEntries, &::g_pSyncTable)
CDAC_GLOBAL_POINTER(MiniMetaDataBuffAddress, &::g_MiniMetaDataBuffAddress)
CDAC_GLOBAL_POINTER(MiniMetaDataBuffMaxSize, &::g_MiniMetaDataBuffMaxSize)
CDAC_GLOBAL_POINTER(OffsetOfCurrentThreadInfo, &::g_offsetOfCurrentThreadInfo)
#ifdef TARGET_WINDOWS
CDAC_GLOBAL_POINTER(TlsIndexBase, &::_tls_index)
#endif // TARGET_WINDOWS
#ifdef STRESS_LOG
CDAC_GLOBAL(StressLogEnabled, uint8, 1)
CDAC_GLOBAL_POINTER(StressLog, &g_pStressLog)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ DEFINE_DACVAR(PTR_SystemDomain, SystemDomain__m_pSystemDomain, SystemDomain::m_p
DEFINE_DACVAR(DWORD, dac__g_debuggerWordTLSIndex, g_debuggerWordTLSIndex)
#endif
DEFINE_DACVAR(DWORD, dac__g_TlsIndex, g_TlsIndex)
DEFINE_DACVAR(DWORD, dac__g_offsetOfCurrentThreadInfo, g_offsetOfCurrentThreadInfo)

#ifdef FEATURE_EH_FUNCLETS
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pEHClass, ::g_pEHClass)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,13 +1142,13 @@ void InitThreadManager()
#ifndef TARGET_UNIX
_ASSERTE(GetThreadNULLOk() == NULL);

size_t offsetOfCurrentThreadInfo = Thread::GetOffsetOfThreadStatic(&t_CurrentThreadInfo);
g_offsetOfCurrentThreadInfo = (DWORD)Thread::GetOffsetOfThreadStatic(&t_CurrentThreadInfo);

_ASSERTE(offsetOfCurrentThreadInfo < 0x8000);
_ASSERTE(g_offsetOfCurrentThreadInfo < 0x8000);
_ASSERTE(_tls_index < 0x10000);

// Save t_CurrentThreadInfo location for debugger
SetIlsIndex((DWORD)(_tls_index + (offsetOfCurrentThreadInfo << 16) + 0x80000000));
SetIlsIndex((DWORD)(_tls_index + (g_offsetOfCurrentThreadInfo << 16) + 0x80000000));

_ASSERTE(g_TrapReturningThreads == 0);
#endif // !TARGET_UNIX
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ GPTR_IMPL(RCWCleanupList,g_pRCWCleanupList);
GVAL_IMPL_INIT(DWORD, g_debuggerWordTLSIndex, TLS_OUT_OF_INDEXES);
#endif
GVAL_IMPL_INIT(DWORD, g_TlsIndex, TLS_OUT_OF_INDEXES);
GVAL_IMPL_INIT(DWORD, g_offsetOfCurrentThreadInfo, 0);

MethodTable* g_pCastHelpers;
#ifdef FEATURE_EH_FUNCLETS
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ GPTR_DECL(MethodDesc, g_pObjectFinalizerMD);
GVAL_DECL(DWORD, g_debuggerWordTLSIndex);
#endif
GVAL_DECL(DWORD, g_TlsIndex);
GVAL_DECL(DWORD, g_offsetOfCurrentThreadInfo);

#ifdef FEATURE_EH_FUNCLETS
GPTR_DECL(MethodTable, g_pEHClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static class Globals

public const string MiniMetaDataBuffAddress = nameof(MiniMetaDataBuffAddress);
public const string MiniMetaDataBuffMaxSize = nameof(MiniMetaDataBuffMaxSize);
public const string OffsetOfCurrentThreadInfo = nameof(OffsetOfCurrentThreadInfo);
public const string TlsIndexBase = nameof(TlsIndexBase);

public const string StressLogEnabled = nameof(StressLogEnabled);
public const string StressLogHasModuleTable = nameof(StressLogHasModuleTable);
Expand All @@ -51,6 +53,7 @@ public static class Globals

public const string ExecutionManagerCodeRangeMapAddress = nameof(ExecutionManagerCodeRangeMapAddress);
public const string StubCodeBlockLast = nameof(StubCodeBlockLast);
public const string TlsOutOfIndexes = nameof(TlsOutOfIndexes);
public const string PlatformMetadata = nameof(PlatformMetadata);
public const string ProfilerControlBlock = nameof(ProfilerControlBlock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1644,8 +1644,45 @@ int ISOSDacInterface.GetThreadStoreData(DacpThreadStoreData* data)
}

int ISOSDacInterface.GetTLSIndex(uint* pIndex)
=> _legacyImpl is not null ? _legacyImpl.GetTLSIndex(pIndex) : HResults.E_NOTIMPL;
{
if (pIndex == null)
return HResults.E_INVALIDARG;

int hr = HResults.S_OK;
try
{
uint TlsOutOfIndexes = _target.ReadGlobal<uint>(Constants.Globals.TlsOutOfIndexes);
uint TlsIndexBase = _target.Read<uint>(_target.ReadGlobalPointer(Constants.Globals.TlsIndexBase));
uint OffsetOfCurrentThreadInfo = _target.Read<uint>(_target.ReadGlobalPointer(Constants.Globals.OffsetOfCurrentThreadInfo));
uint CombinedTlsIndex = TlsIndexBase + (OffsetOfCurrentThreadInfo << 16) + 0x80000000;
if (CombinedTlsIndex == TlsOutOfIndexes)
{
*pIndex = 0;
hr = HResults.S_FALSE;
}
else
{
*pIndex = CombinedTlsIndex;
}
}
catch (System.Exception ex)
{
hr = ex.HResult;
}
#if DEBUG
if (_legacyImpl is not null)
{
uint indexLocal;
int hrLocal = _legacyImpl.GetTLSIndex(&indexLocal);
Debug.Assert(hrLocal == hr, $"cDAC: {hr:x}, DAC: {hrLocal:x}");
if (hr == HResults.S_OK || hr == HResults.S_FALSE)
{
Debug.Assert(*pIndex == indexLocal);
}
}
#endif
return hr;
}
int ISOSDacInterface.GetUsefulGlobals(DacpUsefulGlobalsData* data)
{
if (data == null)
Expand Down
Loading