Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions docs/design/datacontracts/Thread.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ record struct ThreadData (
TargetPointer AllocContextLimit;
TargetPointer Frame;
TargetPointer FirstNestedException;
TargetPointer TEB;
TargetPointer LastThrownObjectHandle;
TargetPointer NextThread;
);
Expand Down Expand Up @@ -97,7 +96,6 @@ The contract additionally depends on these data descriptors
| `Thread` | `Frame` | Pointer to current frame |
| `Thread` | `CachedStackBase` | Pointer to the base of the stack |
| `Thread` | `CachedStackLimit` | Pointer to the limit of the stack |
| `Thread` | `TEB` | Thread Environment Block pointer |
| `Thread` | `LastThrownObject` | Handle to last thrown exception object |
| `Thread` | `LinkNext` | Pointer to get next thread |
| `Thread` | `ExceptionTracker` | Pointer to exception tracking information |
Expand Down Expand Up @@ -184,7 +182,6 @@ ThreadData GetThreadData(TargetPointer address)
AllocContextPointer: allocContextPointer,
AllocContextLimit: allocContextLimit,
Frame: target.ReadPointer(address + /* Thread::Frame offset */),
TEB : /* Has Thread::TEB offset */ ? target.ReadPointer(address + /* Thread::TEB offset */) : TargetPointer.Null,
LastThrownObjectHandle : target.ReadPointer(address + /* Thread::LastThrownObject offset */),
FirstNestedException : firstNestedException,
NextThread: target.ReadPointer(address + /* Thread::LinkNext offset */) - threadLinkOffset;
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,10 +1227,6 @@ HRESULT ClrDataAccess::EnumMemDumpAllThreadsStack(CLRDataEnumMemoryFlags flags)
// Write out the Thread instance
DacEnumHostDPtrMem(pThread);

// @TODO
// write TEB pointed by the thread
// DacEnumHostDPtrMem(pThread->GetTEB());

// @TODO
// If CLR is hosted, we want to write out fiber data

Expand Down
6 changes: 2 additions & 4 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,9 @@ HRESULT ClrDataAccess::GetThreadData(CLRDATA_ADDRESS threadAddr, struct DacpThre
threadData->context = PTR_CDADDR(AppDomain::GetCurrentDomain());
threadData->domain = PTR_CDADDR(AppDomain::GetCurrentDomain());
threadData->lockCount = (DWORD)-1;
#ifndef TARGET_UNIX
threadData->teb = TO_CDADDR(thread->m_pTEB);
#else
// TEB is no longer provided by the runtime. Consumers should look up the TEB
// from the OS thread ID via the debugger's native API (e.g., IDebuggerServices::GetThreadTeb).
threadData->teb = (CLRDATA_ADDRESS)NULL;
#endif
threadData->lastThrownObjectHandle =
TO_CDADDR(thread->m_LastThrownObjectHandle);
threadData->nextThread =
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/datadescriptor/datadescriptor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ CDAC_TYPE_FIELD(Thread, TYPE(GCHandle), LastThrownObject, cdac_data<Thread>::Las
CDAC_TYPE_FIELD(Thread, T_POINTER, LinkNext, cdac_data<Thread>::Link)
CDAC_TYPE_FIELD(Thread, T_POINTER, ThreadLocalDataPtr, cdac_data<Thread>::ThreadLocalDataPtr)
#ifndef TARGET_UNIX
CDAC_TYPE_FIELD(Thread, T_POINTER, TEB, cdac_data<Thread>::TEB)
CDAC_TYPE_FIELD(Thread, T_POINTER, UEWatsonBucketTrackerBuckets, cdac_data<Thread>::UEWatsonBucketTrackerBuckets)
#endif
CDAC_TYPE_END(Thread)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,8 +1513,6 @@ void Thread::InitThread()
#ifndef TARGET_UNIX
(void) _controlfp_s( NULL, _RC_NEAR, _RC_CHOP|_RC_UP|_RC_DOWN|_RC_NEAR );

m_pTEB = (struct _NT_TIB*)NtCurrentTeb();

#endif // !TARGET_UNIX

if (m_CacheStackBase == 0)
Expand Down
15 changes: 0 additions & 15 deletions src/coreclr/vm/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -912,20 +912,6 @@ class Thread
InterpThreadContext* GetOrCreateInterpThreadContext();
#endif // FEATURE_INTERPRETER

#ifndef TARGET_UNIX
private:
_NT_TIB *m_pTEB;
public:
_NT_TIB *GetTEB() {
LIMITED_METHOD_CONTRACT;
return m_pTEB;
}
PEXCEPTION_REGISTRATION_RECORD *GetExceptionListPtr() {
WRAPPER_NO_CONTRACT;
return &GetTEB()->ExceptionList;
}
#endif // !TARGET_UNIX

inline void SetTHAllocContextObj(TypeHandle th) {LIMITED_METHOD_CONTRACT; m_thAllocContextObj = th; }

inline TypeHandle GetTHAllocContextObj() {LIMITED_METHOD_CONTRACT; return m_thAllocContextObj; }
Expand Down Expand Up @@ -3786,7 +3772,6 @@ struct cdac_data<Thread>
static constexpr size_t ProfilerFilterContext = offsetof(Thread, m_pProfilerFilterContext);
#endif // PROFILING_SUPPORTED
#ifndef TARGET_UNIX
static constexpr size_t TEB = offsetof(Thread, m_pTEB);
static constexpr size_t UEWatsonBucketTrackerBuckets = offsetof(Thread, m_ExceptionState) + offsetof(ThreadExceptionState, m_UEWatsonBucketTracker)
+ offsetof(EHWatsonBucketTracker, m_WatsonUnhandledInfo.m_pUnhandledBuckets);
#endif
Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/vm/threadsuspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2893,12 +2893,8 @@ BOOL Thread::RedirectThreadAtHandledJITCase(PFN_REDIRECTTARGET pTgt)
#ifdef _DEBUG
// In some rare cases the stack pointer may be outside the stack limits.
// SetThreadContext would fail assuming that we are trying to bypass CFG.
//
// NB: the check here is slightly more strict than what OS requires,
// but it is simple and uses only documented parts of TEB
auto pTeb = this->GetTEB();
void* stackPointer = (void*)GetSP(pCtx);
if ((stackPointer < pTeb->StackLimit) || (stackPointer > pTeb->StackBase))
if ((stackPointer < this->GetCachedStackLimit()) || (stackPointer > this->GetCachedStackBase()))
{
return (FALSE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public record struct ThreadData(
TargetPointer AllocContextLimit,
TargetPointer Frame,
TargetPointer FirstNestedException,
TargetPointer TEB,
TargetPointer LastThrownObjectHandle,
TargetPointer NextThread);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ ThreadData IThread.GetThreadData(TargetPointer threadPointer)
thread.RuntimeThreadLocals?.AllocContext.GCAllocationContext.Limit ?? TargetPointer.Null,
thread.Frame,
firstNestedException,
thread.TEB,
thread.LastThrownObject.Handle,
GetThreadFromLink(thread.LinkNext));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public Thread(Target target, TargetPointer address)
CachedStackBase = target.ReadPointerField(address, type, nameof(CachedStackBase));
CachedStackLimit = target.ReadPointerField(address, type, nameof(CachedStackLimit));

// TEB does not exist on certain platforms
TEB = target.ReadPointerFieldOrNull(address, type, nameof(TEB));
LastThrownObject = target.ProcessedData.GetOrAdd<ObjectHandle>(
target.ReadPointerField(address, type, nameof(LastThrownObject)));
LinkNext = target.ReadPointerField(address, type, nameof(LinkNext));
Expand All @@ -46,7 +44,6 @@ public Thread(Target target, TargetPointer address)
public TargetPointer Frame { get; init; }
public TargetPointer CachedStackBase { get; init; }
public TargetPointer CachedStackLimit { get; init; }
public TargetPointer TEB { get; init; }
public ObjectHandle LastThrownObject { get; init; }
public TargetPointer LinkNext { get; init; }
public TargetPointer ExceptionTracker { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4266,7 +4266,7 @@ int ISOSDacInterface.GetThreadData(ClrDataAddress thread, DacpThreadData* data)
data->lockCount = -1; // Always set to -1 - lock count was .NET Framework and no longer needed
data->pFrame = threadData.Frame.ToClrDataAddress(_target);
data->firstNestedException = threadData.FirstNestedException.ToClrDataAddress(_target);
data->teb = threadData.TEB.ToClrDataAddress(_target);
data->teb = 0; // TEB is no longer provided by the DAC - consumers should look it up from the OS thread ID
data->lastThrownObjectHandle = threadData.LastThrownObjectHandle.ToClrDataAddress(_target);
data->nextThread = threadData.NextThread.ToClrDataAddress(_target);
}
Expand Down Expand Up @@ -4295,7 +4295,6 @@ int ISOSDacInterface.GetThreadData(ClrDataAddress thread, DacpThreadData* data)
Debug.Assert(data->lockCount == dataLocal.lockCount, $"cDAC: {data->lockCount}, DAC: {dataLocal.lockCount}");
Debug.Assert(data->pFrame == dataLocal.pFrame, $"cDAC: {data->pFrame:x}, DAC: {dataLocal.pFrame:x}");
Debug.Assert(data->firstNestedException == dataLocal.firstNestedException, $"cDAC: {data->firstNestedException:x}, DAC: {dataLocal.firstNestedException:x}");
Debug.Assert(data->teb == dataLocal.teb, $"cDAC: {data->teb:x}, DAC: {dataLocal.teb:x}");
Debug.Assert(data->lastThrownObjectHandle == dataLocal.lastThrownObjectHandle, $"cDAC: {data->lastThrownObjectHandle:x}, DAC: {dataLocal.lastThrownObjectHandle:x}");
Debug.Assert(data->nextThread == dataLocal.nextThread, $"cDAC: {data->nextThread:x}, DAC: {dataLocal.nextThread:x}");
}
Expand Down
2 changes: 0 additions & 2 deletions src/native/managed/cdac/tests/ClrDataExceptionStateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ private static (TestPlaceholderTarget Target, IXCLRDataTask Task) CreateTargetWi
AllocContextLimit: TargetPointer.Null,
Frame: TargetPointer.Null,
FirstNestedException: firstNestedException,
TEB: TargetPointer.Null,
LastThrownObjectHandle: lastThrownObjectHandle,
NextThread: TargetPointer.Null));

Expand Down Expand Up @@ -464,7 +463,6 @@ private static (IXCLRDataTask Task, string ExpectedMessage) CreateTargetWithLast
AllocContextLimit: TargetPointer.Null,
Frame: TargetPointer.Null,
FirstNestedException: firstNestedException,
TEB: TargetPointer.Null,
LastThrownObjectHandle: lastThrownObjectHandle,
NextThread: TargetPointer.Null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ internal sealed class MockThread : TypedView
private const string FrameFieldName = "Frame";
private const string CachedStackBaseFieldName = "CachedStackBase";
private const string CachedStackLimitFieldName = "CachedStackLimit";
private const string TEBFieldName = "TEB";
private const string LastThrownObjectFieldName = "LastThrownObject";
private const string LinkNextFieldName = "LinkNext";
private const string ExceptionTrackerFieldName = "ExceptionTracker";
Expand All @@ -198,7 +197,6 @@ public static Layout<MockThread> CreateLayout(MockTarget.Architecture architectu
.AddPointerField(FrameFieldName)
.AddPointerField(CachedStackBaseFieldName)
.AddPointerField(CachedStackLimitFieldName)
.AddPointerField(TEBFieldName)
.AddPointerField(LastThrownObjectFieldName)
.AddPointerField(LinkNextFieldName)
.AddPointerField(ExceptionTrackerFieldName)
Expand Down
Loading