Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f60b349
remove dt context
rcj1 Jul 8, 2026
764ab1e
merge
rcj1 Jul 8, 2026
b259616
add untracked files
rcj1 Jul 8, 2026
4b72f50
fix build
rcj1 Jul 8, 2026
b1cfa55
fix build
rcj1 Jul 8, 2026
b85b41a
code review
rcj1 Jul 8, 2026
057d5fa
fix build
rcj1 Jul 8, 2026
d7bdaf4
merge
rcj1 Jul 8, 2026
2974b57
fix crossdac
rcj1 Jul 8, 2026
aee5d91
sig
rcj1 Jul 14, 2026
9534815
fix build
rcj1 Jul 14, 2026
3e3816b
Merge
rcj1 Jul 16, 2026
9aea595
code review
rcj1 Jul 17, 2026
f838fb3
merge
rcj1 Jul 17, 2026
6a5e27c
ccr
rcj1 Jul 17, 2026
a4d9bb8
code review
rcj1 Jul 17, 2026
9ba5f91
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rcj1 Jul 18, 2026
f75cbfb
Add GetTargetInfo DacDbi API
rcj1 Jul 8, 2026
c4e0eba
codE review
rcj1 Jul 21, 2026
fd0b7b2
Merge branch 'main' into sw-stuff-2
rcj1 Jul 22, 2026
171a628
fix merge
rcj1 Jul 22, 2026
c117f11
fix loong and riscv
rcj1 Jul 22, 2026
f445952
Update src/coreclr/debug/inc/dacdbistructures.h
rcj1 Jul 22, 2026
24b52fd
only copy part of context that is required by the context flags
rcj1 Jul 22, 2026
ee43cdc
Potential fix for pull request finding
rcj1 Jul 22, 2026
18e4aba
Update IDacDbiInterface.cs
rcj1 Jul 23, 2026
0c59041
Update dacdbiinterface.h
rcj1 Jul 23, 2026
6334ea1
Update dacdbi.idl
rcj1 Jul 23, 2026
e287b49
Update src/coreclr/debug/inc/dacdbistructures.h
rcj1 Jul 23, 2026
45920f1
E
rcj1 Jul 23, 2026
945bb4b
Potential fix for pull request finding
rcj1 Jul 24, 2026
1a090da
Merge branch 'main' into sw-stuff-2
rcj1 Jul 24, 2026
2f4be3a
merge
rcj1 Jul 27, 2026
746f154
fix merge
rcj1 Jul 27, 2026
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
631 changes: 628 additions & 3 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp

Large diffs are not rendered by default.

35 changes: 29 additions & 6 deletions src/coreclr/debug/daccess/dacdbiimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,29 @@ class DacDbiInterfaceImpl :
HRESULT STDMETHODCALLTYPE EnumerateAsyncLocals(VMPTR_MethodDesc vmMethod, CORDB_ADDRESS codeAddr, UINT32 state, FP_ASYNC_LOCAL_CALLBACK fpCallback, CALLBACK_DATA pUserData);
HRESULT STDMETHODCALLTYPE GetGenericArgTokenIndex(VMPTR_MethodDesc vmMethod, OUT UINT32* pIndex);

HRESULT STDMETHODCALLTYPE GetTargetContextSize(ContextSizeFlags flags, OUT ULONG32 * pSize);

HRESULT STDMETHODCALLTYPE WriteRegistersToContext(IN OUT BYTE * ctxBuf, IN ULONG32 cb, IN const CorDebugRegister * regs, IN ULONG32 nRegs, IN const TADDR * values);
HRESULT STDMETHODCALLTYPE ReadRegistersFromContext(IN BYTE * ctxBuf, IN ULONG32 cb, IN const CorDebugRegister * regs, IN ULONG32 nRegs, OUT TADDR * pValues);
HRESULT STDMETHODCALLTYPE GetAvailableRegistersMask(IN BOOL fActive, IN BOOL fQuickUnwind, IN ULONG32 regCount, OUT BYTE pAvailable[]);
HRESULT STDMETHODCALLTYPE ConvertJitRegNumToCorDebugRegister(IN ULONG32 jitRegNum, OUT CorDebugRegister * pReg);
HRESULT STDMETHODCALLTYPE ReadFloatRegistersFromContext(
IN BYTE * ctxBuf,
IN ULONG32 cb,
IN ULONG32 regCount,
OUT DOUBLE values[CORDB_MAX_FLOAT_REGISTERS],
OUT ULONG32 * pValuesCount,
OUT int * pFirstFloatReg,
OUT ULONG32 * pFloatStackTop);

HRESULT STDMETHODCALLTYPE GetTargetInfo(OUT TargetInfo * pTargetInfo);

HRESULT STDMETHODCALLTYPE ContextHasExtendedRegisters(IN BYTE * ctxBuf, IN ULONG32 cb, OUT BOOL * pResult);

HRESULT STDMETHODCALLTYPE CompareControlRegisters(IN const BYTE * ctxBuf1, IN ULONG32 cb1, IN const BYTE * ctxBuf2, IN ULONG32 cb2, OUT BOOL * pResult);

HRESULT STDMETHODCALLTYPE CopyContext(IN OUT BYTE * dstCtxBuf, IN ULONG32 cbDst, IN const BYTE * srcCtxBuf, IN ULONG32 cbSrc, IN ULONG32 flags);

private:
void TypeHandleToExpandedTypeInfoImpl(AreValueTypesBoxed boxed,
TypeHandle typeHandle,
Expand Down Expand Up @@ -681,24 +704,24 @@ class DacDbiInterfaceImpl :
HRESULT STDMETHODCALLTYPE GetManagedStoppedContext(VMPTR_Thread vmThread, OUT VMPTR_CONTEXT * pRetVal);

// Create and return a stackwalker on the specified thread.
HRESULT STDMETHODCALLTYPE CreateStackWalk(VMPTR_Thread vmThread, DT_CONTEXT * pInternalContextBuffer, OUT StackWalkHandle * ppSFIHandle);
HRESULT STDMETHODCALLTYPE CreateStackWalk(VMPTR_Thread vmThread, BYTE * pInternalContextBuffer, OUT StackWalkHandle * ppSFIHandle);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are removing the strong types off these CONTEXT parameters then for safety we should add a ULONG32 cbContext parameter so that the function implementation can confirm the buffer is the size it expects and reduce our risk of buffer overruns.


// Delete the stackwalk object
HRESULT STDMETHODCALLTYPE DeleteStackWalk(StackWalkHandle ppSFIHandle);

// Get the CONTEXT of the current frame at which the stackwalker is stopped.
HRESULT STDMETHODCALLTYPE GetStackWalkCurrentContext(StackWalkHandle pSFIHandle, DT_CONTEXT * pContext);
HRESULT STDMETHODCALLTYPE GetStackWalkCurrentContext(StackWalkHandle pSFIHandle, BYTE * pContext);

void GetStackWalkCurrentContext(StackFrameIterator * pIter, DT_CONTEXT * pContext);

// Set the stackwalker to the specified CONTEXT.
HRESULT STDMETHODCALLTYPE SetStackWalkCurrentContext(VMPTR_Thread vmThread, StackWalkHandle pSFIHandle, CorDebugSetContextFlag flag, DT_CONTEXT * pContext);
HRESULT STDMETHODCALLTYPE SetStackWalkCurrentContext(VMPTR_Thread vmThread, StackWalkHandle pSFIHandle, CorDebugSetContextFlag flag, BYTE * pContext);

// Unwind the stackwalker to the next frame.
HRESULT STDMETHODCALLTYPE UnwindStackWalkFrame(StackWalkHandle pSFIHandle, OUT BOOL * pResult);

HRESULT STDMETHODCALLTYPE CheckContext(VMPTR_Thread vmThread,
const DT_CONTEXT * pContext);
const BYTE * pContext);

// Retrieve information about the current frame from the stackwalker.
HRESULT STDMETHODCALLTYPE GetStackWalkCurrentFrameInfo(StackWalkHandle pSFIHandle, OPTIONAL Debugger_STRData * pFrameData, OUT FrameType * pRetVal);
Expand All @@ -722,10 +745,10 @@ class DacDbiInterfaceImpl :

// Return TRUE if the specified CONTEXT is the CONTEXT of the leaf frame.
// @dbgtodo filter CONTEXT - Currently we check for the filter CONTEXT first.
HRESULT STDMETHODCALLTYPE IsLeafFrame(VMPTR_Thread vmThread, const DT_CONTEXT * pContext, OUT BOOL * pResult);
HRESULT STDMETHODCALLTYPE IsLeafFrame(VMPTR_Thread vmThread, const BYTE * pContext, OUT BOOL * pResult);

// DacDbi API: Get the context for a particular thread of the target process
HRESULT STDMETHODCALLTYPE GetContext(VMPTR_Thread vmThread, DT_CONTEXT * pContextBuffer);
HRESULT STDMETHODCALLTYPE GetContext(VMPTR_Thread vmThread, BYTE * pContextBuffer);

// Check if the given method is a DiagnosticHidden or an LCG method.
HRESULT STDMETHODCALLTYPE IsDiagnosticsHiddenOrLCGMethod(VMPTR_MethodDesc vmMethodDesc, OUT DynamicMethodType * pRetVal);
Expand Down
27 changes: 17 additions & 10 deletions src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ T_CONTEXT * GetContextBufferFromHandle(StackWalkHandle pSFIHandle)


// Create and return a stackwalker on the specified thread.
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::CreateStackWalk(VMPTR_Thread vmThread, DT_CONTEXT * pInternalContextBuffer, OUT StackWalkHandle * ppSFIHandle)
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::CreateStackWalk(VMPTR_Thread vmThread, BYTE * pInternalContextBuffer, OUT StackWalkHandle * ppSFIHandle)
{
DD_ENTER_MAY_THROW;

Expand Down Expand Up @@ -156,7 +156,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::DeleteStackWalk(StackWalkHandle p
}

// Get the CONTEXT of the current frame at which the stackwalker is stopped.
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetStackWalkCurrentContext(StackWalkHandle pSFIHandle, DT_CONTEXT * pContext)
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetStackWalkCurrentContext(StackWalkHandle pSFIHandle, BYTE * pContext)
{
DD_ENTER_MAY_THROW;

Expand All @@ -166,7 +166,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetStackWalkCurrentContext(StackW

StackFrameIterator * pIter = GetIteratorFromHandle(pSFIHandle);

GetStackWalkCurrentContext(pIter, pContext);
GetStackWalkCurrentContext(pIter, reinterpret_cast<DT_CONTEXT *>(pContext));
}
EX_CATCH_HRESULT(hr);
return hr;
Expand All @@ -189,20 +189,22 @@ void DacDbiInterfaceImpl::GetStackWalkCurrentContext(StackFrameIterator * pIter,


// Set the stackwalker to the specified CONTEXT.
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::SetStackWalkCurrentContext(VMPTR_Thread vmThread, StackWalkHandle pSFIHandle, CorDebugSetContextFlag flag, DT_CONTEXT * pContext)
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::SetStackWalkCurrentContext(VMPTR_Thread vmThread, StackWalkHandle pSFIHandle, CorDebugSetContextFlag flag, BYTE * pContextBuffer)
{
DD_ENTER_MAY_THROW;

HRESULT hr = S_OK;
EX_TRY
{

DT_CONTEXT * pContext = reinterpret_cast<DT_CONTEXT *>(pContextBuffer);

StackFrameIterator * pIter = GetIteratorFromHandle(pSFIHandle);
REGDISPLAY * pRD = GetRegDisplayFromHandle(pSFIHandle);

#if defined(_DEBUG)
// The caller should have checked this already.
_ASSERTE(CheckContext(vmThread, pContext) == S_OK);
_ASSERTE(CheckContext(vmThread, pContextBuffer) == S_OK);
#endif // _DEBUG

// DD can't keep pointers back into the RS address space.
Expand Down Expand Up @@ -342,9 +344,12 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::UnwindStackWalkFrame(StackWalkHan
// Check whether the specified CONTEXT is valid. The only check we perform right now is whether the
// SP in the specified CONTEXT is in the stack range of the thread.
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::CheckContext(VMPTR_Thread vmThread,
const DT_CONTEXT * pContext)
const BYTE * pContextBuffer)
{
DD_ENTER_MAY_THROW;
_ASSERTE(pContextBuffer != NULL);

const DT_CONTEXT * pContext = reinterpret_cast<const DT_CONTEXT *>(pContextBuffer);

// If the SP in the CONTEXT isn't valid, then there's no point in checking.
if ((pContext->ContextFlags & CONTEXT_CONTROL) == 0)
Expand Down Expand Up @@ -704,14 +709,16 @@ FramePointer DacDbiInterfaceImpl::GetFramePointerWorker(StackFrameIterator * pIt
}

// Return TRUE if the specified CONTEXT is the CONTEXT of the leaf frame.
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsLeafFrame(VMPTR_Thread vmThread, const DT_CONTEXT * pContext, OUT BOOL * pResult)
HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsLeafFrame(VMPTR_Thread vmThread, const BYTE * pContextBuffer, OUT BOOL * pResult)
{
DD_ENTER_MAY_THROW;

HRESULT hr = S_OK;
EX_TRY
{

const DT_CONTEXT * pContext = reinterpret_cast<const DT_CONTEXT *>(pContextBuffer);

DT_CONTEXT ctxLeaf;
Thread * pThread = vmThread.GetDacPtr();
ctxLeaf.ContextFlags = DT_CONTEXT_ALL;
Expand All @@ -721,7 +728,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::IsLeafFrame(VMPTR_Thread vmThread
reinterpret_cast<BYTE *>(&ctxLeaf)));

// Call a platform-specific helper to compare the two contexts.
*pResult = CompareControlRegisters(pContext, &ctxLeaf);
*pResult = ::CompareControlRegisters(pContext, &ctxLeaf);
}
EX_CATCH_HRESULT(hr);
return hr;
Expand Down Expand Up @@ -755,7 +762,7 @@ void DacDbiInterfaceImpl::InitFrameData(StackFrameIterator * pIter,
pFrameData->eType = Debugger_STRData::cRuntimeNativeFrame;

_ASSERTE(pFrameData->ctx != NULL);
GetStackWalkCurrentContext(pIter, pFrameData->ctx);
GetStackWalkCurrentContext(pIter, reinterpret_cast<DT_CONTEXT *>(pFrameData->ctx));
}
else if (ft == kManagedStackFrame)
{
Expand Down Expand Up @@ -786,7 +793,7 @@ void DacDbiInterfaceImpl::InitFrameData(StackFrameIterator * pIter,
pFrameData->eType = Debugger_STRData::cMethodFrame;

_ASSERTE(pFrameData->ctx != NULL);
GetStackWalkCurrentContext(pIter, pFrameData->ctx);
GetStackWalkCurrentContext(pIter, reinterpret_cast<DT_CONTEXT *>(pFrameData->ctx));

//
// initialize the fields in Debugger_STRData::v
Expand Down
21 changes: 1 addition & 20 deletions src/coreclr/debug/di/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(CORDBDI_SOURCES
shimstackwalk.cpp
breakpoint.cpp
cordb.cpp
cordbregisterset.cpp
divalue.cpp
dbgtransportmanager.cpp
Comment thread
rcj1 marked this conversation as resolved.
hash.cpp
Expand Down Expand Up @@ -50,33 +51,13 @@ set(CORDBDI_HEADERS
if(CLR_CMAKE_HOST_WIN32)
#use static crt
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)

if (CLR_CMAKE_TARGET_ARCH_AMD64 OR ((CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD))
set(CORDBDI_SOURCES_ASM_FILE ${ARCH_SOURCES_DIR}/floatconversion.asm)
endif()

if ((CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
convert_to_absolute_path(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
preprocess_files(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
endif()
elseif(CLR_CMAKE_HOST_UNIX)

if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64 OR CLR_CMAKE_TARGET_ARCH_RISCV64)
set(CORDBDI_SOURCES_ASM_FILE
${ARCH_SOURCES_DIR}/floatconversion.S
)
endif()

endif(CLR_CMAKE_HOST_WIN32)

if (CLR_CMAKE_TARGET_WIN32)
convert_to_absolute_path(CORDBDI_HEADERS ${CORDBDI_HEADERS})
list(APPEND CORDBDI_SOURCES ${CORDBDI_HEADERS})
endif (CLR_CMAKE_TARGET_WIN32)

list(APPEND CORDBDI_SOURCES ${CORDBDI_SOURCES_ASM_FILE})

add_library_clr(cordbdi STATIC ${CORDBDI_SOURCES})
target_precompile_headers(cordbdi PRIVATE stdafx.h)
add_dependencies(cordbdi eventing_headers)
19 changes: 0 additions & 19 deletions src/coreclr/debug/di/amd64/FloatConversion.asm

This file was deleted.

Loading