Skip to content

[cDAC] Implement GetILCodeVersionNodeData in DacDbi - #129448

Merged
rcj1 merged 5 commits into
mainfrom
copilot/featureget-il-code-version-node-data
Jun 16, 2026
Merged

rcj1 merged 5 commits into
mainfrom
copilot/featureget-il-code-version-node-data

Conversation

@rcj1

@rcj1 rcj1 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor
  • Making InstrumentedILOffsetMapping m_cMap UINT, it already would fit in a UINT
  • Adding API TryGetInstrumentedILMap(ILCodeVersionHandle ilCodeVersionHandle, out uint mapEntryCount, out TargetPointer mapEntries)
  • Implementing GetILCodeVersionNodeData

@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

Adds cDAC exposure for instrumented IL offset mappings and wires that into the legacy DacDbi GetILCodeVersionNodeData flow, including CoreCLR data-descriptor plumbing and unit test coverage.

Changes:

  • Add InstrumentedILOffsetMapping to the CoreCLR cDAC data descriptor set and contracts, and expose it off ILCodeVersionNode.
  • Introduce ICodeVersions.TryGetInstrumentedILMap(...) and implement it in CodeVersions_1.
  • Implement DacDbiImpl.GetILCodeVersionNodeData and add new unit tests/mocks for the new mapping data.
Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/MockDescriptors/MockDescriptors.CodeVersions.cs Extends mock layouts/builders to represent instrumented IL map data on IL code version nodes.
src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs Adds a unit test validating GetILCodeVersionNodeData populates IL + instrumented map outputs.
src/native/managed/cdac/tests/UnitTests/CodeVersionsTests.cs Adds contract-level tests for TryGetInstrumentedILMap (explicit + synthetic).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Updates DacDbiSharedReJitInfo managed struct layout to match native changes (removes unused fields).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements GetILCodeVersionNodeData using cDAC contracts and instrumented IL map query.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/DataType.cs Adds InstrumentedILOffsetMapping to the contract DataType enum.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/InstrumentedILOffsetMapping.cs New data contract type representing the embedded mapping (count + pointer).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/ILCodeVersionNode.cs Exposes the embedded mapping address via [FieldAddress] InstrumentedILMap.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/CodeVersions_1.cs Implements TryGetInstrumentedILMap by reading the embedded mapping.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ICodeVersions.cs Adds new contract API TryGetInstrumentedILMap(...).
src/coreclr/vm/ilinstrumentation.h Changes mapping count storage to UINT and adds cdac_data<> descriptor offsets.
src/coreclr/vm/ilinstrumentation.cpp Updates SetMappingInfo/GetCount signatures to UINT.
src/coreclr/vm/datadescriptor/datadescriptor.inc Adds cDAC type/fields for InstrumentedILOffsetMapping and embeds it in ILCodeVersionNode.
src/coreclr/vm/codeversion.h Updates SetInstrumentedILMap signatures to UINT and adds cDAC offset for embedded mapping.
src/coreclr/vm/codeversion.cpp Updates SetInstrumentedILMap implementations to use UINT.
src/coreclr/debug/inc/dacdbistructures.h Removes unused fields from native DacSharedReJitInfo structure.
src/coreclr/debug/ee/functioninfo.cpp Updates DebuggerMethodInfo::SetInstrumentedILMap count parameter to UINT.
src/coreclr/debug/ee/debugger.h Updates SetInstrumentedILMap declaration to UINT.
src/coreclr/debug/daccess/dacdbiimpl.cpp Stops populating removed DacSharedReJitInfo fields; keeps IL + instrumented map outputs.
docs/design/datacontracts/CodeVersions.md Documents the new API and new data descriptors involved in the mapping.

Copilot's findings

  • Files reviewed: 20/20 changed files
  • Comments generated: 6

@github-actions

This comment has been minimized.

rcj1 and others added 2 commits June 15, 2026 18:53
Copilot AI review requested due to automatic review settings June 16, 2026 01:54

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.

Copilot's findings

  • Files reviewed: 20/20 changed files
  • Comments generated: 3

@github-actions

This comment has been minimized.

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

lgtm

@github-actions

This comment has been minimized.

Copilot AI review requested due to automatic review settings June 16, 2026 13:25
@github-actions

Copy link
Copy Markdown
Contributor

Copilot Code Review

Holistic Assessment

Motivation: This PR implements GetILCodeVersionNodeData in the managed cDAC DacDbi layer, continuing the migration from native DAC to managed contracts. It also adds TryGetInstrumentedILMap to ICodeVersions, exposes InstrumentedILOffsetMapping as a cDAC data type, narrows SIZE_T to UINT for the map count, and removes unused fields from DacSharedReJitInfo. All clearly justified as part of the ongoing cDAC effort.

Approach: Sound. The embedded InstrumentedILOffsetMapping is correctly modeled via [Field] on the IData<T> type (matching established patterns like EEAllocContext.GCAllocationContext), the data descriptor uses CDAC_TYPE_INDETERMINATE appropriately (since padding between T_UINT32 Count and T_POINTER Map varies by platform), and the DacDbi implementation follows the same defensive patterns as sibling methods.

Summary: ✅ LGTM. The implementation correctly mirrors native DAC behavior, the SIZE_T → UINT narrowing is safe (bounded by the ULONG profiler API surface), struct layout changes are consistent across native/managed boundaries, and tests provide good coverage across architectures.


Detailed Findings

Detailed Findings

✅ Native behavior fidelity

Verified the full chain: native ILCodeVersionNode::GetInstrumentedILMap() returns &m_instrumentedILMap (always non-null for explicit nodes since it's an embedded struct). ILCodeVersion::GetInstrumentedILMap() returns this for explicit versions and NULL for synthetic versions. The cDAC TryGetInstrumentedILMap correctly returns true for all explicit versions and false for synthetic — matching exactly.

The DacDbiImpl.GetILCodeVersionNodeData fills the same fields as native DacDbiInterfaceImpl::GetILCodeVersionNodeData (dacdbiimpl.cpp:7163-7183), and the DEBUG validation block correctly compares all three output fields.

✅ Data descriptor registration

datadescriptor.inc correctly uses TYPE(InstrumentedILOffsetMapping) for the embedded field (not a scalar type), and declares the type with CDAC_TYPE_INDETERMINATE. The cdac_data<InstrumentedILOffsetMapping> template in ilinstrumentation.h correctly maps Count and Map to the private fields via offsetof, with the friend struct ::cdac_data<InstrumentedILOffsetMapping> declaration granting access.

✅ SIZE_T → UINT narrowing

Safe change. The profiler API (ICorProfilerInfo::SetILInstrumentedCodeMap) uses ULONG for the entry count, so counts are already bounded to 32 bits at the API boundary. The data descriptor uses T_UINT32 consistently.

✅ Defensive initialization and struct field removal

*pData = default is set immediately after the null check, before the IReJIT contract gate — following the same pattern as GetActiveRejitILCodeVersionNode (line 4239). Removal of m_state/m_dwCodegenFlags from both native DacSharedReJitInfo (dacdbistructures.h) and managed DacDbiSharedReJitInfo is consistent — both the native GetILCodeVersionNodeData and managed implementation no longer write those fields.

✅ Mock layout consistency

The MockILCodeVersionNode layout correctly models the embedded struct as two sequential fields (UInt32 Count + Pointer Map), which will produce the same offsets as MockInstrumentedILOffsetMapping. On 64-bit: Count at offset 0, Map at offset 8 (with 4 bytes padding); on 32-bit: Count at offset 0, Map at offset 4. Both match the real native struct layout.

✅ Test coverage

Tests cover:

  • Explicit version with non-zero map data (TryGetInstrumentedILMap_Explicit)
  • Synthetic version returning false (TryGetInstrumentedILMap_Synthetic_ReturnsFalse)
  • DacDbi integration with hasMap=true and hasMap=false (GetILCodeVersionNodeData_FillsData)
  • Both 32-bit and 64-bit architectures via MockTarget.StdArch

💡 Minor doc phrasing — non-blocking

The contract doc comment says "Returns false when the version has no instrumented map." The actual semantic is "returns false for synthetic versions that lack a backing ILCodeVersionNode." For explicit versions with Count == 0, the method returns true (the embedded mapping struct exists, it's just empty). The phrasing is acceptable since "has no instrumented map" can mean "the map object does not exist," but a future clarification could make this distinction explicit.

Note

This review was generated by Copilot.

Generated by Code Review for issue #129448 · ● 44.9M · ◷

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.

Copilot's findings

  • Files reviewed: 22/22 changed files
  • Comments generated: 3

@rcj1

rcj1 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

/ba-g timeouts

@rcj1
rcj1 merged commit 95e7c8e into main Jun 16, 2026
132 of 141 checks passed
@rcj1
rcj1 deleted the copilot/featureget-il-code-version-node-data branch June 16, 2026 21:29
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
* Making InstrumentedILOffsetMapping m_cMap UINT, it already would fit
in a UINT
* Adding API `TryGetInstrumentedILMap(ILCodeVersionHandle
ilCodeVersionHandle, out uint mapEntryCount, out TargetPointer
mapEntries)`
* Implementing `GetILCodeVersionNodeData`

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants