Skip to content

Add method extent enumeration support to legacy cDAC - #130996

Merged
rcj1 merged 6 commits into
mainfrom
copilot/6944fe7764ae6f34a8079864f0f79cc0e6eb59a8-0e94bde20
Jul 20, 2026
Merged

rcj1 merged 6 commits into
mainfrom
copilot/6944fe7764ae6f34a8079864f0f79cc0e6eb59a8-0e94bde20

Conversation

Copilot AI commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

This change adds the minimal legacy cDAC support needed to expose a method extent through IXCLRDataMethodInstance by implementing StartEnumExtents, EnumExtent, and EndEnumExtents.

Copilot AI review requested due to automatic review settings July 17, 2026 19:56

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 was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI temporarily deployed to copilot-pat-pool July 17, 2026 19:57 Inactive
Copilot AI changed the title [WIP] Add support for method extent enumeration in legacy cDAC [WIP] Add method extent enumeration support to legacy cDAC Jul 17, 2026
Copilot finished work on behalf of rcj1 July 17, 2026 19:57
Copilot AI requested a review from rcj1 July 17, 2026 19:57
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI review requested due to automatic review settings July 18, 2026 05:24

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 was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI review requested due to automatic review settings July 18, 2026 05:30

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 was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI review requested due to automatic review settings July 18, 2026 05:31

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 was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot finished work on behalf of rcj1 July 18, 2026 05:31
Copilot AI review requested due to automatic review settings July 20, 2026 01:50
@rcj1 rcj1 changed the title [WIP] Add method extent enumeration support to legacy cDAC Add method extent enumeration support to legacy cDAC Jul 20, 2026
@rcj1
rcj1 requested a review from noahfalk July 20, 2026 02:04
@rcj1
rcj1 requested review from barosiak and max-charlamb July 20, 2026 02:04
@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.

@rcj1
rcj1 marked this pull request as ready for review July 20, 2026 02:05
@azure-pipelines

Copy link
Copy Markdown
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.

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

@github-actions

github-actions Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow state for the Holistic Review Orchestrator.

{
  "version": 5,
  "last_dispatched_commit": "40639fcb480e209eb086e4351053aaf550d9ce78",
  "last_dispatched_base_ref": "main",
  "last_dispatched_base_sha": "f94898a9b55df07348434e86915c7405962427b6",
  "last_reviewed_commit": "40639fcb480e209eb086e4351053aaf550d9ce78",
  "last_reviewed_base_ref": "main",
  "last_reviewed_base_sha": "f94898a9b55df07348434e86915c7405962427b6",
  "last_recorded_worker_run_id": "29766975575",
  "review_attempt_commit": "",
  "review_attempt_base_ref": "",
  "review_attempt_count": 0,
  "max_review_attempts": 5,
  "review_history_format": "holistic-review-disclosure-v1",
  "review_history": [
    {
      "commit": "5918b959829472ddc7c203e53f9a033304ae3493",
      "review_id": 4732021351
    },
    {
      "commit": "40639fcb480e209eb086e4351053aaf550d9ce78",
      "review_id": 4737838875
    }
  ]
}

@github-actions github-actions Bot 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.

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 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, would be nice to add a dump test for this new set of APIs.

Copilot AI review requested due to automatic review settings July 20, 2026 17:51

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 was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot finished work on behalf of rcj1 July 20, 2026 18:02

@github-actions github-actions Bot 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.

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 5918b95 with 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

@rcj1
rcj1 merged commit c16ef06 into main Jul 20, 2026
71 checks passed
@rcj1
rcj1 deleted the copilot/6944fe7764ae6f34a8079864f0f79cc0e6eb59a8-0e94bde20 branch July 20, 2026 21:59
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 23, 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