Skip to content

Start DBI changes needed for non-surrogate loading#131008

Draft
hoyosjs wants to merge 1 commit into
dotnet:mainfrom
hoyosjs:hoyosjs/cdac-dbi-live-debugging
Draft

Start DBI changes needed for non-surrogate loading#131008
hoyosjs wants to merge 1 commit into
dotnet:mainfrom
hoyosjs:hoyosjs/cdac-dbi-live-debugging

Conversation

@hoyosjs

@hoyosjs hoyosjs commented Jul 18, 2026

Copy link
Copy Markdown
Member

No description provided.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR begins wiring up the DBI/cDAC stack for non-surrogate loading by (1) standardizing context-buffer alignment handling in the managed cDAC entrypoints, and (2) enabling live-process data targets to expose runtime/contract location plus optional mutability (write + SetThreadContext) through existing COM shapes.

Changes:

  • Centralize and reuse a 16-byte alignment requirement for thread-context buffers in mscordaccore_universal entrypoints and target adapters.
  • Add managed COM projection for ICorDebugMutableDataTarget and plumb optional write / SetThreadContext support when available.
  • Introduce ICLRContractLocator in the CLR data IDL/prebuilt headers and implement it (and ICLRRuntimeLocator) on the shim live-process data target; link dbgutil to support symbol lookup.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs Reuse a shared context alignment constant; add optional mutable target support; tighten ReadVirtual semantics for full reads.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Add managed ICorDebugMutableDataTarget COM interface definition.
src/coreclr/pal/prebuilt/inc/clrdata.h Add prebuilt COM interface declaration for ICLRContractLocator.
src/coreclr/pal/prebuilt/idl/clrdata_i.cpp Add IID definition for ICLRContractLocator.
src/coreclr/inc/clrdata.idl Define new ICLRContractLocator COM interface in the source IDL.
src/coreclr/dlls/mscordbi/CMakeLists.txt Link dbgutil into mscordbi to support export symbol lookup.
src/coreclr/debug/di/shimprocess.cpp Add shim hook to propagate runtime base to the live data target.
src/coreclr/debug/di/shimpriv.h Declare ShimProcess::SetRuntimeBase.
src/coreclr/debug/di/shimdatatarget.h Extend shim data target to implement ICLRContractLocator/ICLRRuntimeLocator and store runtime base.
src/coreclr/debug/di/shimdatatarget.cpp Implement QI for the new interfaces and resolve the contract descriptor via TryGetSymbol.
src/coreclr/debug/di/process.cpp Ensure the shim live data target receives the runtime base before creating the DAC/DBI interface.

Comment on lines 458 to +462
uint bytesRead;
return dataTarget.ReadVirtual(address, bufferPtr, (uint)buffer.Length, &bytesRead);
int hr = dataTarget.ReadVirtual(address, bufferPtr, (uint)buffer.Length, &bytesRead);
return hr >= 0 && bytesRead != (uint)buffer.Length
? HResults.E_FAIL
: hr;
Comment on lines +467 to +472
if (mutableDataTarget is null)
return HResults.E_NOTIMPL;

fixed (byte* bufferPtr = buffer)
{
return mutableDataTarget.WriteVirtual(address, bufferPtr, (uint)buffer.Length);
Comment on lines +507 to +515
if (mutableDataTarget is null)
return HResults.E_NOTIMPL;

fixed (byte* contextPtr = context)
{
if (((nuint)contextPtr & (ContextAlignment - 1)) == 0)
{
return mutableDataTarget.SetThreadContext(threadId, (uint)context.Length, contextPtr);
}
Comment on lines +111 to +116
HRESULT STDMETHODCALLTYPE ShimDataTarget::GetContractDescriptor(CLRDATA_ADDRESS * contractAddress)
{
if (contractAddress == NULL || m_runtimeBase == 0)
{
return E_INVALIDARG;
}
Comment on lines +132 to +137
HRESULT STDMETHODCALLTYPE ShimDataTarget::GetRuntimeBase(CLRDATA_ADDRESS * baseAddress)
{
if (baseAddress == NULL || m_runtimeBase == 0)
{
return E_INVALIDARG;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants