Implement cDAC TraverseVirtCallStubHeap and address review polish#127296
Implement cDAC TraverseVirtCallStubHeap and address review polish#127296
TraverseVirtCallStubHeap and address review polish#127296Conversation
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/9bc90482-f937-46eb-9d1d-3082f206b2e4 Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
TraverseVirtCallStubHeap in SOSDacImpl with Loader_1 parityTraverseVirtCallStubHeap in SOSDacImpl
There was a problem hiding this comment.
Pull request overview
Implements cDAC support for ISOSDacInterface.TraverseVirtCallStubHeap in SOSDacImpl, aligning behavior with the native DAC by traversing VirtualCallStubManager loader heaps (Indcell / CacheEntry) via the loader contract, and adds unit tests for the new behavior.
Changes:
- Added
VCSHeapTypeenum and updatedISOSDacInterface.TraverseVirtCallStubHeapsignature to use the enum and a typed unmanaged callback. - Implemented
TraverseVirtCallStubHeapinSOSDacImplusingILoader.GetGlobalLoaderAllocator()+GetLoaderAllocatorHeaps(...)and reusingTraverseLoaderHeapCore(...). - Added Loader contract-based unit tests covering traversal, missing manager, invalid heap type, and invalid argument scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/native/managed/cdac/tests/LoaderTests.cs |
Adds unit tests for TraverseVirtCallStubHeap behavior using a mocked ILoader contract. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs |
Implements TraverseVirtCallStubHeap and refactors TraverseLoaderHeapCore to take a TargetPointer. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ISOSDacInterface.cs |
Introduces VCSHeapType and updates the COM interface method signature accordingly. |
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
TraverseVirtCallStubHeap in SOSDacImplTraverseVirtCallStubHeap
max-charlamb
left a comment
There was a problem hiding this comment.
A few nit-level suggestions — logic is correct, these are polish items. LGTM once addressed or deferred.
| if (!heaps.ContainsKey("IndcellHeap")) | ||
| throw new NullReferenceException(); | ||
|
|
||
| string? heapName = heaptype switch | ||
| { | ||
| VCSHeapType.IndcellHeap => "IndcellHeap", | ||
| VCSHeapType.CacheEntryHeap => "CacheEntryHeap", |
There was a problem hiding this comment.
Nit: the producer (Loader_1.GetLoaderAllocatorHeaps) uses nameof(Data.VirtualCallStubManager.IndcellHeap) / nameof(Data.VirtualCallStubManager.CacheEntryHeap) as the dictionary keys. Consider using nameof here too (on the ContainsKey check and in the switch arms) so the two sides stay in sync under rename-refactorings and the contract coupling is self-documenting.
There was a problem hiding this comment.
nameof what? We would have to then define these strings at the abstraction level. Should we maybe define these enum instead at the abstraction level?
There was a problem hiding this comment.
Updated heap-key coupling to use nameof(VCSHeapType.IndcellHeap/CacheEntryHeap) in TraverseVirtCallStubHeap so key names stay refactor-safe and self-documenting. Addressed in 0593031.
There was a problem hiding this comment.
Yeah I don’t think this is what we want.
There was a problem hiding this comment.
Why can't we use the name of the enum type? We could even simplify the switch to use enum ToString
There was a problem hiding this comment.
the producer (Loader_1.GetLoaderAllocatorHeaps) uses nameof(Data.VirtualCallStubManager.IndcellHeap)
If we are expecting contract consumers (like this code) to be able to lookup specific heaps by a well-known name then that sounds like those heap names are part of the public contract API and should not change when refactoring the implementation of the loader contract. We might want to use fixed constant strings or switch to an enum rather than deriving the names using nameof() on private implementation fields.
There was a problem hiding this comment.
Yes we discussed this offline and decided on the enum. I’m working on a separate pr for that.
There was a problem hiding this comment.
Isn't the problem here that adding/removing heaps on the runtime is something that can happen? I'd prefer the contract surface be "here are the named runtime heaps", and the debugger can present that data how it wishes.
(and not every heap type is in every build)
The current contract is that the loader reports exactly what the runtime calls the heaps. If we want to change it so the cDAC drives the names, that would be reasonable.
I take it back, after looking at the code, I think it is totally reasonable to change this so that we have an enum of heaps we can request. The cDAC does drive the naming currently.
|
@copilot please address the feedback |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/49e920ec-25ea-495b-96cb-9c5be87c4cad Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/49e920ec-25ea-495b-96cb-9c5be87c4cad Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Addressed the requested feedback in follow-up commits |
TraverseVirtCallStubHeapTraverseVirtCallStubHeap and address review polish
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/214fed2a-4388-4cb3-a777-ec0d3ae1b379 Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Adding
TraverseVirtCallStubHeapSOS API, using the sameTraverseLoaderHeapCoreloader heap traversal structure added for theTraverseLoaderHeapAPIs.Follow-up review feedback addressed in this PR:
E_INVALIDARG.TraverseVirtCallStubHeap(core traversal remains the reset point).pAppDomainhandling (validated, then global loader allocator is used)."IndcellHeap"/"CacheEntryHeap") in implementation and tests, per maintainer feedback.VCSHeapTypebacking type tointto match native.CacheEntryHeaptraversal path.