Skip to content

cDAC test cleanup - Allocator adds HeapFragments by default#126780

Open
noahfalk wants to merge 1 commit intodotnet:mainfrom
noahfalk:cDac_auto_add_heap_fragments
Open

cDAC test cleanup - Allocator adds HeapFragments by default#126780
noahfalk wants to merge 1 commit intodotnet:mainfrom
noahfalk:cDac_auto_add_heap_fragments

Conversation

@noahfalk
Copy link
Copy Markdown
Member

Previously the tests used a two step process of first using BumpAllocator to calculate a simulated address for a new HeapFragment, then separately calling Builder.AddHeapFragment() to store it. Now the allocator automatically stores all allocations eliminating the need for a 2nd call.

This is follow up from the recent PR feedback asking to consolidate the AllocateAndAdd() helper. Removing the need for it entirely seemed cleaner. #126466 (comment)

Previously the tests used a two step process of first using BumpAllocator to calculate
a simulated address for a new HeapFragment, then separately calling
Builder.AddHeapFragment() to store it. Now the allocator automatically stores
all allocations eliminating the need for a 2nd call.

This is follow up from the recent PR feedback asking to consolidate the
AllocateAndAdd() helper. Removing the need for it entirely seemed cleaner.
dotnet#126466 (comment)
Copilot AI review requested due to automatic review settings April 11, 2026 00:17
@noahfalk
Copy link
Copy Markdown
Member Author

@rcj1 @max-charlamb @barosiak

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
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

This PR simplifies cDAC test setup by making MockMemorySpace.BumpAllocator automatically register each allocated HeapFragment with the owning MockMemorySpace.Builder, removing the need for many manual AddHeapFragment(s) calls across tests and mock descriptor builders.

Changes:

  • Updated MockMemorySpace.Builder.CreateAllocator / BumpAllocator so Allocate auto-registers fragments with the builder.
  • Removed redundant AddHeapFragment / AddHeapFragments calls in tests and mock descriptor helpers that use BumpAllocator.
  • Deleted now-unnecessary AllocateAndAdd helper methods in multiple mock builders.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/native/managed/cdac/tests/ThreadTests.cs Removes manual fragment registration for exception handle allocations now covered by allocator auto-registration.
src/native/managed/cdac/tests/PrecodeStubsTests.cs Removes redundant AddHeapFragment calls for allocator-backed precode/stub data allocations.
src/native/managed/cdac/tests/MockMemorySpace.cs Updates CreateAllocator to construct a builder-bound allocator and documents auto-registration behavior.
src/native/managed/cdac/tests/MockMemorySpace.BumpAllocator.cs Adds builder reference and registers each successful allocation via AddHeapFragment.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Thread.cs Removes AllocateAndAdd and redundant AddHeapFragments calls; relies on allocator registration.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.SyncBlock.cs Removes AllocateAndAdd helper and redundant fragment registrations.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.RuntimeTypeSystem.cs Removes manual AddHeapFragment after allocator allocations.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.RuntimeFunctions.cs Removes AllocateAndAdd helper and uses allocator registration for runtime function/unwind allocations.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.ReJIT.cs Removes redundant manual registration of allocator-produced fragments.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Object.cs Removes manual fragment registration for allocator-backed managed object allocations.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.MethodDescriptors.cs Removes redundant AddHeapFragment calls after allocations.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Loader.cs Removes AllocateAndAdd helper and redundant fragment registrations for module/assembly/string allocations.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.HashMap.cs Removes AllocateAndAdd helper and redundant fragment registration for hash map structures.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.GC.cs Removes redundant manual registrations for GC allocator-backed globals/regions/tables.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.ExecutionManager.cs Removes redundant fragment registrations for allocator-backed execution manager structures.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.CodeVersions.cs Removes AllocateAndAdd helper and redundant registrations for code versioning nodes/states.
src/native/managed/cdac/tests/MockDescriptors/MockBuiltInComBuilder.cs Removes AllocateAndAdd helper and redundant fragment registration for COM mock allocations.
src/native/managed/cdac/tests/MethodTableTests.cs Removes manual registration of allocator-produced partial fragments used for E_INVALIDARG scenarios.
src/native/managed/cdac/tests/LoaderTests.cs Removes redundant manual fragment registration in PE/Webcil image mock setup.
src/native/managed/cdac/tests/GCMemoryRegionTests.cs Removes manual fragment registrations for allocator-based memory region graph construction.
src/native/managed/cdac/tests/DebuggerTests.cs Removes redundant fragment registration for allocator-backed debugger globals/structures.
src/native/managed/cdac/tests/ClrDataExceptionStateTests.cs Removes manual registration for allocator-backed exception handle fragments.
src/native/managed/cdac/tests/AuxiliarySymbolsTests.cs Removes redundant fragment registrations for allocator-based helper/name data.

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.

2 participants