Skip to content

Conversation

@alexey-zakharov
Copy link

@alexey-zakharov alexey-zakharov commented Mar 15, 2024

Exposed coreclr_unity_profiler_get_managed_assembly_load_context API to get owning ALC for the AssemblyID

Motivation

It is not possible to obtain information about owning AssemblyLoadContext of native Assembly's object.

Managed Assembly object does not have information about parent AssemblyLoadContext in managed data, as well as managed AssemblyLoadContext does not have data about own modules/assemblies in managed data. This information is stored only in native land as a part of AssemblyBinder (m_ptrManagedAssemblyLoadContext member variable) and is stored when the managed AssemblyLoadContext instance is initialized in managed code.
At the same time ICorProfilerInfo set of APIs do not expose managed object handle for the AssemblyID object which we can get hold of when inspecting object (ObjectID->ClassID->ModuleID->AssemblyID).

In order to be able to attribute particular type to a particular managed AssemblyLoadContext we need to be able to retrieve ObjectHandleID of it from a native AssemblyID value.

Changes

Exposed coreclr_unity_profiler_get_managed_assembly_load_context which simply returns m_ptrManagedAssemblyLoadContext for a given Assembly* instance.

@alexey-zakharov alexey-zakharov requested a review from joncham March 15, 2024 16:45
@alexey-zakharov alexey-zakharov self-assigned this Mar 18, 2024
@alexey-zakharov alexey-zakharov merged commit 0facac1 into unity-main Mar 18, 2024
@alexey-zakharov alexey-zakharov deleted the add-alchandle-api branch March 18, 2024 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants