Skip to content

Add support to DAC for reading tagged memory on tracked types - #54994

Merged
4 commits merged into
dotnet:mainfrom
AaronRobinsonMSFT:objc_dac_updates
Jul 2, 2021
Merged

4 commits merged into
dotnet:mainfrom
AaronRobinsonMSFT:objc_dac_updates

Conversation

@AaronRobinsonMSFT

@AaronRobinsonMSFT AaronRobinsonMSFT commented Jul 1, 2021 •

Copy link
Copy Markdown
Member

Objective-C interop was added to CoreCLR in dotnet/runtime#52146. The design document for this feature included support for new diagnostic features in the SOS tooling. This document attempts to capture those details.

The following capability should be provided by SOS. All mentioned .NET types are contained within the System.Runtime.InteropServices.ObjectiveC namespace unless stated otherwise.

The ObjectiveCMarshal.CreateReferenceTrackingHandle() API allocates a GCHandle of type HNDTYPE_REFCOUNTED for the passed in object instance. This handle type should already be known to SOS as it is also used for COM interop. What is new to this usage is "tagged memory". The tagged memory is presently 2 pointer sizes worth (that is, sizeof(void*) * 2) but could expand in the future. This memory is stored on the InteropSyncBlockInfo type in the m_taggedMemory field.

SOS: When examining an object (that is, !do) and/or an object's SyncBlock (that is, !SyncBlk) provide the address of the tagged memory and size.

Once this work is completed the design document's Diagnostics section will be updated to reflect the commands.

@ghost

ghost commented Jul 1, 2021

Copy link
Copy Markdown

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

Issue Details

Objective-C interop was added to CoreCLR in dotnet/runtime#52146. The design document for this feature included support for new diagnostic features in the SOS tooling. This document attempts to capture those details.

The following capability should be provided by SOS. All mentioned .NET types are contained within the System.Runtime.InteropServices.ObjectiveC namespace unless stated otherwise.

The ObjectiveCMarshal.CreateReferenceTrackingHandle() API allocates a GCHandle of type HNDTYPE_REFCOUNTED for the passed in object instance. This handle type should already be known to SOS as it is also used for COM interop. What is new to this usage is "tagged memory". The tagged memory is presently 2 pointer sizes worth (that is, sizeof(void*) * 2) but could expand in the future. This memory is stored on the InteropSyncBlockInfo type in the m_taggedMemory field.

SOS: When examining an object (that is, !do) or object's SyncBlock (that is, !SyncBlk) provide the address of the tagged memory and size.

Once this work is completed the design document's Diagnostics section will be updated to reflect the commands.

Author: AaronRobinsonMSFT
Assignees: -
Labels:

area-Diagnostics-coreclr

Milestone: -

@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 6.0.0 milestone Jul 1, 2021
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

/cc @jkoritzinsky @elinor-fung

Comment thread src/coreclr/debug/daccess/request.cpp Resolved
Comment thread src/coreclr/debug/daccess/request.cpp Resolved
Comment thread src/coreclr/vm/syncblk.h Resolved

@noahfalk noahfalk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM aside from the already commented stuff. Thanks @AaronRobinsonMSFT !

Create helper function for tagged memory API querying.
@ghost

ghost commented Jul 2, 2021

Copy link
Copy Markdown

Hello @AaronRobinsonMSFT!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
ghost merged commit b862155 into dotnet:main Jul 2, 2021
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the objc_dac_updates branch July 2, 2021 20:49
@ghost ghost locked as resolved and limited conversation to collaborators Aug 1, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants