Skip to content

Start DBI changes needed for non-surrogate loading - #131008

Merged
hoyosjs merged 4 commits into
dotnet:mainfrom
hoyosjs:hoyosjs/cdac-dbi-live-debugging
Jul 27, 2026
Merged

Start DBI changes needed for non-surrogate loading#131008
hoyosjs merged 4 commits into
dotnet:mainfrom
hoyosjs:hoyosjs/cdac-dbi-live-debugging

Conversation

@hoyosjs

@hoyosjs hoyosjs commented Jul 18, 2026

Copy link
Copy Markdown
Member

Enables live debugging through the cDAC-backed DBI.

The DacDbiInterfaceInstance export takes a contractDescriptorAddress parameter alongside the runtime base. When creating the DAC/DBI interface, the DBI resolves the runtime's contract descriptor address via TryGetSymbol and passes it to the export.

On the cdac side, the DacDbiInterfaceInstance entrypoint uses that address to build the ContractDescriptorTarget and construct the legacy DacDbiImpl over it, so a live ICorDebug session can be served by the cDAC. The native DAC export forwards the same address into its cDAC bring-up path.

@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 thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Comment thread src/coreclr/debug/di/shimdatatarget.cpp Outdated
Comment thread src/coreclr/debug/di/shimdatatarget.cpp Outdated

@noahfalk noahfalk left a comment

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.

I think with a small adjustment to the DacDbiInterfaceInstance export function signature a good chunk of the code in this PR can go away.

Comment thread src/coreclr/debug/di/shimdatatarget.h Outdated
Enables live debugging through the cDAC-backed DBI. The
DacDbiInterfaceInstance export takes a contractDescriptorAddress
parameter alongside the runtime base. When creating the DAC/DBI
interface, the DBI resolves the runtime's contract descriptor address
via TryGetSymbol and passes it to the export.

The cdac entrypoint uses that address to build the
ContractDescriptorTarget and construct the legacy DacDbiImpl over it, so
a live ICorDebug session can be served by the cDAC. The native DAC
export forwards the same address into its cDAC bring-up path.
Copilot AI review requested due to automatic review settings July 25, 2026 05:58
@hoyosjs
hoyosjs marked this pull request as ready for review July 25, 2026 05:58
@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.

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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/debug/di/shimdatatarget.h Outdated
Comment thread src/coreclr/debug/di/process.cpp
Copilot AI review requested due to automatic review settings July 25, 2026 10:10

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

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Return CORDBG_E_READVIRTUAL_FAILURE for an incomplete ReadVirtual and
CORDBG_E_TARGET_READONLY when the target does not implement
ICorDebugMutableDataTarget, instead of the generic E_FAIL/E_NOTIMPL.
Copilot AI review requested due to automatic review settings July 25, 2026 12:10

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Comment thread src/coreclr/debug/di/process.cpp
@hoyosjs
hoyosjs enabled auto-merge (squash) July 27, 2026 19:19
@hoyosjs
hoyosjs merged commit 00115f0 into dotnet:main Jul 27, 2026
139 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 28, 2026
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.

3 participants