Repository navigation
Use DAC GCInfo interfaces for X86 SOS reporting, and address bugs in DAC GCInfo interface handling for other platforms - #6198
Merged
davidwrighton merged 5 commits intoNov 10, 2026
Conversation
Display X86 headers and decoded push/pop transitions, correct common slot formatting and preserve compatibility with legacy GCInfo output in SOS tests. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
Delegate register naming and optional X86 details to IMachine without changing machine-selection guards. Only missing Interface18 permits automatic legacy decoding; report errors from available interfaces. Preserve the explicit -legacy comparison switch. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
Respect the pointer flag for EBP push reporting and label pops as argument counts rather than pointer counts. Regress against legacy output from the existing dictionary scenario under X86 Cdb and dotnet-dump cDAC configurations. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
Move the prebuilt Interface19 GUID definition before MIDL_DEFINE_GUID is undefined. Directly compile the checked-in file in both GUID macro configurations. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
Follow existing machine-class virtual declaration style to avoid Clang's inconsistent-missing-override errors. Gate supplemental X86 assertions on actual reporting capability rather than DAC selection. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
davidwrighton
marked this pull request as ready for review
November 10, 2026 19:51
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the DAC-based X86 GCInfo reporting and formatting changes.
No open issues 🎉
What changed in this PR
Adds prototype DAC-interface-based X86 GCInfo reporting to SOS, paired with the companion runtime changes. It also improves shared GCInfo formatting while preserving legacy decoding for runtimes without Interface18 and explicit -legacy comparisons.
Changes:
- Uses Interface18 for common GCInfo and optional Interface19 for X86 details, with architecture-specific formatting through
IMachine. - Corrects root and argument formatting and reports interface failures instead of silently falling back.
- Updates parsers and tests for legacy/interface output, including X86 non-pointer push/pop regression coverage.
| File | Description |
|---|---|
src/tests/SOS.Tests/CodeInfoTests.cs |
Adds legacy comparisons and X86 push/pop regression checks. |
src/tests/SOS.Tests/CodeCommandParsingTests.cs |
Tests hexadecimal sizes and qualified interface roots. |
src/tests/SOS.Tests/CodeCommandParsing.cs |
Supports -legacy and expanded GCInfo output formats. |
src/tests/SOS.Tests/ClrUTests.cs |
Checks standalone and interleaved GCInfo consistency. |
src/SOS/Strike/strike.cpp |
Restricts automatic fallback to absent Interface18 and reports failures. |
src/SOS/Strike/gcinfoprovider.h |
Adds X86 supplemental data storage and clarifies creation results. |
src/SOS/Strike/gcinfoprovider.cpp |
Validates interface results and improves root and transition formatting. |
src/SOS/Strike/exts.h |
Adds machine-specific GCInfo retrieval and formatting hooks. |
src/SOS/Strike/disasmRISCV64.cpp |
Provides RISC-V register-name mapping for interface output. |
src/SOS/Strike/disasmLOONGARCH64.cpp |
Provides LoongArch register-name mapping for interface output. |
src/SOS/Strike/disasm.h |
Declares architecture-specific GCInfo overrides. |
src/SOS/Strike/disasm.cpp |
Implements X86 supplemental reporting and register-name mappings. |
src/shared/pal/prebuilt/inc/sospriv.h |
Adds prebuilt Interface19 declarations and X86 data structures. |
src/shared/pal/prebuilt/idl/sospriv_i.cpp |
Adds the Interface19 identifier. |
src/shared/inc/sospriv.idl |
Defines the optional X86 GCInfo interface contract. |
Review effort: Balanced
max-charlamb
approved these changes
Nov 10, 2026
This was referenced Nov 13, 2026
davidwrighton
added a commit
to dotnet/runtime
that referenced
this pull request
Nov 17, 2026
## Summary Implement cDAC GCInfo inspection through **ISOSDacInterface18** and **ISOSDacInterface19**, and correct the X86 decoding and lifetime projection needed to make that information useful to diagnostic tools. Together, the interfaces let consumers such as SOS obtain decoded GC headers, interruptibility, safe points, root lifetimes, and X86-specific stack transitions from the DAC instead of maintaining their own interpretation of the runtime's encoded GCInfo. ## ISOSDacInterface18: normalized GCInfo inspection Provide the cDAC implementation of all four existing Interface18 methods: | API | Information returned | | --- | --- | | `GetGCInfoHeader` | Encoding version, method/prolog sizes, frame register, parameter area, and available GS-cookie, PSP, and generics-context information. | | `GetGCInfoInterruptibleRanges` | Ranges in which execution is fully interruptible. | | `GetGCInfoSafePoints` | Discrete safe-point offsets. | | `GetGCInfoSlotLifetimes` | Register and stack-root locations, lifetime intervals, and interior/pinned/untracked qualifiers. | - Resolve the supplied managed-code address through the execution manager, obtain its GCInfo address/version, and select the native or interpreter decoder as appropriate. - Normalize contract stack-base identifiers to the existing Interface18 representation: SP-relative or relative to the header's frame register. - Keep partially interruptible X86 call-site ranges available to stack walking, but expose those call sites through the safe-point API rather than misreporting them as fully interruptible regions. - Support count-then-fetch enumeration, report required capacity with `S_FALSE`, validate caller buffers/header sizes, and translate failures to HRESULTs. The existing Interface18 ABI is unchanged; this PR supplies its cDAC implementation. ## ISOSDacInterface19: supplemental X86 details Add a separately queryable interface for information that cannot be represented by Interface18's normalized root model: | API | Information returned | | --- | --- | | `GetGCInfoX86Header` | Epilog information, saved-register mask, argument/frame sizes, frame and method flags, untracked/VarPtr counts, synchronization/no-GC metadata, argument-table metadata, return kind, and reverse P/Invoke offset. | | `GetGCInfoX86Epilogs` | Epilog start offsets. | | `GetGCInfoX86Transitions` | Decoded register live/dead, push/pop, kill, stack-depth, receiver-register, interior-mask, and call records. | Transition records preserve code offsets, register identifiers, argument counts/indices or masks, pointer/interior/receiver flags, and stack-depth deltas where represented. Ordinary EBP pointer push/pop records currently report zero stack delta; bulk stack-depth records report their byte delta. Add the corresponding `IGCInfo` contract methods and data types, managed COM declarations, native IDL, and checked-in native interface definitions. Supplemental data requires a native X86 decoder; other decoders report `E_NOTIMPL` through the COM interface. Interface18 consumers do not need to use Interface19. ## X86 decoder and lifetime correctness - Retain interior qualifiers from register LIVE records instead of trying to recover them from later DEAD records. - Project root state by code offset, coalescing adjacent intervals only when both the location and qualifiers match. - Track outgoing argument depth, pointer indices, and pointer-index gaps. Recompute ESP-relative root/local locations as the stack moves, while using the stable frame-relative argument base for ordinary EBP frames. - Count **all** stack entries when processing fully interruptible pops, including non-pointer arguments. Popping a non-pointer entry must not remove a pointer root below it. - Handle both single non-pointer pushes and bulk stack-depth adjustments, including the GCInfo operations corresponding to constant method-body `sub esp, N` / `add esp, N`. - Treat KILL as invalidating the indicated highest pointer arguments without popping the argument stack. - Report partially interruptible call roots only at their call-site offsets rather than inventing tracked liveness between calls. - Separate huge-call argument offsets from their encoded interior flags and preserve explicit argument roots and receiver metadata. - Exclude explicit no-GC regions from fully interruptible ranges. - Accept valid register-death transitions at the method end while rejecting out-of-range transitions and invalid local-lifetime bounds. - Preserve untracked and pinned/interior qualifiers when stack movement splits a location's lifetime. These changes address the X86 problems illustrated in [this GCInfo investigation](https://gist.github.com/davidwrighton/1f07d7c37e663beebb32b07f384fdc32). ## Tests and documentation Add focused coverage for COM interface discovery and calls, header/decoder selection, stack-base normalization, count/fetch buffer semantics, invalid arguments, initialized failure outputs, and unsupported supplemental decoders. X86 regressions cover GCInfo versions 4 and 5, interior-register lifetimes, pushed pointers, non-pointer single/bulk stack changes in EBP and ESP frames, KILL, pointer-index gaps, huge calls, receiver metadata, explicit no-GC regions, and method-end transitions. An encoded GCInfo fixture from an actual pinned/interior-root method exercises the combined projection. Document the X86 diagnostic contract, units, flags, lifetime semantics, and limitations in `docs/design/datacontracts/GCInfo.md`. The specification describes contract APIs independently of the SOS COM adapter. ## SOS integration The companion SOS consumer changes are in dotnet/diagnostics#6198. They format the interface data for `!gcinfo` and `!u -gcinfo`, use Interface19 for supplemental X86 reporting, and retain legacy decoding for older runtimes without Interface18. The diagnostics changes are intended to merge first so runtime SOS integration tests use the updated formatter and output expectations. ## Local validation - Windows X64 and genuine Windows X86: 347 focused runtime tests passed per architecture, covering GCInfoTests, GCInfoHeaderTests, and StackWalkTests. - With the companion diagnostics changes: 20 SOS/parser tests passed per architecture, exercising Legacy/CDac through Cdb and dotnet-dump. - New EBP non-pointer pop regressions failed before the decoder fix; the real-output SOS regression also failed against the old formatter. - Native cDAC binaries were checked for the correct PE architecture. - Analyzer-enabled Abstractions/Contracts rebuilds and focused C# whitespace checks passed. ## Known limitations Dynamic localloc and funclet argument bases require per-frame execution state and are not fully reconstructed by the static lifetime projection. The diagnostic transition interface exposes decoded records, not raw GCInfo encoding bytes, and those records do not distinguish arithmetic stack adjustments from equivalent push/pop operations. > [!NOTE] > This PR and its description were prepared with GitHub Copilot. --------- Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820 Copilot-Session: 35abd219-305c-4a6c-b33d-3a4d7a665c88
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prototype SOS support for interface-based X86 GCInfo reporting, paired with the runtime cDAC changes.
!gcinfo -legacyfor comparison.Companion runtime draft PR: dotnet/runtime#137119
Compatibility and scope
.NET 8/9/10 retain the legacy route when the interfaces are unavailable; tests do not require cDAC on those runtimes. Local integration validation used the private runtime with both Legacy and CDac, not separate .NET 8/9/10 installations.
This is a reporting prototype, not a change to machine selection or a complete cross-target disassembler implementation. Dynamic localloc and funclet argument-base limitations remain in the companion runtime's static projection.
Local validation
Note
This PR and its description were prepared with GitHub Copilot.