Skip to content

[cDAC] Implement SetJITCompilerFlags for cDAC#126595

Open
barosiak wants to merge 2 commits intodotnet:mainfrom
barosiak:barosiak/SetJITCompilerFlags
Open

[cDAC] Implement SetJITCompilerFlags for cDAC#126595
barosiak wants to merge 2 commits intodotnet:mainfrom
barosiak:barosiak/SetJITCompilerFlags

Conversation

@barosiak
Copy link
Copy Markdown
Member

@barosiak barosiak commented Apr 7, 2026

 Summary

Implement SetJITCompilerFlags on IXCLRDataModule2 in the cDAC.

 Changes

  • ClrDataModule.cs - SetJITCompilerFlags implementation
  • ILoader.cs / Loader_1.cs - added GetDebuggerInfoBits and SetDebuggerInfoBits contract methods with direct target memory read/write
  • IXCLRData.cs - added DebuggerAssemblyControlFlags enum mirroring cordbpriv.h
  • Tests - new tests covering get/set/flag-preservation

@barosiak barosiak requested review from max-charlamb and rcj1 April 7, 2026 01:20
@barosiak barosiak self-assigned this Apr 7, 2026
Copilot AI review requested due to automatic review settings April 7, 2026 01:20
@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.

Copy link
Copy Markdown
Contributor

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

Implements IXCLRDataModule2.SetJITCompilerFlags for the managed cDAC by wiring it to the Loader contract’s module transient-flag debugger bits, adding the necessary contract surface and tests to validate read/write behavior.

Changes:

  • Implement IXCLRDataModule2.SetJITCompilerFlags in ClrDataModule by updating module debugger control bits via ILoader.
  • Extend ILoader/Loader_1 with GetDebuggerInfoBits and SetDebuggerInfoBits, and document the new contract surface/constants.
  • Update cDAC test infrastructure to support target-memory writes and add Loader tests for debugger-bit get/set and flag preservation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataModule.cs Implements SetJITCompilerFlags using Loader debugger-info bits.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/IXCLRData.cs Adds managed DebuggerAssemblyControlFlags enum mirroring cordbpriv.h.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs Adds GetDebuggerInfoBits / SetDebuggerInfoBits to the Loader contract.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs Implements debugger-info bit get/set by reading/writing Module::Flags.
src/native/managed/cdac/tests/TestPlaceholderTarget.cs Adds write-capable target support for tests.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Loader.cs Allows initializing module transient flags in mocks.
src/native/managed/cdac/tests/LoaderTests.cs Adds new tests for debugger-info bit behavior.
docs/design/datacontracts/Loader.md Documents new Loader contract methods and constants.
src/coreclr/vm/ceeload.h Notes cDAC Loader contract dependency on debugger-info mask/shift constants.
src/coreclr/inc/cordbpriv.h Adds explicit comment that cDAC depends on flag values.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 7, 2026 17:53
Copy link
Copy Markdown
Contributor

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

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

Comment on lines +482 to +487
int hr = HResults.S_OK;
try
{
if ((flags != CORDEBUG_JIT_DEFAULT) && (flags != CORDEBUG_JIT_DISABLE_OPTIMIZATION))
throw new ArgumentException();

Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

IXCLRDataModule2.SetJITCompilerFlags is now implemented, but there doesn’t appear to be any unit/integration test that exercises this COM entrypoint (argument validation and the expected updates to Module::m_dwTransientFlags via Loader.Get/SetDebuggerInfoBits). Adding a focused test that constructs a ClrDataModule over a mock Module, calls SetJITCompilerFlags with both supported values (and an invalid value), and then asserts the shifted debugger bits in target memory would help prevent regressions.

Suggested change
int hr = HResults.S_OK;
try
{
if ((flags != CORDEBUG_JIT_DEFAULT) && (flags != CORDEBUG_JIT_DISABLE_OPTIMIZATION))
throw new ArgumentException();
if ((flags != CORDEBUG_JIT_DEFAULT) && (flags != CORDEBUG_JIT_DISABLE_OPTIMIZATION))
{
return HResults.E_INVALIDARG;
}
int hr = HResults.S_OK;
try
{

Copilot uses AI. Check for mistakes.
void SetDebuggerInfoBits(ModuleHandle handle, uint newBits)
{
uint currentFlags = // read Module::Flags (uint32) at handle.Address + Flags offset
uint updated = (currentFlags & ~DebuggerInfoMask) | (newBits << DebuggerInfoShift);
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The SetDebuggerInfoBits pseudocode writes (newBits << DebuggerInfoShift) without masking to the available bit-range, but the contract implementation masks newBits to (DebuggerInfoMask >> DebuggerInfoShift) before shifting. Please update the documentation snippet to reflect the masking behavior so callers don’t assume higher bits will be preserved/written.

Suggested change
uint updated = (currentFlags & ~DebuggerInfoMask) | (newBits << DebuggerInfoShift);
uint updated = (currentFlags & ~DebuggerInfoMask) | ((newBits & (DebuggerInfoMask >> DebuggerInfoShift)) << DebuggerInfoShift);

Copilot uses AI. Check for mistakes.
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