[cDAC] Hide module lookup map layout details - #130730
Conversation
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
This PR refactors cDAC’s module lookup-map access to avoid leaking native lookup-map layout details to consumers by replacing the layout-shaped ModuleLookupTables with module+kind-based lookup operations implemented inside the Loader contract.
Changes:
- Replaces
ModuleLookupTableswithModuleLookupMapKindplus newILoaderAPIs for lookup-map base access, element lookup, and enumeration. - Implements map selection, traversal, flag masking, and metadata-token construction inside
Loader_1. - Migrates legacy/SOS and contract/test consumers and updates Loader/related contract documentation.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs | Updates mocks/helpers to use module+kind lookup APIs. |
| src/native/managed/cdac/tests/UnitTests/CodeVersionsTests.cs | Updates mock loader lookups for IL code versioning map. |
| src/native/managed/cdac/tests/DumpTests/IXCLRDataMethodDefinitionDumpTests.cs | Switches MethodDef→Desc lookup to module+kind API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs | Updates SOS DAC shims to new lookup APIs and enumeration shape. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/TypeDataWalk.cs | Migrates typedef/typeref map access to new API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs | Migrates multiple token→desc/MT lookups to new API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataMethodDefinition.cs | Updates MethodDef→Desc lookup to new API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/EcmaMetadataUtils.cs | Adds mdtMemberRef token type for token construction/mapping. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/GC/GcSignatureTypeProvider.cs | Updates type resolution lookups to kind-based API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Signature/SignatureTypeProvider.cs | Updates type resolution lookups to kind-based API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs | Updates FieldDef→Desc lookup to kind-based API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/ManagedTypeSource_1.cs | Updates TypeDef→MT lookup to kind-based API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs | Centralizes lookup-map selection, traversal, masking, and token construction. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/ExecutionManager/ExecutionManagerCore.cs | Updates TypeDef/TypeRef resolution to new lookup API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/CodeVersions_1.cs | Updates MethodDef→ILCodeVersioningState lookup to new API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs | Replaces ModuleLookupTables with ModuleLookupMapKind and new public ILoader methods. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/Extensions/ILoaderExtensions.cs | Updates assembly-ref resolution helper to use new lookup API. |
| docs/design/datacontracts/ManagedTypeSource.md | Updates spec pseudocode to new lookup API. |
| docs/design/datacontracts/Loader.md | Updates Loader contract spec to new lookup API and enumeration/token behavior. |
| docs/design/datacontracts/CodeVersions.md | Updates spec pseudocode to new lookup API. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f2aa5dc4-0c99-43f0-af14-734143849c4a
655e74c to
037212e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs:648
- EnumerateModuleLookupMap currently builds metadata tokens from the per-segment index returned by EnumerateModuleLookupMap(GetModuleLookupMap(...)). When the lookup map spans multiple linked segments (Next != Null), that index is no longer the original metadata RID, so CreateModuleLookupMapToken(kind, rid) can produce incorrect / invalid tokens (e.g., RID 0) and callers like SOSDacImpl.TraverseModuleMap will report wrong indices.
IEnumerable<(TargetPointer Value, uint Token)> ILoader.EnumerateModuleLookupMap(ModuleHandle module, ModuleLookupMapKind kind)
{
foreach ((TargetPointer value, uint rid) in EnumerateModuleLookupMap(GetModuleLookupMap(module, kind)))
yield return (value, CreateModuleLookupMapToken(kind, rid));
}
docs/design/datacontracts/Loader.md:726
- Loader.md removed the note/guard for builds that don't have code versioning (FEATURE_CODE_VERSIONING). The implementation treats MethodDefToILCodeVersioningState as an optional map (null/empty when absent), so the spec should reflect that rather than always reading the field unconditionally.
TypeDefToMethodTable => target.ReadPointer(module.Address + /* Module::TypeDefToMethodTableMap offset */),
TypeRefToMethodTable => target.ReadPointer(module.Address + /* Module::TypeRefToMethodTableMap offset */),
MethodDefToILCodeVersioningState => target.ReadPointer(module.Address + /* Module::MethodDefToILCodeVersioningStateMap offset */),
};
docs/design/datacontracts/Loader.md:798
- EnumerateModuleLookupMap pseudocode constructs the returned token from the segment-local "index". When the lookup map spans multiple linked segments (Next != Null), "index" is adjusted via
index -= countand no longer corresponds to the original metadata RID, so the returned token can be wrong. Track a base RID offset per segment when creating the token.
TargetPointer rawValue = target.ReadPointer(entryAddress);
ulong maskedValue = rawValue & ~(supportedFlagsMask.Value);
if (maskedValue != 0)
yield return (new TargetPointer(maskedValue), CreateModuleLookupMapToken(kind, index));
index++;
|
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. |
|
/ba-g osx timeout |
Summary
ModuleLookupTablesrecord with module-and-kind lookup operations.TableDataOffsetarithmetic.This gives consumers semantic operations for module lookup maps without exposing the native lookup-map object layout.
Validation
dotnet build src\native\managed\cdac\cdac.slnx -c Debug -p:UseSharedCompilation=false /nr:falsedotnet test src\native\managed\cdac\tests\UnitTests\Microsoft.Diagnostics.DataContractReader.Tests.csproj -c Debug --no-build(2697 passed, 16 skipped)DacDbiImplTests,CodeVersionsTests, andLoaderTestsrun (579 passed)Note
This PR was generated with the assistance of GitHub Copilot.