Skip to content

Adding IsTrackedType and GetTaggedMemory cDAC APIs#118250

Closed
rcj1 wants to merge 5 commits intodotnet:mainfrom
rcj1:IsTrackedType_GetTaggedMemory
Closed

Adding IsTrackedType and GetTaggedMemory cDAC APIs#118250
rcj1 wants to merge 5 commits intodotnet:mainfrom
rcj1:IsTrackedType_GetTaggedMemory

Conversation

@rcj1
Copy link
Copy Markdown
Contributor

@rcj1 rcj1 commented Jul 31, 2025

  • Grouping these two together because they both rely on TaggedMemory
  • Putting this up as a draft until I can fully test on a Mac 😅

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

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

@rcj1 rcj1 mentioned this pull request Jul 31, 2025
32 tasks
@max-charlamb
Copy link
Copy Markdown
Member

@jkoritzinsky is this one of the syncblock APIs which may be changing?

@jkoritzinsky
Copy link
Copy Markdown
Member

No, this is not one that I'm looking at changing. Im only looking at ones related to the monitor in the syncblock.

TargetPointer objPtr = objAddr.ToTargetPointer(_target);
TargetPointer mt = objectContract.GetMethodTableAddress(objPtr);
if (mt == TargetPointer.Null)
hr = HResults.E_INVALIDARG;
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.

If we end up in this condition, both *isTrackedType and *hasTaggedMemory should be false.

Comment thread docs/design/datacontracts/Object.md Outdated
if (taggedMemoryPtr != null)
{
*taggedMemory = taggedMemoryPtr.Value.ToClrDataAddress(_target);
*taggedMemorySizeInBytes = 2 * (nuint)_target.PointerSize;
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.

Can we make this part of the contract? It would be nice for this to be driven by the runtime, either through a constant in the contract spec or a data descriptor.

Copy link
Copy Markdown
Contributor Author

@rcj1 rcj1 Aug 1, 2025

Choose a reason for hiding this comment

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

Yes I think we can break this up into two contract methods, HasTaggedMemory and TaggedMemorySize

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.

You could use an out variable to give the size.

For example:

TargetPointer TaggedMemory(TargetPointer address, out uint size);

Comment thread docs/design/datacontracts/Object.md
Comment thread docs/design/datacontracts/Object.md
@rcj1
Copy link
Copy Markdown
Contributor Author

rcj1 commented Aug 4, 2025

GetTaggedMemory takes a nuint parameter; should this be replaced with a fixed-size?

@max-charlamb
Copy link
Copy Markdown
Member

GetTaggedMemory takes a nuint parameter; should this be replaced with a fixed-size?

Yes. We should avoid nuint and nint in the cDAC managed code.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@jkoritzinsky
Copy link
Copy Markdown
Member

Coming back to this, these API should be added to a new contract named ObjectiveC (like the BuiltInCOM contract proposed in #119320)

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 6, 2025
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