Add TestCDACNoFallback flag for cDAC-only testing#5806
Merged
max-charlamb merged 1 commit intomainfrom Apr 17, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new SOS unit test configuration knob (TestCDACNoFallback via SOS_TEST_CDAC_NO_FALLBACK) to run tests with cDAC enabled without falling back to the legacy DAC, and conditionally skips ICorDebug-dependent ClrStack -i validations in script-based tests.
Changes:
- Introduces
TestCDACNoFallbackinTestConfiguration(env var parsing + log suffix tagging). - When enabled, sets
DOTNET_ENABLE_CDAC=1andCDAC_NO_FALLBACK=1for the debugger process and adds a script define (CDAC_TESTING) to gate unsupported test sections. - Wraps
ClrStack -i(ICorDebug) sections in 7 SOS.scriptfiles with!IFDEF:CDAC_TESTING/ENDIF:CDAC_TESTING.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/SOS.UnitTests/Scripts/WebApp.script | Skips ClrStack -i verification when CDAC_TESTING is enabled. |
| src/tests/SOS.UnitTests/Scripts/StackTests.script | Gates ICorDebug-based ClrStack -i / -i -a region under !IFDEF:CDAC_TESTING. |
| src/tests/SOS.UnitTests/Scripts/StackAndOtherTests.script | Gates ICorDebug-based ClrStack -i / -i -a region under !IFDEF:CDAC_TESTING. |
| src/tests/SOS.UnitTests/Scripts/MiniDumpLocalVarLookup.script | Skips clrstack -i -l locals verification under CDAC_TESTING. |
| src/tests/SOS.UnitTests/Scripts/DynamicMethod.script | Gates the ICorDebug-dependent flow (used for <POUT> capture) under !IFDEF:CDAC_TESTING. |
| src/tests/SOS.UnitTests/Scripts/DualRuntimes.script | Skips ClrStack -i verification under CDAC_TESTING. |
| src/tests/SOS.UnitTests/Scripts/ClrStackWithNumberOfFrames.script | Skips ClrStack -i -c ... checks under CDAC_TESTING. |
| src/tests/SOS.UnitTests/SOSRunner.cs | Adds env var setup for no-fallback mode + enables CDAC_TESTING define for scripts. |
| src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs | Adds TestCDACNoFallback config value, suffix tagging, and boolean accessor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5d47d59 to
6e1da4b
Compare
6e1da4b to
326e459
Compare
Add a new TestCDACNoFallback test configuration flag (SOS_TEST_CDAC_NO_FALLBACK env var) that enables cDAC with no fallback to the legacy DAC. When enabled: - Sets DOTNET_ENABLE_CDAC=1 and CDAC_NO_FALLBACK=1 on the debugger process - Adds CDAC_TESTING define to skip ClrStack -i tests (ICorDebug is not implemented in the cDAC) Wraps ClrStack -i commands with !IFDEF:CDAC_TESTING in 7 script files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
326e459 to
60cced0
Compare
noahfalk
approved these changes
Apr 16, 2026
max-charlamb
added a commit
to dotnet/runtime
that referenced
this pull request
Apr 17, 2026
Update runtime-diagnostics pipeline to use the -noFallback build flag from dotnet/diagnostics#5806 instead of setting CDAC_NO_FALLBACK as a pipeline-level environment variable. The -noFallback flag properly sets the env var on the debugger process and enables CDAC_NO_FALLBACK_TESTING defines to skip ClrStack -i tests. Add noFallback parameter to runtime-diag-job.yml template and wire it through to the build script. Remove unnecessary try/catch around Console.Error.WriteLine in LegacyFallbackHelper — stderr writes don't throw when the stream is unavailable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
max-charlamb
added a commit
to dotnet/runtime
that referenced
this pull request
Apr 17, 2026
Update runtime-diagnostics pipeline to use the -noFallback build flag from dotnet/diagnostics#5806 instead of setting CDAC_NO_FALLBACK as a pipeline-level environment variable. The -noFallback flag properly sets the env var on the debugger process and enables CDAC_NO_FALLBACK_TESTING defines to skip ClrStack -i tests. Add noFallback parameter to runtime-diag-job.yml template and wire it through to the build script. Remove unnecessary try/catch around Console.Error.WriteLine in LegacyFallbackHelper — stderr writes don't throw when the stream is unavailable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
max-charlamb
added a commit
to dotnet/runtime
that referenced
this pull request
Apr 17, 2026
> [!NOTE] > This PR description was generated with the assistance of GitHub Copilot. ## Summary Add a granular, per-method allowlist (`LegacyFallbackHelper`) that controls which delegation-only APIs may fall back to the legacy DAC when `CDAC_NO_FALLBACK=1` is set. This enables selective no-fallback testing — blocking fallback for most APIs while allowing specific APIs that are known to not yet be implemented in the cDAC. Wire this into the runtime-diagnostics CI pipeline using the `-noFallback` flag from [dotnet/diagnostics#5806](dotnet/diagnostics#5806). All fallback attempts (both allowed and blocked) are logged to stderr with method name, file, and line number for capture by the diagnostics test infrastructure. ## Changes ### LegacyFallbackHelper.cs — Granular fallback control New static helper that every delegation-only call site invokes via `CanFallback()`. Uses `[CallerMemberName]`, `[CallerFilePath]`, and `[CallerLineNumber]` to identify the call site. - **Normal mode** (`CDAC_NO_FALLBACK` unset): Always returns `true` (single `bool` check, `[AggressiveInlining]`) - **No-fallback mode** (`CDAC_NO_FALLBACK=1`): Checks method name against a `HashSet<string>` allowlist and file name against a file-level allowlist **Per-method allowlist:** | Method | Reason | |--------|--------| | `EnumMemoryRegions` | Dump creation — cDAC has no memory enumeration implementation | | `GetInterface` | IMetaDataImport QI ([PR #127028](#127028)) | | `GetMethodDefinitionByToken` | IXCLRDataModule — not yet implemented in cDAC | | `IsTrackedType` | GC heap analysis ([PR #125895](#125895)) | | `TraverseLoaderHeap` | Loader heap traversal ([PR #125129](#125129)) | **File-level allowlist:** | File | Reason | |------|--------| | `DacDbiImpl.cs` | Entire DBI/ICorDebug interface (122 methods) — deferred | ### Entrypoints.cs — Simplified creation Both `CreateSosInterface` and `CreateDacDbiInterface` now follow the same pattern: the legacy implementation is always passed through, and `LegacyFallbackHelper.CanFallback()` at each call site decides whether to delegate. Removed `prevent_release`, `noFallback` env var check, and null-legacy-ref logic. ### 13 Legacy wrapper files — Instrumented delegation sites All 296 delegation-only methods across all legacy wrapper files now call `LegacyFallbackHelper.CanFallback()`: - `SOSDacImpl.cs` (12 methods) - `SOSDacImpl.IXCLRDataProcess.cs` (38 methods, `Flush()` intentionally excluded — cache management) - `ClrDataModule.cs` (29 methods + IMetaDataImport QI) - `DacDbiImpl.cs` (122 methods) - Other wrappers: `ClrDataTask.cs`, `ClrDataExceptionState.cs`, `ClrDataFrame.cs`, `ClrDataValue.cs`, `ClrDataTypeInstance.cs`, `ClrDataMethodInstance.cs`, `ClrDataStackWalk.cs`, `ClrDataProcess.cs` ### CI Pipeline — `-noFallback` flag Updated `runtime-diag-job.yml` to accept a `noFallback` parameter that passes `-noFallback` to the diagnostics build script. The `cDAC_no_fallback` leg in `runtime-diagnostics.yml` now uses `noFallback: true` instead of setting `CDAC_NO_FALLBACK` as a pipeline-level environment variable. The `-noFallback` flag (from [dotnet/diagnostics#5806](dotnet/diagnostics#5806)) properly: - Sets `DOTNET_ENABLE_CDAC=1` and `CDAC_NO_FALLBACK=1` on the debugger process - Defines `CDAC_NO_FALLBACK_TESTING` to skip `ClrStack -i` tests (ICorDebug not implemented in cDAC) ### Stderr logging Every fallback attempt is logged to stderr in the format: ``` [cDAC] Allowed fallback: CreateStackWalk at DacDbiImpl.cs:590 [cDAC] Blocked fallback: SomeMethod at SOSDacImpl.cs:123 ``` The diagnostics test infrastructure (`ProcessRunner`) captures stderr and routes it to xunit test output with `STDERROR:` prefix, making fallback usage visible in test results. ## Test Results With `CDAC_NO_FALLBACK=1` and the current allowlist, running the full SOS test suite against a private runtime build: - **24 passed**, **2 failed** (flaky/pre-existing), **2 skipped** (Linux-only) - **0 blocked fallbacks** ## Motivation The existing cDAC test leg always has the legacy DAC as a fallback, so unimplemented APIs are silently handled. The granular no-fallback mode makes gaps visible per-method, helping track progress toward full cDAC coverage while keeping tests green for known-deferred APIs. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new
TestCDACNoFallbacktest configuration flag (SOS_TEST_CDAC_NO_FALLBACKenv var) that enables cDAC with no fallback to the legacy DAC.When enabled:
DOTNET_ENABLE_CDAC=1andCDAC_NO_FALLBACK=1on the debugger processCDAC_NO_FALLBACK_TESTINGdefine to skipClrStack -itests (ICorDebug is not implemented in the cDAC)TestCDACNoFallbacktakes precedence overTestCDACwhen both are setWraps
ClrStack -icommands with!IFDEF:CDAC_NO_FALLBACK_TESTING/ENDIF:CDAC_NO_FALLBACK_TESTINGin 7 script files.The
CDAC_NO_FALLBACKenvironment variable is added by dotnet/runtime#126752, which introduces the no-fallback mode to the cDAC runtime and adds a no-fallback test leg to the runtime-diagnostics pipeline.