Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[cDAC] Implement ISOSDacImpl.GetAssemblyList #114800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 6, 2025

Conversation

max-charlamb
Copy link
Contributor

@max-charlamb max-charlamb commented Apr 17, 2025

As part of work for #114336, the cDAC now supports iterating Assemblies in an AppDomain so this API falls out nicely.

It is also used as part of !dumpdomain and is relatively easy to test.

Given we already have a ModuleHandle in ILoader, I wanted to keep using that even if we have to iterate assemblies. On further thought, it appears an assembly can exist without a module. Therefore, I'm wondering if it would be reasonable to convert to using an AssemblyHandle. Can a module exist without an assembly?

Edit: Discussed with @davidwrighton and decided that a Module should always exist for all relevant Assembly instances. Therefore, we can use the ModuleHandle to represent an Assembly.

@Copilot Copilot AI review requested due to automatic review settings April 17, 2025 19:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the ISOSDacImpl.GetAssemblyList API to support iterating assemblies within an AppDomain. Key changes include:

  • Implementation of the GetAssemblyList method in SOSDacImpl.cs with appropriate argument checks, exception handling, and debug validation.
  • Addition of new data types (e.g. LoaderAllocator, ArrayListBase, and related cdac_data specializations) and updates to the assembly and appdomain data models to support the new functionality.
  • Updates to the ILoader interface and associated loaders in the DataContractReader.Contracts to enumerate assemblies based on various iteration flags.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs Implements the GetAssemblyList API with error checks and debug validation against legacy implementations.
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Contracts/Data/LoaderAllocator.cs Introduces LoaderAllocator data type for tracking loader allocations.
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Contracts/Data/Assembly.cs Extends the Assembly data type with new fields (Module, Error, NotifyFlags, Level) to support assembly status.
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Contracts/Data/ArrayListBase.cs Provides implementation for ArrayListBase and its block elements using modern collection initialization.
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Contracts/Data/AppDomain.cs Adds DomainAssemblyList field for improved assembly enumeration in AppDomains.
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs Updates ILoader contract with GetAssemblies and IsAssemblyLoaded methods.
Other coreclr and datadescriptor files Updates to cdac_data and constant definitions to support the new APIs.

Copy link
Contributor

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

@max-charlamb
Copy link
Contributor Author

/azp run runtime-diagnostics

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -15,10 +15,32 @@ readonly struct ModuleHandle
[Flags]
enum ModuleFlags
{
Tenured = 0x00000001, // Set once we know for sure the Module will not be freed until the appdomain itself exits
Copy link
Member

Choose a reason for hiding this comment

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

There needs to be a detail in the versioned portion of the contract indicating which module flags are actually handled by that specific version of the contract. I want to be able to know which magic constants are meaningful, and the current document does not explain. (This becomes relevant since we may renumber the enum in the runtime, but we won't be able to renumber the enum in the contract interface.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created ModuleFlags_1 which represent the runtime implementation of Module::Flags and a function to map ModuleFlags_1 to ModuleFlags.

@max-charlamb max-charlamb force-pushed the cdac-symbol-reading-2 branch from 688baab to 173d72c Compare May 5, 2025 13:45
@max-charlamb
Copy link
Contributor Author

/azp run runtime-diagnostics

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@max-charlamb
Copy link
Contributor Author

/azp run runtime-diagnostics

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@max-charlamb
Copy link
Contributor Author

/ba-g Known issue #115070 and unrelated failures

@max-charlamb max-charlamb merged commit 81899bb into dotnet:main May 6, 2025
148 of 155 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants