Skip to content

[cDAC] Add GetTargetInfo DacDbi API#130388

Draft
rcj1 wants to merge 1 commit into
dotnet:mainfrom
rcj1:target-info-dbi-api
Draft

[cDAC] Add GetTargetInfo DacDbi API#130388
rcj1 wants to merge 1 commit into
dotnet:mainfrom
rcj1:target-info-dbi-api

Conversation

@rcj1

@rcj1 rcj1 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Introduces IDacDbiInterface::GetTargetInfo, which reports the target's processor architecture and OS family, along with the TargetInfo/TargetArchitecture/TargetOperatingSystem types. Includes the native DAC implementation and the managed cDAC implementation.

Needed so that DBI can use this instead of #ifdef TARGET_XXX.

Introduces IDacDbiInterface::GetTargetInfo, which reports the target's processor architecture and OS family, along with the TargetInfo/TargetArchitecture/TargetOperatingSystem types. Includes the native DAC implementation and the managed cDAC implementation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 9, 2026 00:04
@rcj1 rcj1 changed the title Add GetTargetInfo DacDbi API [cDAC] Add GetTargetInfo DacDbi API Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 extends the internal DacDbi surface area with a new IDacDbiInterface::GetTargetInfo API that returns a small TargetInfo struct describing the target’s processor architecture and OS “family”, with corresponding managed (cDAC) and native (DAC) implementations.

Changes:

  • Adds GetTargetInfo to the DacDbi COM interface (IDL + C++ interface header) and wires it into the native DAC implementation.
  • Adds managed definitions (TargetInfo / TargetArchitecture / TargetOperatingSystem) and a managed DacDbiImpl.GetTargetInfo implementation backed by the IRuntimeInfo contract.
  • Introduces DEBUG-only validation to compare cDAC vs legacy DAC results.
Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Adds managed GetTargetInfo signature plus managed Target* types.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements the managed GetTargetInfo method using IRuntimeInfo and DEBUG compares with legacy.
src/coreclr/inc/dacdbi.idl Adds the TargetInfo struct and the new COM method to the IDL.
src/coreclr/debug/inc/dacdbiinterface.h Adds native Target* enums/struct and the new vtable method.
src/coreclr/debug/daccess/dacdbiimpl.h Declares DacDbiInterfaceImpl::GetTargetInfo.
src/coreclr/debug/daccess/dacdbiimpl.cpp Implements the native GetTargetInfo method using TARGET_* defines.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 9

Comment on lines +816 to +817
Wasm,
}
Unix,
}

public struct TargetInfo
Comment on lines +5621 to +5623

Contracts.IRuntimeInfo runtimeInfo = _target.Contracts.RuntimeInfo;

{
Contracts.RuntimeInfoArchitecture.X86 => TargetArchitecture.X86,
Contracts.RuntimeInfoArchitecture.X64 => TargetArchitecture.AMD64,
Contracts.RuntimeInfoArchitecture.Arm => TargetArchitecture.Arm,
Contracts.RuntimeInfoArchitecture.LoongArch64 => TargetArchitecture.LoongArch64,
Contracts.RuntimeInfoArchitecture.RiscV64 => TargetArchitecture.RiscV64,
Contracts.RuntimeInfoArchitecture.Wasm => TargetArchitecture.Wasm,
_ => TargetArchitecture.Unknown,
Contracts.RuntimeInfoOperatingSystem.Windows => TargetOperatingSystem.Windows,
Contracts.RuntimeInfoOperatingSystem.Unix => TargetOperatingSystem.Unix,
Contracts.RuntimeInfoOperatingSystem.Apple => TargetOperatingSystem.Unix,
_ => TargetOperatingSystem.Unknown,
Comment on lines +5614 to +5616
public int GetTargetInfo(TargetInfo* pTargetInfo)
{
int hr = HResults.S_OK;
Comment on lines +2215 to +2216
kArchWasm,
} TargetArchitecture;
Comment on lines +7414 to +7416
#elif defined(TARGET_WASM)
pTargetInfo->arch = kArchWasm;
#else
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@rcj1 rcj1 marked this pull request as draft July 9, 2026 01:10
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.

2 participants