Skip to content

[cDAC] Add switch to load cDAC directly #5373

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

Closed
wants to merge 5 commits into from

Conversation

max-charlamb
Copy link
Contributor

@max-charlamb max-charlamb commented Mar 25, 2025

Depends on cDAC changes dotnet/runtime#113899

  • Adds ICLRContractLocator COM interface which is passed to DAC/cDAC instantiation. Fetches the contract descriptor location. New cDAC entrypoint depends on this API.
  • Managed path (SOS.Hosting)
    • Loads cDAC if DOTNET_SOS_LOAD_CDAC is set
    • Implements ICLRContractLocator using existing IExportSymbol service
  • Native path
    • Loads cDAC if DOTNET_SOS_LOAD_CDAC is set
    • Lays out interface but does not implement ICLRContractLocator. The existing symbol lookup defers to WinDBG for Windows and uses parsers for MachO/ELF. However, only one of these is built at a time depending on the host platform. Todo: figure out cross-platform native symbol reading.

@max-charlamb max-charlamb requested a review from a team as a code owner March 25, 2025 20:41
@max-charlamb max-charlamb marked this pull request as draft March 25, 2025 20:41
@mikem8361
Copy link

I was planning to do this work myself later this week or next. This PR does have some considerable issues like all the code changes under "Strike\platform" are only used to fallback when there isn't a managed host. We use the CLRMD runtime enumeration to find a "runtime" and to create the IXCLRDataProcess instance for managed code.

And using an env var to control loading the CDAC isn't the direction I want to go in. I haven't completely thought this out but the !runtime command can be used to control this. And we may want to have the CLRMA code use the CDAC and the rest of SOS to still use the regular DAC.

@mikem8361
Copy link

I'm not saying most of this work will be needed like adding ICLRContractLocator and the implementation.

@max-charlamb
Copy link
Contributor Author

max-charlamb commented Mar 25, 2025

I was planning to do this work myself later this week or next. This PR does have some considerable issues like all the code changes under "Strike\platform" are only used to fallback when there isn't a managed host. We use the CLRMD runtime enumeration to find a "runtime" and to create the IXCLRDataProcess instance for managed code.

And using an env var to control loading the CDAC isn't the direction I want to go in. I haven't completely thought this out but the !runtime command can be used to control this. And we may want to have the CLRMA code use the CDAC and the rest of SOS to still use the regular DAC.

Agreed on the env variable. A command would be preferable.

I was looking into the difference between managed/native hosting and have tested this on Windows-x64 for the managed hosting. The native hosting I set up some interfaces but didn't implement ICLRContractLocator because it is unclear to me how to get cross-platform symbol reading.

We can discuss this tomorrow at the cDAC meeting. I'm happy to change this how you prefer or drop part of it.

}
else
{
OSPlatform platform = Target.OperatingSystem;

Choose a reason for hiding this comment

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

FYI, this should use the RuntimeInformation.IsOSPlatform() because we need the OS we are loading the module on not the target OS. We can load Linux dumps on Windows with windbg or dotnet-dump.


if (val == 0)
{
_dacFilePath ??= GetLibraryPath(DebugLibraryKind.Dac);

Choose a reason for hiding this comment

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

Probably will just add another value to DebugLibraryKind for the CDAC in CLRMD. CLRMD needs some of these changes and more to find a CDAC compatible runtime, load it and create the instance.

@mikem8361 mikem8361 closed this Apr 7, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants