Implement cDAC memory region APIs (GetHandleTableMemoryRegions, GetGCBookkeepingMemoryRegions, GetGCFreeRegions)#124926
Conversation
|
@copilot , we need to update the cDAC docs and write tests for these new APIs |
|
@copilot try again |
Updated the cDAC docs (GC.md) with new API types, data descriptors, globals, constants, and pseudocode for all three methods. Added 6 additional test methods covering edge cases (empty buckets, multiple linked segments, multiple bookkeeping entries, empty/multiple free regions). Total: 9 test methods × 4 architectures = 36 tests, all passing. See commit |
|
@copilot fix the build break |
|
Ah I will merge my changes into main and then this should work better |
|
@copilot please start over using the current |
There was a problem hiding this comment.
Pull request overview
This PR implements three ISOSDacInterface13 APIs (GetHandleTableMemoryRegions, GetGCBookkeepingMemoryRegions, GetGCFreeRegions) natively in the cDAC by extending the IGC contract. These APIs previously delegated to legacy DAC or returned E_NOTIMPL. The implementation follows the existing SOSMethodEnum pattern and includes comprehensive test coverage.
Changes:
- Added managed
ISOSMemoryEnumCOM interface andSOSMemoryEnumimplementation following theSOSMethodEnumpattern - Extended
IGCcontract with three new memory region enumeration methods, each with appropriate safety caps (8192/32/2048 iterations) - Added six new data types (
HandleTableMap,HandleTableBucket,HandleTable,HandleTableSegment,CardTableInfo,RegionFreeList) with corresponding native data descriptors and managed data classes - Extended
GCHeaptype descriptors andIGCHeapinterface with optional fields for free regions (conditional on GC build configuration)
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| GCMemoryRegionTests.cs | Comprehensive unit tests covering all three APIs with empty/single/multiple region scenarios (36 tests total) |
| SOSDacImpl.cs | Three new ISOSDacInterface13 method implementations calling IGC contract + new SOSMemoryEnum class |
| ISOSDacInterface.cs | Added SOSMemoryRegion struct and ISOSMemoryEnum interface, changed method signatures from void** to typed out ISOSMemoryEnum? |
| RegionFreeList.cs, HandleTableSegment.cs, HandleTableMap.cs, HandleTableBucket.cs, HandleTable.cs, CardTableInfo.cs | New managed data classes implementing IData<T> pattern |
| GCHeapSVR.cs | Added optional FreeableSohSegment, FreeableUohSegment, FreeRegions fields with conditional loading via ContainsKey |
| IGCHeap.cs | Extended interface with three new nullable TargetPointer? properties for free region tracking |
| GC_1.cs | Core implementation of three enumeration APIs with helper methods for walking handle tables, card tables, and free region lists |
| GCHeapWKS.cs | Added conditional loading of free region globals using TryReadGlobalPointer |
| Constants.cs | Added 12 new global constant names for handle tables, card tables, and free regions |
| DataType.cs | Added 6 new data type enum entries |
| IGC.cs | Added FreeRegionKind enum and GCMemoryRegionData struct to the contract interface, plus three new method signatures |
| datadescriptor.inc, datadescriptor.h | Native data descriptor definitions mapping runtime structures to cDAC types, including conditional field definitions |
| GC.md | Comprehensive documentation of new APIs, data structures, globals, and pseudocode algorithms |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Outdated
Show resolved
Hide resolved
Started over from the latest |
|
@copilot fix the build break |
Merge conflicts resolved in |
|
@copilot, you messed up the merge. You did pull in thousands of files. Please fix the merge so that only the files relevant to the PR are included. |
Fixed in |
This comment has been minimized.
This comment has been minimized.
|
@copilot, can you take a look at the CI failures and investigate? We should also address the feedback from comments |
Fixed in |
|
@copilot, can you try again? It seems like there are still CI failures |
Investigated and fixed in
Fixed in |
…sses Add native data descriptors for GC memory region types (CardTableInfo, RegionFreeList, GCHeapSVR/WKS bookkeeping fields). Add corresponding DataType enum entries, Constants.Globals, and IGCHeap interface methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add GetHandleTableMemoryRegions, GetGCBookkeepingMemoryRegions, and GetGCFreeRegions to the IGC contract interface. Implement all three in GC_1 with handle table bucket iteration, bookkeeping segment/card table enumeration, and region free list traversal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add SOSMemoryEnum class following the SOSHandleEnum pattern. Implement ISOSDacInterface13.GetHandleTableMemoryRegions, GetGCBookkeepingMemoryRegions, and GetGCFreeRegions with #if DEBUG validation against legacy DAC. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add GCMemoryRegionTests with coverage for handle table, bookkeeping, and free region enumeration including edge cases. Add ServerGC and WorkstationGC dump tests for end-to-end validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document GetHandleTableMemoryRegions, GetGCBookkeepingMemoryRegions, and GetGCFreeRegions APIs with data descriptor tables, globals, and implementation pseudocode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove duplicate CDAC_GLOBAL(HandleSegmentSize) entry that was introduced during merge with main (already present at line 143). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
- Remove duplicate HandleSegmentSize constant in Constants.cs - Use constructor-injected _handleSegmentSize instead of redundant global read - Fix off-by-one: use maxRegions > 0 for consistent safety cap boundary - Add MaxSegmentListIterations guard to handle table segment linked list loop Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🤖 Copilot Code Review — PR #124926Note This review was generated by GitHub Copilot using claude-opus-4.6. The GPT-5.4 multi-model sub-agent did not complete within the timeout window, so this review reflects a single-model analysis. Holistic AssessmentMotivation: This PR adds three GC memory region enumeration APIs ( Approach: The implementation follows established cDAC patterns: new data descriptors in native code, DataType entries, data classes, IGC contract interface extensions, GC_1 implementation, SOSDacImpl integration, and comprehensive tests. The design is sound with proper safety caps on linked list traversals, cycle detection, and DEBUG-mode validation against the legacy DAC. Summary: Detailed Findings✅ Correctness — Linked list traversals are safe and well-guardedAll three memory region enumeration methods in
✅ Pointer Indirection — FreeRegions vs FreeableSoh/UohSegment levels are correctI verified the different indirection levels are intentional and correct:
✅ Data Descriptor Consistency — All field names match across native and managed code
All constants in ✅ SOSDacImpl Integration — Follows established patternsThe three new
The ✅ Documentation — GC.md is comprehensive and accurateThe documentation adds data descriptor tables, global variables, and pseudocode for all three methods. The pseudocode matches the actual implementation logic, including safety caps and traversal patterns.
|
Implements three
ISOSDacInterface13APIs natively in the cDAC by extending theIGCcontract:GetHandleTableMemoryRegions,GetGCBookkeepingMemoryRegions, andGetGCFreeRegions. These APIs previously delegated to legacy DAC or returnedE_NOTIMPL.Description
SOSMemoryEnum
SOSMemoryEnumimplementation following theSOSHandleEnumpattern, with built-in#if DEBUGvalidation against the legacy DAC enum (validatesStart,Size,ExtraData,Heapfields onNext(),Skip(),Reset(), andGetCount())IGC Contract Extensions
IGCcontract with three new memory region enumeration methodsMaxHandleTableRegions(8192),MaxBookkeepingRegions(32),MaxSegmentListIterations(2048)GetGCFreeRegionsusesTryReadGlobalforCountFreeRegionKindsto gracefully handle non-regions GC buildsheap.FreeRegionsvalue in server GC pathnext > cardTableInfoSize) matching native DACdaccess.cpp:8313Data Types & Descriptors
CardTableInfoandRegionFreeListdata classesGCHeaptype descriptors with optional fields (FreeableSohSegment,FreeableUohSegment,FreeRegions) conditional on GC build configuration (BACKGROUND_GC,USE_REGIONS)Documentation & Tests
docs/design/datacontracts/GC.mdwith new API types, data descriptors, globals, constants, and pseudocode following cDAC best practices (field-access patterns usingtarget.ReadPointer(addr + /* offset */)instead ofRead<DataType>()syntax)GCMemoryRegionTests.cs) covering single/multiple segments, empty buckets, linked segments, bookkeeping entries, and free regionsServerGCDumpTests.csandWorkstationGCDumpTests.csMerge Conflict Resolution
origin/maininGC.mdandGC_1.cs, integrating the newGetHandleExtraInfoimplementation from main alongside the memory region APIsorigin/mainHandleSegmentSizeconstant introduced by the mergeCI Fix
origin/main, ensuring the diff contains exactly 16 PR-specific files💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.