Skip to content

Implement ISOSDacInterface::GetThreadAllocData in cDAC SOSDacImpl#124817

Merged
max-charlamb merged 10 commits intomainfrom
copilot/implement-get-thread-alloc-data
Feb 26, 2026
Merged

Implement ISOSDacInterface::GetThreadAllocData in cDAC SOSDacImpl#124817
max-charlamb merged 10 commits intomainfrom
copilot/implement-get-thread-alloc-data

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

  • Add AllocBytes and AllocBytesLoh fields to GCAllocContext in datadescriptor.inc
  • Extend managed GCAllocContext data class with corresponding long properties
  • Add GetThreadAllocContext with out parameters to IThread contract; implement in Thread_1
  • Define managed DacpAllocData struct and implement GetThreadAllocData in SOSDacImpl
  • Add unit tests and dump test
  • Update documentation (Thread.md, GC.md)
  • Address review: move checks inside try, use NullReferenceException for E_POINTER, rename to GetThreadAllocContext
  • Address review: remove extra whitespace in Thread_1.cs
  • Fix build break: add missing MockDescriptors.Thread setup in GetThreadAllocContext test
  • Address review: replace ThreadAllocData struct with out parameters on GetThreadAllocContext
  • Fix merge conflict artifacts in GC.md

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Copilot AI and others added 2 commits February 24, 2026 21:02
- Add AllocBytes and AllocBytesLoh fields to GCAllocContext data descriptor
- Add ThreadAllocData record struct and GetThreadAllocData to IThread contract
- Implement GetThreadAllocData in Thread_1.cs contract
- Define DacpAllocData managed struct in ISOSDacInterface.cs
- Implement GetThreadAllocData in SOSDacImpl.cs with DEBUG comparison
- Add unit tests for GetThreadAllocData with non-zero and zero values
- Add dump test for GetThreadAllocData
- Update Thread.md and GC.md documentation

Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement GetThreadAllocData in SOSDacImpl Implement ISOSDacInterface::GetThreadAllocData in cDAC SOSDacImpl Feb 24, 2026
Copy link
Member

@max-charlamb max-charlamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , address feedback

…eption for E_POINTER, rename to GetThreadAllocContext

Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 24, 2026

@copilot , address feedback

All three review comments addressed in 9fbc6c9. All 840 tests pass.

Copy link
Member

@max-charlamb max-charlamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , address feedback

@max-charlamb max-charlamb marked this pull request as ready for review February 24, 2026 21:52
Copilot AI review requested due to automatic review settings February 24, 2026 21:52
Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements ISOSDacInterface::GetThreadAllocData in the cDAC-based SOSDacImpl by exposing per-thread GC allocation byte counters from gc_alloc_context through the managed contracts and data descriptors.

Changes:

  • Added AllocBytes / AllocBytesLoh fields to the GCAllocContext data descriptor and managed data model.
  • Extended the IThread contract with GetThreadAllocContext returning a new ThreadAllocData record, and wired it into SOSDacImpl.GetThreadAllocData.
  • Added unit + dump tests and updated mock descriptors and design docs to cover/describe the new fields.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/native/managed/cdac/tests/ThreadTests.cs Adds unit tests for GetThreadAllocContext.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Thread.cs Extends mock type layouts and thread creation to include alloc-context hierarchy and alloc byte values.
src/native/managed/cdac/tests/DumpTests/ThreadDumpTests.cs Adds dump test to validate alloc context can be read across all threads.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs Implements GetThreadAllocData using the IThread contract and follows existing try/catch + DEBUG-compare patterns.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ISOSDacInterface.cs Introduces DacpAllocData and updates the interface signature to use it.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/GCAllocContext.cs Reads new alloc-byte fields from the target in managed data representation.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Thread_1.cs Implements IThread.GetThreadAllocContext.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs Adds ThreadAllocData record and the new contract method.
src/coreclr/vm/datadescriptor/datadescriptor.inc Adds GCAllocContext field descriptors for alloc byte counts.
docs/design/datacontracts/Thread.md Documents new GCAllocContext field dependencies for the Thread contract.
docs/design/datacontracts/GC.md Documents new GCAllocContext field descriptors used by GC-related contracts.

@max-charlamb max-charlamb requested a review from rcj1 February 24, 2026 22:36
@max-charlamb
Copy link
Member

@copilot, please fix build break

…dAllocContext test and fix trailing whitespace

Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 24, 2026

@copilot, please fix build break

Fixed in 0e5922e — the GetThreadAllocContext test was missing TargetTestHelpers/MockMemorySpace.Builder/MockDescriptors.Thread setup. Also cleaned up remaining trailing whitespace in Thread_1.cs. All 24 thread tests pass.

…ontext

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Copy link
Member

@max-charlamb max-charlamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , address feedback

Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 25, 2026

@copilot , address feedback

Merge conflict artifacts in GC.md fixed in 70d85a9. All 24 thread tests pass.

@copilot, please fix build break

Build is clean — all 876 cDAC tests pass. The merge conflict artifacts in GC.md have been fixed in 70d85a9.

Copy link
Member

@max-charlamb max-charlamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes lgtm

@max-charlamb max-charlamb merged commit c746487 into main Feb 26, 2026
109 of 114 checks passed
@max-charlamb max-charlamb deleted the copilot/implement-get-thread-alloc-data branch February 26, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants