[cDAC] Implement EnumerateMonitorEventWaitList for cDAC#129054
Open
barosiak wants to merge 2 commits into
Open
[cDAC] Implement EnumerateMonitorEventWaitList for cDAC#129054barosiak wants to merge 2 commits into
barosiak wants to merge 2 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Contributor
There was a problem hiding this comment.
Pull request overview
Implements DacDbiImpl.EnumerateMonitorEventWaitList in the cDAC managed DacDbiImpl to enumerate threads waiting on a monitor’s condition wait list for a given object, and adds unit tests exercising key scenarios across architectures.
Changes:
- Added a cDAC implementation of
EnumerateMonitorEventWaitListthat reads theMonitor.s_conditionTable, resolves the object’sConditionviaConditionalWeakTable, maps per-thread waiter objects to threads, then walks the waiters linked list to invoke the callback. - Added
#if DEBUGvalidation comparing cDAC results against legacy DAC results. - Added unit tests covering: no sync block, null callback, missing condition / empty waiters list, and single/multiple/non-waiting thread cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs |
Adds the cDAC implementation of EnumerateMonitorEventWaitList plus DEBUG-only legacy cross-validation. |
src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs |
Adds helper infrastructure and new tests for EnumerateMonitorEventWaitList behavior across architectures. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+3206
to
+3219
| // Build a map of Waiter objects to their owning Threads. | ||
| var waiterToThreadMap = new Dictionary<ulong, TargetPointer>(); | ||
| Contracts.IThread threadContract = _target.Contracts.Thread; | ||
| Contracts.ThreadStoreData threadStore = threadContract.GetThreadStoreData(); | ||
| TargetPointer currentThread = threadStore.FirstThread; | ||
| while (currentThread != TargetPointer.Null) | ||
| { | ||
| Contracts.ThreadData threadData = threadContract.GetThreadData(currentThread); | ||
|
|
||
| if (_target.Contracts.ManagedTypeSource.TryGetThreadStaticFieldAddress( | ||
| "System.Threading.Condition", "t_waiterForCurrentThread", currentThread, out TargetPointer waiterSlot)) | ||
| { | ||
| TargetPointer waiterObj = _target.ReadPointer(waiterSlot); | ||
| if (waiterObj != TargetPointer.Null) |
Comment on lines
+1002
to
+1009
| var slotFragment = allocator.Allocate((ulong)ptrSize, $"WaiterSlot_{thread.Value:x}"); | ||
| helpers.WritePointer(slotFragment.Data, waiterFragments[waiterIdx].Address); | ||
|
|
||
| TargetPointer outAddr = new(slotFragment.Address); | ||
| mockMts.Setup(m => m.TryGetThreadStaticFieldAddress( | ||
| "System.Threading.Condition", "t_waiterForCurrentThread", thread, out outAddr)) | ||
| .Returns(true); | ||
| waiterIdx++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement
DacDbiImpl.EnumerateMonitorEventWaitListin the cDAC to enumerate threads waiting on a monitor lock for a given object.Changes
DacDbiImpl.cs- ImplementEnumerateMonitorEventWaitListwith#if DEBUGlegacy validationDacDbiImplTests.cs- Add 4 test methods (16 cases across architectures) covering no sync block, null callback, ConditionalWeakTable miss/empty list, and single/multiple/non-waiting thread scenarios