Skip to content

Commit

Permalink
Fix DAC getting alloc context for thread (#103610)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Jun 18, 2024
1 parent b8ef822 commit 5d1981e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ ClrDataAccess::GetThreadAllocData(CLRDATA_ADDRESS addr, struct DacpAllocData *da

Thread* thread = PTR_Thread(TO_TADDR(addr));

gc_alloc_context* pAllocContext = thread->GetAllocContext();
PTR_gc_alloc_context pAllocContext = thread->GetAllocContext();

if (pAllocContext != NULL)
{
Expand Down Expand Up @@ -827,7 +827,7 @@ HRESULT ClrDataAccess::GetThreadDataImpl(CLRDATA_ADDRESS threadAddr, struct Dacp
threadData->state = thread->m_State;
threadData->preemptiveGCDisabled = thread->m_fPreemptiveGCDisabled;

gc_alloc_context* allocContext = thread->GetAllocContext();
PTR_gc_alloc_context allocContext = thread->GetAllocContext();
if (allocContext)
{
threadData->allocContextPtr = TO_CDADDR(allocContext->alloc_ptr);
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/vm/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ class TailCallTls
const PortableTailCallFrame* GetFrame() { return m_frame; }
};

typedef DPTR(struct gc_alloc_context) PTR_gc_alloc_context;

// #ThreadClass
//
// A code:Thread contains all the per-thread information needed by the runtime. We can get this
Expand Down Expand Up @@ -947,12 +949,12 @@ class Thread

// We store a pointer to this thread's alloc context here for easier introspection
// from other threads and diagnostic tools
gc_alloc_context* m_alloc_context;
PTR_gc_alloc_context m_alloc_context;

public:
inline void InitAllocContext() { LIMITED_METHOD_CONTRACT; m_alloc_context = &t_thread_alloc_context; }
inline void InitAllocContext() { LIMITED_METHOD_CONTRACT; m_alloc_context = PTR_gc_alloc_context(&t_thread_alloc_context); }

inline gc_alloc_context *GetAllocContext() { LIMITED_METHOD_CONTRACT; return m_alloc_context; }
inline PTR_gc_alloc_context GetAllocContext() { LIMITED_METHOD_CONTRACT; return m_alloc_context; }

// This is the type handle of the first object in the alloc context at the time
// we fire the AllocationTick event. It's only for tooling purpose.
Expand Down

0 comments on commit 5d1981e

Please sign in to comment.