Implement ISOSDacInterface12::GetGlobalAllocationContext in cDAC SOSDacImpl#124805
Implement ISOSDacInterface12::GetGlobalAllocationContext in cDAC SOSDacImpl#124805
Conversation
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
…acImpl - Add CDAC_GLOBAL_POINTER for g_global_alloc_context in VM data descriptor - Add GlobalAllocContext constant to Constants.Globals - Implement GetGlobalAllocationContext using Target type info and ReadPointer to read EEAllocContext/GCAllocContext data, matching native request.cpp behavior - Add dump test in WorkstationGCDumpTests to verify the API Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
|
@copilot, You should update the GC.md contract to add the new datadescriptor. Additionally, this should be accessed through the contract layer. |
- Add GetGlobalAllocationContext to IGC interface - Implement in GC_1.cs using EEAllocContext/GCAllocContext Data types - Update SOSDacImpl.cs to call _target.Contracts.GC instead of direct reads - Document EEAllocContext type, GlobalAllocContext global, and API in GC.md - Update dump test to use contract layer Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Done in e9b1e15. Added |
max-charlamb
left a comment
There was a problem hiding this comment.
@copilot, address feedback
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Outdated
Show resolved
Hide resolved
…nit in comparison block Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements ISOSDacInterface12::GetGlobalAllocationContext in the cDAC SOSDacImpl, providing access to the global allocation context pointer and limit through the GC contract. The implementation mirrors the native ClrDataAccess::GetGlobalAllocationContext in request.cpp by exposing the g_global_alloc_context global variable and routing calls through the GC contract layer.
Changes:
- Exposes
g_global_alloc_contextas a global pointer and implements the GC contract method to read it - Implements cDAC SOSDacImpl method with proper error handling and DEBUG legacy comparison
- Adds dump test to verify the global allocation context is readable with valid pointer invariants
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/datadescriptor/datadescriptor.inc | Exposes g_global_alloc_context as GlobalAllocContext global pointer |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs | Adds GlobalAllocContext constant for the global name |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IGC.cs | Adds GetGlobalAllocationContext method signature to the IGC contract interface |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GC/GC_1.cs | Implements GetGlobalAllocationContext using ProcessedData.GetOrAdd to traverse EEAllocContext → GCAllocContext |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs | Replaces legacy delegation with cDAC implementation including parameter validation, error handling, and DEBUG comparison |
| docs/design/datacontracts/GC.md | Documents the EEAllocContext data type, GlobalAllocContext global, API signature, and implementation pseudocode |
| src/native/managed/cdac/tests/DumpTests/WorkstationGCDumpTests.cs | Adds test validating global allocation context readability and pointer invariant (allocPtr <= allocLimit) |
Comments suppressed due to low confidence (1)
src/native/managed/cdac/tests/DumpTests/WorkstationGCDumpTests.cs:92
- The test is missing the
[SkipOnVersion("net10.0", "GC contract is not available in .NET 10 dumps")]attribute that all other GC contract tests in this file have. This attribute should be added to ensure the test is skipped on .NET 10 dumps where the GC contract is not available, maintaining consistency with the other tests in this file.
[ConditionalTheory]
[MemberData(nameof(TestConfigurations))]
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Outdated
Show resolved
Hide resolved
…back Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
This was already addressed in e9b1e15 — GC.md was updated with the |
Description
Implements
GetGlobalAllocationContextin the cDACSOSDacImpl, matching the nativeClrDataAccess::GetGlobalAllocationContextinrequest.cpp. The implementation is routed through the GC contract layer. Adds a dump test using the GCRoots debuggee.Changes
datadescriptor.inc): Exposeg_global_alloc_contextasCDAC_GLOBAL_POINTER(GlobalAllocContext, ...)GlobalAllocContextglobal name constantGetGlobalAllocationContext(out TargetPointer allocPtr, out TargetPointer allocLimit)to theIGCcontract interfaceGetGlobalAllocationContextusingEEAllocContext/GCAllocContextData types viaProcessedData.GetOrAdd_target.Contracts.GC.GetGlobalAllocationContext(), usingArgumentExceptionfor null parameter validation inside the try block and#if DEBUGlegacy comparison withdefault-initialized localsEEAllocContextdata descriptor type,GlobalAllocContextglobal variable, new API signature, and pseudocode implementationWorkstationGC_GlobalAllocationContextIsReadabletest validating the global is readable via the contract layer andallocPtr <= allocLimitThe implementation reads the global pointer through the GC contract, which navigates
EEAllocContext→GCAllocContextusing the internal Data types, then extractsPointerandLimit— mirroring how the native DAC dereferences((ee_alloc_context)g_global_alloc_context).m_GCAllocContext.Fixes #124824
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.