[cDAC] Implement GetModuleSimpleName for cDAC#127415
Conversation
Replace the legacy-delegation stub with a contract-based implementation that uses ILoader.GetModuleHandleFromModulePtr and TryGetSimpleName. Follows the GetAppDomainFullName pattern with try/catch and DEBUG legacy validation. Add dump-based integration test. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/d565028d-e96a-4a77-961a-592e8f591a34 Co-authored-by: barosiak <76071368+barosiak@users.noreply.github.com>
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
Implements IDacDbiInterface.GetModuleSimpleName in the managed cDAC DBI (DacDbiImpl) using the ILoader contract, and adds a dump-based integration test to validate the API returns S_OK with a non-empty name for modules in the MultiModule full dump.
Changes:
- Implement
DacDbiImpl.GetModuleSimpleNameusingILoader.GetModuleHandleFromModulePtr+ILoader.TryGetSimpleName. - Add a dump test that iterates all modules and asserts
GetModuleSimpleNamereturnsS_OKwith a non-empty string.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs | Adds contract-based implementation of GetModuleSimpleName (with DEBUG-time validation against legacy DAC). |
| src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiLoaderDumpTests.cs | Adds integration coverage to ensure module simple names are returned successfully and are non-empty in dump scenarios. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR implements DacDbiImpl.GetModuleSimpleName using the cDAC ILoader contract (TryGetSimpleName) instead of relying on legacy DAC delegation, and adds a dump-based integration test to ensure module simple names are available and non-empty.
Changes:
- Implement
DacDbiImpl.GetModuleSimpleNameviaILoader.GetModuleHandleFromModulePtr+ILoader.TryGetSimpleName, including DEBUG-only validation against legacy output. - Add a dump test that iterates all modules in the MultiModule full dump and asserts
GetModuleSimpleNamereturnsS_OKand a non-empty string for each.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs | Implements GetModuleSimpleName using the loader contract and adds DEBUG-only string comparison against legacy DAC output. |
| src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiLoaderDumpTests.cs | Adds a dump integration test validating GetModuleSimpleName succeeds and returns a non-empty name for all modules. |
There was a problem hiding this comment.
Pull request overview
Implements DacDbiImpl.GetModuleSimpleName using the cDAC ILoader contract (TryGetSimpleName) instead of delegating to the legacy DAC-only implementation, and adds dump-based coverage to ensure module simple names are returned successfully.
Changes:
- Implement
DacDbiImpl.GetModuleSimpleNameviaTarget.Contracts.Loader.TryGetSimpleNameand copy into the nativeIStringHolder. - Add a dump test that calls
GetModuleSimpleNamefor all modules and assertsS_OKwith a non-empty result. - Fix
NativeStringHolder’s namespace to align with the Legacy assembly and simplify theHResultsreference.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs | Implements GetModuleSimpleName using the ILoader contract and retains DEBUG cross-checking against legacy. |
| src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiLoaderDumpTests.cs | Adds dump-based integration test coverage for GetModuleSimpleName. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/NativeStringHolder.cs | Aligns helper type namespace with the Legacy assembly and updates HRESULT reference. |
🤖 Copilot Code Review — PR #127415Note This review was AI/Copilot-generated. Models contributing: Claude Opus 4.6 (primary), Claude Sonnet 4.5. Holistic AssessmentMotivation: The PR replaces a legacy-delegation stub for Approach: The implementation correctly follows the established try/catch + Summary: ✅ LGTM. The implementation is correct, follows established patterns, and includes both DEBUG validation and a dump-based integration test. One minor advisory note below about test strictness, but it is not blocking. Detailed Findings✅ Correctness & Pattern Consistency — VerifiedThe new
The DEBUG validation block is an improvement over the existing ✅ NativeStringHolder Move — Correctly Executed
✅ Error Handling — CompleteAll error paths are handled: contract failures throw exceptions caught by the ✅ Test Quality — GoodThe new 💡 Advisory: Test Strictness AssumptionThe test asserts
|
There was a problem hiding this comment.
Pull request overview
This PR wires DacDbiImpl.GetModuleSimpleName to the cDAC ILoader contract (instead of delegating only to legacy DAC), and adds dump-test coverage to ensure module simple names are available in dump-based scenarios.
Changes:
- Replace
ILoader.TryGetSimpleNamewithILoader.GetSimpleNameand update the contract implementation/docs accordingly. - Implement
DacDbiImpl.GetModuleSimpleNameusingILoader.GetSimpleNamewith DEBUG-only validation against legacy (when available). - Add/update unit + dump tests for the new simple-name retrieval behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/managed/cdac/tests/LoaderTests.cs | Updates loader unit tests to use GetSimpleName instead of TryGetSimpleName. |
| src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiLoaderDumpTests.cs | Switches debuggee and adds a dump test asserting GetModuleSimpleName returns S_OK and a non-empty name per module. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/NativeStringHolder.cs | Fixes the namespace and aligns HRESULT usage for the native string-holder test helper. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs | Implements GetModuleSimpleName via the cDAC loader contract and adds DEBUG validation against legacy output. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataModule.cs | Updates IXCLRDataModule.GetName to use ILoader.GetSimpleName. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs | Implements ILoader.GetSimpleName in the Loader v1 contract. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs | Changes the public ILoader interface surface to GetSimpleName. |
| docs/design/datacontracts/Loader.md | Updates contract documentation to reflect GetSimpleName. |
|
|
||
| return _target.ReadUtf8String(module.SimpleName, strict: true); |
| @@ -103,7 +103,7 @@ public interface ILoader : IContract | |||
| bool IsProbeExtensionResultValid(ModuleHandle handle) => throw new NotImplementedException(); | |||
| ModuleFlags GetFlags(ModuleHandle handle) => throw new NotImplementedException(); | |||
| bool IsReadyToRun(ModuleHandle handle) => throw new NotImplementedException(); | |||
| /// <summary> | ||
| /// Dump-based integration tests for DacDbiImpl loader, assembly, and module methods. | ||
| /// Uses the MultiModule debuggee (full dump), which loads assemblies from multiple ALCs. | ||
| /// Uses the StackRefs debuggee (full dump), which loads assemblies from multiple ALCs. | ||
| /// </summary> | ||
| public class DacDbiLoaderDumpTests : DumpTestBase | ||
| { | ||
| protected override string DebuggeeName => "MultiModule"; | ||
| protected override string DebuggeeName => "StackRefs"; |
| TargetPointer moduleAddr = loader.GetModule(module); | ||
|
|
||
| using var holder = new NativeStringHolder(); | ||
| int hr = dbi.GetModuleSimpleName(moduleAddr.Value, holder.Ptr); | ||
| Assert.Equal(System.HResults.S_OK, hr); | ||
| Assert.False(string.IsNullOrEmpty(holder.Value), "Module simple name should not be empty"); |
| [Theory] | ||
| [ClassData(typeof(MockTarget.StdArch))] | ||
| public void TryGetSimpleName(MockTarget.Architecture arch) | ||
| public void GetSimpleName(MockTarget.Architecture arch) | ||
| { | ||
| string expected = "TestModule"; | ||
| TargetPointer moduleAddr = TargetPointer.Null; | ||
| TargetPointer moduleAddrEmptyName = TargetPointer.Null; | ||
|
|
||
| ILoader contract = CreateLoaderContract(arch, loader => | ||
| { | ||
| moduleAddr = loader.AddModule(simpleName: expected).Address; | ||
| moduleAddrEmptyName = loader.AddModule().Address; | ||
| }); | ||
|
|
||
| { | ||
| Contracts.ModuleHandle handle = contract.GetModuleHandleFromModulePtr(moduleAddr); | ||
| bool result = contract.TryGetSimpleName(handle, out string actual); | ||
| Assert.True(result); | ||
| string actual = contract.GetSimpleName(handle); | ||
| Assert.Equal(expected, actual); | ||
| } | ||
| { | ||
| Contracts.ModuleHandle handle = contract.GetModuleHandleFromModulePtr(moduleAddrEmptyName); | ||
| bool result = contract.TryGetSimpleName(handle, out string actual); | ||
| Assert.False(result); | ||
| Assert.Equal(string.Empty, actual); | ||
| } | ||
| } |
| Contracts.ILoader loader = _target.Contracts.Loader; | ||
| Contracts.ModuleHandle handle = loader.GetModuleHandleFromModulePtr(new TargetPointer(vmModule)); | ||
| cdacSimpleName = loader.GetSimpleName(handle); | ||
| hr = StringHolderAssignCopy(pStrFilename, cdacSimpleName); |
Summary
Implement
GetModuleSimpleNameonDacDbiImplusing theILoadercontract, replacing legacy-only delegation.Changes
DacDbiImpl.cs- ImplementGetModuleSimpleNameviaILoader.TryGetSimpleNameDacDbiLoaderDumpTests.cs- Add dump test verifying all modules returnS_OKwith a non-empty simple name