Repository navigation
Implement cDAC GCInfo inspection with ISOSDacInterface18/19 - #137119
Conversation
Expose the existing GCInfo inspection interface through the cDAC COM object. Forward header, interruptible-range, safe-point, and slot-lifetime queries to the appropriate platform or interpreter decoder, with sized-buffer and HRESULT handling. Add regression coverage for interface discovery, unmanaged vtable calls, field mappings, buffer sizing, and failure outputs. Validate the NativeAOT cDAC build and 626 focused tests. Co-authored-by: Copilot <[email protected]>
Keep ISOSDacInterface18 stack-base semantics independent of decoder enums and GCInfo versions. Document the existing API values and cover v5/v6 decoding, native COM output, and unsupported bases. Co-authored-by: Copilot <[email protected]>
Correct X86 root lifetimes, stack movement, call qualifiers and no-GC ranges. Expose optional X86 headers and decoded transitions for SOS, with contract documentation and decoder/COM regressions. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
Accept terminal transitions for fully interruptible methods while rejecting offsets beyond the code size. Cover the boundary and a real pinned/interior-root method, including Interface18 projection. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
Use total argument stack depth for fully interruptible EBP pops, preserving pointer roots below non-pointer arguments. Cover single and bulk adjustments for both frame styles and encoding versions, and correct the prototype documentation. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
Describe X86 transitions, safepoints, and slot lifetimes using contract APIs. Remove SOS interface and HRESULT bridge details from the contract specification. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
|
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 |
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
|
How far are we from being able to call cDAC managed APIs directly in SOS commands? Encapsulating intricate implementation details like this in COM interfaces is unfortunate. |
Place each enum member on its own line to satisfy StyleCop SA1136. Leave the expected diagnostics-version mismatch failures unchanged. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
We are working on this. Once we release diagnostics tooling for net11, I have a bunch of changes for SOS to support NativeAOT builds. Then we can compile it together with the cDAC and call the APIs directly for new features. We will still need to call through the |
Make ApplyPointerTransition static now that it no longer reads decoder instance state, satisfying CA1822 in the analyzer-enabled CI build. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
|
@max-charlamb ... do you think I should drop the X86 changes, and just add some tweak like.. X86 platform ignores the GCInfo dac interfaces and just does its own thing until this is all ready? Also, do you think you would want to keep the cDAC changes here regardless? |
|
I don't love having a separate set of APIs specifically for x86, however it will be a good amount of time before we are ready to call the cDAC contracts directly from SOS. If this provides debugging value now, it looks reasonable to me and should be good to add. |
Correct transition field semantics and stale frame/timing comments. Explain packed argument flags, stack-base translation, call-root intervals, and encoded test fixtures. Remove remaining prototype wording from the contract specification. Comments and documentation only; no behavior or ABI changes. Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
…DAC GCInfo interface handling for other platforms (#6198) ## Summary Prototype SOS support for interface-based X86 GCInfo reporting, paired with the runtime cDAC changes. - Use ISOSDacInterface18 for common GCInfo data and optional ISOSDacInterface19 for X86 supplemental headers, epilogs, argument push/pop, KILL, and stack-depth details. - Delegate architecture-specific register names and supplemental formatting through IMachine. Existing macro-guarded machine implementation selection is deliberately unchanged. - Fix formatting of pinned/interior roots and EBP non-pointer pushes. Pop counts describe all arguments, not only pointers. - Automatically use the built-in parser only when Interface18 is absent. Errors from available interfaces are reported explicitly rather than silently falling back. Preserve explicit `!gcinfo -legacy` for comparison. - Update tests/parsing to accept both legacy and interface output, and add a real-output X86 regression comparing non-pointer pushes and pops against the legacy encoding. 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 - Native SOS builds passed on Windows X86 and X64. - 20 SOS/parser tests passed per architecture with Legacy/CDac through Cdb and dotnet-dump; no skips. - The X86 non-pointer reporting regression failed under both hosts against the old formatter and passed after the fix. - The companion runtime passed 347 focused tests per architecture. - Captured legacy/interface output for RootsScenario, including pinned/interior locals, register lifetimes, and pointer argument push/pop. - C# whitespace checks passed. > [!NOTE] > This PR and its description were prepared with GitHub Copilot. --------- Co-authored-by: Copilot <[email protected]> Copilot-Session: 352b31fe-6b43-42a3-89cf-1944f4642820
There was a problem hiding this comment.
🟡 Changes recommended
The EBP mapping can make live GC enumeration resolve fully interruptible funclet argument roots to parent-frame addresses instead of their correct ESP-relative locations.
4 open issues
What changed in this PR
This PR enables cDAC-based GCInfo inspection for diagnostic tools through ISOSDacInterface18 and adds supplemental X86 details through ISOSDacInterface19.
Changes:
- Implements normalized GCInfo queries and adds X86 header, epilog, and transition interfaces.
- Corrects X86 root lifetime projection, stack movement handling, interior flags, and interruptibility.
- Adds COM and decoder regression tests and documents the contract’s semantics and limitations.
| File | Description |
|---|---|
src/native/managed/cdac/tests/UnitTests/GCInfoTests.cs |
Adds COM interface and X86 decoding regression coverage. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs |
Implements Interface18/19 queries, validation, and result mapping. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ISOSDacInterface.cs |
Declares Interface19 and its managed data structures. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GCInfo/X86/GCInfo.cs |
Updates root projection and exposes X86 diagnostic details. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GCInfo/X86/GCArgTable.cs |
Corrects argument-depth tracking and huge-call offset decoding. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GCInfo/GCInfoX86_1.cs |
Connects supplemental contract methods to the X86 decoder. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IGCInfo.cs |
Adds X86 diagnostic methods and data types. |
src/coreclr/pal/prebuilt/inc/sospriv.h |
Adds checked-in native Interface19 declarations. |
src/coreclr/pal/prebuilt/idl/sospriv_i.cpp |
Defines the Interface19 identifier. |
src/coreclr/inc/sospriv.idl |
Defines the supplemental X86 COM interface and structures. |
docs/design/datacontracts/GCInfo.md |
Documents X86 projection rules, units, flags, and limitations. |
Review effort: Balanced
- Fix funclet pushed-root base, EBP interior-pointer flag, and non-pointer push indices in the x86 GCInfo decoder. - Normalize GS cookie offsets to caller SP (including callee-popped bytes) and add SpecialSlotBase.InitialStackPointer for double-aligned frames. - Interface18: document caller-SP-relative special slots and lifetime base value 2 (caller SP); report unrepresentable GS cookies as absent. - Interface19: add GSCookieBase/Offset/ValidRange fields to SOSGCInfoX86Header so double-aligned cookies can be reported. - Add regression tests and update the GCInfo data contract docs. Co-authored-by: Copilot <[email protected]> Copilot-Session: 35abd219-305c-4a6c-b33d-3a4d7a665c88
…prototype/x86-cdac-gcinfo
ContextHolder.GetBytes now returns a span (dotnet#137102). Co-authored-by: Copilot <[email protected]> Copilot-Session: 35abd219-305c-4a6c-b33d-3a4d7a665c88
There was a problem hiding this comment.
🔵 Needs a closer look
The X86 decoder changes affect shared GC-root stack walking and need specialist review because native-decoder parity and Windows X86 SOS/cDAC behavior could not be independently validated.
No open issues 🎉
4 resolved since last review
Review effort: Balanced
|
/ba-g known issues...
|


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:
GetGCInfoHeaderGetGCInfoInterruptibleRangesGetGCInfoSafePointsGetGCInfoSlotLifetimesS_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:
GetGCInfoX86HeaderGetGCInfoX86EpilogsGetGCInfoX86TransitionsTransition 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
IGCInfocontract methods and data types, managed COM declarations, native IDL, and checked-in native interface definitions. Supplemental data requires a native X86 decoder; other decoders reportE_NOTIMPLthrough the COM interface. Interface18 consumers do not need to use Interface19.X86 decoder and lifetime correctness
sub esp, N/add esp, N.These changes address the X86 problems illustrated in this GCInfo investigation.
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
!gcinfoand!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
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.