Repository navigation
Add method extent enumeration support to legacy cDAC - #130996
Conversation
Co-authored-by: rcj1 <[email protected]>
|
Azure Pipelines: Successfully started running 4 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. |
Co-authored-by: rcj1 <[email protected]>
Co-authored-by: rcj1 <[email protected]>
Co-authored-by: rcj1 <[email protected]>
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
|
Workflow state for the Holistic Review Orchestrator. |
There was a problem hiding this comment.
Holistic Review
Motivation: The legacy cDAC (Microsoft.Diagnostics.DataContractReader.Legacy) is progressively reimplementing the native DAC's IXCLRData* COM surface so managed code can serve diagnostic clients. IXCLRDataMethodInstance's extent enumeration (StartEnumExtents/EnumExtent/EndEnumExtents) was previously stubbed to E_NOTIMPL (with a legacy fallback). This PR fills that gap by exposing a method's single native code extent, matching ClrDataAccess::GetMethodExtents in src/coreclr/debug/daccess/daccess.cpp.
Approach: A new ClrDataAddressRange struct is added to IXCLRData.cs and the EnumExtent signature is tightened from void* to ClrDataAddressRange*. The implementation introduces a private EnumMethodExtents : IEnum<ClrDataAddressRange> enumerator holding a single-element sequence, and follows the established GCHandle-based enumerator lifecycle used elsewhere in this assembly (e.g. ClrDataModule.EnumMethodDefinitionByName). GetMethodExtent() computes the start via RuntimeTypeSystem.GetNativeCode + PrecodeStubs.GetInterpreterCodeFromInterpreterPrecodeIfPresent and the length from GC info (interpreter vs. platform-specific decoding), mirroring the existing SOSDacImpl MethodSize logic. DEBUG builds cross-validate cDAC results against the legacy DAC via Debug.ValidateHResult and value asserts, consistent with the rest of the file.
Summary: This is a focused, well-scoped addition that faithfully mirrors both the native DAC semantics and the existing cDAC conventions in this assembly (enumerator pattern, #if DEBUG legacy cross-checks, HRESULT-from-exception translation). The extent computation matches the native reference (methodStart + GetFunctionSize) and the interpreter/JIT GC-info branching matches the sibling SOSDacImpl code. Error handling correctly maps E_NOINTERFACE (null code) and surfaces exception HResults. I found no correctness blockers. One minor robustness nit is raised inline: StartEnumExtents does not zero *handle on the failure path, unlike the sibling ClrDataModule implementations. Verdict: LGTM with a minor optional suggestion.
Detailed Findings
See the inline comment on ClrDataMethodInstance.cs regarding initializing *handle = 0 on the StartEnumExtents failure path for defensiveness and parity with ClrDataModule.StartEnumExtents.
No test files are included. Consistent with much of the legacy cDAC surface, correctness is guarded at runtime by the DEBUG-mode legacy cross-validation rather than unit tests; that is acceptable here, though a dump-based test exercising EnumExtent would strengthen coverage if practical.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 114.7 AIC · ⌖ 10.2 AIC · ⊞ 10K
max-charlamb
left a comment
There was a problem hiding this comment.
lgtm, would be nice to add a dump test for this new set of APIs.
Co-authored-by: rcj1 <[email protected]>
There was a problem hiding this comment.
Holistic Review
Motivation: Unchanged from the prior review. The PR fills a gap in the legacy cDAC (Microsoft.Diagnostics.DataContractReader.Legacy) by implementing IXCLRDataMethodInstance extent enumeration (StartEnumExtents/EnumExtent/EndEnumExtents), which was previously stubbed to E_NOTIMPL, mirroring the native DAC's ClrDataAccess::GetMethodExtents. The one new commit adds a dump-based integration test, which is a natural and valuable complement to the feature.
Approach: Unchanged. The implementation keeps the established GCHandle-based enumerator lifecycle and #if DEBUG legacy cross-validation. The new commit adds MethodInstance_EnumExtents_ReturnsSingleRangeContainingInstructionPointer, a [ConditionalTheory] in StackWalkDumpTests.cs. It walks the crashing thread, locates the MethodC frame, constructs a ClrDataMethodInstance with legacyImpl: null (so it validates the pure cDAC path rather than only the DEBUG cross-check), and asserts StartEnumExtents returns S_OK with a non-zero handle, EnumExtent yields a single range whose bounds contain the frame's instruction pointer, a second EnumExtent returns S_FALSE, and EndEnumExtents cleans up in a finally. This directly addresses the prior review's suggestion that a dump-based test would strengthen coverage.
Summary: ✅ LGTM. The incremental change is a focused, correct test addition that follows the conventions of the surrounding tests ([ConditionalTheory] + [MemberData(nameof(TestConfigurations))] + SkipOnVersion, finally-based handle cleanup, AssertHResult helper). The handle lifecycle is exercised correctly (S_OK → range → S_FALSE, with EndEnumExtents guarded on handle != 0), the Assert.InRange upper bound uses endAddress - 1 to reflect the half-open extent, and Assert.Fail guards against silently passing if MethodC is absent. Testing the legacyImpl: null path is stronger than relying on the DEBUG cross-check alone. I found no correctness or convention issues in the added test, and no new findings in the previously reviewed code (unchanged this iteration).
Assessment History
- review 4732021351 reviewed commit
5918b95with an LGTM verdict. Current verdict is also LGTM. The overall assessment (motivation, approach, risk) is unchanged; the only new commit (40639fc) adds a dump-based test that implements the earlier review's optional suggestion, so no verdict change was warranted.
Detailed Findings
No actionable findings in the incremental change. The new test is well-formed and consistent with the existing dump-test patterns in StackWalkDumpTests.cs.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 95.7 AIC · ⌖ 10.8 AIC · ⊞ 10K
This change adds the minimal legacy cDAC support needed to expose a method extent through
IXCLRDataMethodInstanceby implementingStartEnumExtents,EnumExtent, andEndEnumExtents.