Skip to content

Add DacDbiInterfaceInstance to cdac#130856

Merged
hoyosjs merged 2 commits into
dotnet:mainfrom
hoyosjs:juhoyosa/dacdbi-interface-instance
Jul 17, 2026
Merged

Add DacDbiInterfaceInstance to cdac#130856
hoyosjs merged 2 commits into
dotnet:mainfrom
hoyosjs:juhoyosa/dacdbi-interface-instance

Conversation

@hoyosjs

@hoyosjs hoyosjs commented Jul 16, 2026

Copy link
Copy Markdown
Member

Adds a DacDbiInterfaceInstance entrypoint to the cDAC (mscordaccore_universal) so DBI can obtain an IDacDbiInterface backed by the managed data-contract reader, mirroring the native DAC export of the same name and signature. Previously the cDAC only exposed the SOS / IXCLRDataProcess surface via CLRDataCreateInstance, so DBI could only be serviced through the native DAC.

What this enables

  • A cDAC-serviced DacDbi creation path with the export name and signature DBI already expects.
  • The supporting interop declarations the entrypoint needs: ICorDebugDataTarget and ICLRRuntimeLocator.

Design decisions and tradeoffs

  • Self-location via the contract descriptor: the cDAC builds its target from the embedded contract descriptor (read through ICLRContractLocator on the caller's data target). The passed runtime base is used only to cross-check against ICLRRuntimeLocator::GetRuntimeBase when the data target implements it, keeping the activation model consistent with the SOS path.
  • The target is read-only: the write-memory path returns E_NOTIMPL, which is sufficient for the DacDbi surface.
  • DacSetTargetConsistencyChecks returns success on the standalone path since it only toggles target assertions.

Includes unit tests for the consistency-checks toggle.

Note

This description was drafted with GitHub Copilot.

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

Adds a new managed export (DacDbiInterfaceInstance) to the cDAC universal DAC so DBI can create an IDacDbiInterface backed by the managed data-contract reader, plus supporting interop declarations and unit tests around the standalone (non-legacy) path.

Changes:

  • Added DacDbiInterfaceInstance unmanaged entrypoint and helper to build a ContractDescriptorTarget from an ICorDebugDataTarget.
  • Added interop declarations for ICorDebugDataTarget and ICLRRuntimeLocator, and updated DbiVersion layout to MS/LS words.
  • Implemented standalone CheckDbiVersion / DacSetTargetConsistencyChecks behaviors and added unit tests for them.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs Adds unit tests for standalone DacDbi version checking and consistency-checks toggling.
src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs Adds the new DacDbiInterfaceInstance export and target-construction helper for CorDebug data targets.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ICLRData.cs Introduces ICLRRuntimeLocator COM interop declaration used for runtime base cross-checking.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Adds ICorDebugDataTarget interop and updates DbiVersion field layout to match native.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements standalone CheckDbiVersion and makes standalone DacSetTargetConsistencyChecks return success.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/CorDbHResults.cs Adds CORDBG_E_INCOMPATIBLE_PROTOCOL constant for managed use.

Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Comment thread src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs
Comment thread src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs Outdated
Comment thread src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs Outdated
Copilot AI review requested due to automatic review settings July 16, 2026 18:01

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 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs

@max-charlamb max-charlamb 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.

new entrypoint looks good to me.

hoyosjs and others added 2 commits July 16, 2026 19:45
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…arget.TryCreate call

Match the native DAC export by not requiring the allocator/metadata lookup pointers, and update CreateTargetFromCorDebugDataTarget to use the TryCreate factory (the address-based Create overload no longer exists on main).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 17, 2026 03:09
@hoyosjs
hoyosjs force-pushed the juhoyosa/dacdbi-interface-instance branch from 7759eb5 to 557fd72 Compare July 17, 2026 03:09

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 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
Comment thread src/native/managed/cdac/mscordaccore_universal/Entrypoints.cs
@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.

@hoyosjs
hoyosjs enabled auto-merge (squash) July 17, 2026 18:09
@hoyosjs
hoyosjs merged commit 6853d73 into dotnet:main Jul 17, 2026
87 checks passed
@hoyosjs
hoyosjs deleted the juhoyosa/dacdbi-interface-instance branch July 17, 2026 21:27
hoyosjs added a commit to hoyosjs/runtime that referenced this pull request Jul 17, 2026
hoyosjs added a commit to hoyosjs/runtime that referenced this pull request Jul 18, 2026
Squash the two commits from dotnet#130856 into one isolated change so it can be reverted independently.
hoyosjs added a commit to hoyosjs/runtime that referenced this pull request Jul 18, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 18, 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.

4 participants