Adding GetAssemblyLoadContext cDAC API#117939
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for retrieving Assembly Load Context (ALC) information through the cDAC API by implementing the GetAssemblyLoadContext method. The implementation provides a way to traverse from a method table to its associated Assembly Load Context by following the chain: MethodTable → Module → PEAssembly → HostAssembly/FallbackBinder → AssemblyBinder → ManagedAssemblyLoadContext.
Key changes include:
- Implementation of
GetAssemblyLoadContextmethod inSOSDacImpl.cswith proper error handling and debug validation - Addition of new data structures (
BinderSpaceAssembly,AssemblyBinder) to support ALC traversal - Extension of existing data structures (
PEAssembly) with additional fields for binder information - Addition of
GetBinderAssemblyLoadContextmethod to theILoadercontract
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| SOSDacImpl.cs | Implements GetAssemblyLoadContext method with cDAC contract calls and debug validation |
| PEAssembly.cs | Adds HostAssembly and FallbackBinder fields to support ALC traversal |
| BinderSpaceAssembly.cs | New data structure representing binder space assembly with Binder field |
| AssemblyBinder.cs | New data structure representing assembly binder with ManagedAssemblyLoadContext field |
| Loader_1.cs | Implements GetBinderALC method to traverse ALC hierarchy |
| DataType.cs | Adds enum entries for new data types |
| ILoader.cs | Adds GetBinderAssemblyLoadContext method to interface |
| peassembly.h | Adds cdac_data template specialization with new field offsets |
| assemblybinder.h | Adds cdac_data template specialization and friend declaration |
| datadescriptor.h | Adds CDAC type definitions for new data structures |
| assembly.hpp | Adds cdac_data template specialization for BINDER_SPACE::Assembly |
| Loader.md | Updates documentation with new API and data structure descriptions |
Comments suppressed due to low confidence (2)
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs:298
- The method name 'GetBinderALC' is inconsistent with the interface method name 'GetBinderAssemblyLoadContext'. The implementation should match the interface method name for clarity.
TargetPointer ILoader.GetBinderALC(ModuleHandle handle)
src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs:946
- The code calls 'GetBinderAssemblyLoadContext' but the actual implementation method is named 'GetBinderALC', which will cause a runtime error due to the method name mismatch.
// which is apparently not expected by SOS.
|
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
src/native/managed/cdac/mscordaccore_universal/Legacy/SOSDacImpl.cs
Outdated
Show resolved
Hide resolved
jkotas
left a comment
There was a problem hiding this comment.
LGTM. Thank you!
@max-charlamb Could you please review this as well?
- There is a merge conflict to resolve
- It would be nice to rename ManagedAssemblyLoadContext -> AssemblyLoadContext everywhere as mentioned above (in a separate PR)
max-charlamb
left a comment
There was a problem hiding this comment.
lgtm mod one small nit 👍
|
/ba-g System.Collections.Tests failure is knonw issue #117939 |
No description provided.