Skip to content

[cDAC] Add single-file application dump tests#128781

Draft
max-charlamb wants to merge 3 commits into
mainfrom
cdac-singlefile-dump-tests
Draft

[cDAC] Add single-file application dump tests#128781
max-charlamb wants to merge 3 commits into
mainfrom
cdac-singlefile-dump-tests

Conversation

@max-charlamb
Copy link
Copy Markdown
Member

@max-charlamb max-charlamb commented May 29, 2026

Note

This PR was created with assistance from GitHub Copilot.

Summary

Adds single-file application dump tests to the cDAC dump test framework. Single-file apps bundle the runtime into one executable, which changes how modules appear in crash dumps -- this was previously untested.

Changes

New PublishModes dimension

PublishModes is a new per-debuggee property (default: Normal), orthogonal to the existing R2RModes (R2R/Jit). Debuggees opt in with:

<PublishModes>Normal;SingleFile</PublishModes>

This produces compound dump directory names: singlefile-r2r, singlefile-jit.

Module discovery fix

ClrMdDumpHost.FindContractDescriptorAddress() now has a two-pass scan: first checks known runtime module names (fast path), then falls back to scanning all modules for the DotNetRuntimeContractDescriptor export. This handles single-file bundles where coreclr is embedded in the apphost.

Initial debuggees

Three debuggees opt in as initial coverage:

  • BasicThreads (Thread contract)
  • StackWalk (StackWalk contract)
  • TypeHierarchy (RuntimeTypeSystem contract)

CI integration

No pipeline YAML changes needed -- the existing BuildDebuggeesOnly and PrepareHelixPayload MSBuild targets automatically pick up single-file variants for opted-in debuggees. The build stage already includes host+packs which builds singlefilehost.

Validation

  • Locally validated: single-file dump generated and ThreadCounts_AreNonNegative(config: local/singlefile-r2r) passed
  • Uses locally-built singlefilehost via targetingpacks.targets (same mechanism as R2R tests)

Add a new PublishModes dimension (Normal/SingleFile) to the cDAC dump
test framework, orthogonal to the existing R2RModes (R2R/Jit).

Key changes:
- ClrMdDumpHost: Add fallback scan of all modules for the contract
  descriptor export, handling single-file bundles where coreclr is
  embedded in the apphost.
- DumpTests.targets: Add PublishModes cross-product with R2RModes,
  compound directory names (singlefile-r2r, singlefile-jit), and a
  new _GenerateSingleFileDump target for self-contained single-file
  publish.
- TestConfiguration: Add PublishMode property and CompoundDirName for
  dump path construction.
- DumpTestBase: Cross-product RuntimeVersion x R2RMode x PublishMode
  in TestConfigurations.
- Helix: Update metadata generation, command routing (run exe directly
  for single-file), and payload copying for single-file variants.
- Opt in BasicThreads, StackWalk, TypeHierarchy as initial debuggees.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

This PR extends the cDAC dump test framework to cover single-file published debuggees by introducing a new publish-mode dimension (normal vs single-file), updating dump layout handling, and making contract-descriptor discovery resilient to single-file bundling module names.

Changes:

  • Added PublishMode/compound directory naming to TestConfiguration + updated dump-path resolution in DumpTestBase.
  • Updated MSBuild/Helix plumbing to build/copy/run single-file debuggees and to generate metadata/dumps in singlefile-{r2r|jit} directories.
  • Made ClrMdDumpHost.FindContractDescriptorAddress() fall back to scanning all modules for DotNetRuntimeContractDescriptor.

Reviewed changes

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

Show a summary per file
File Description
src/native/managed/cdac/tests/DumpTests/TestConfiguration.cs Adds PublishMode and CompoundDirName for dump directory naming.
src/native/managed/cdac/tests/DumpTests/DumpTestBase.cs Enumerates publish modes and uses compound dir names when locating dumps.
src/native/managed/cdac/tests/DumpTests/Microsoft.Diagnostics.DataContractReader.DumpTests.csproj Extends debuggee metadata generation and Helix payload copying for single-file variants.
src/native/managed/cdac/tests/DumpTests/DumpTests.targets Adds publish-mode cross-product and single-file publish/dump generation targets.
src/native/managed/cdac/tests/DumpTests/ClrMdDumpHost.cs Adds a second-pass module scan for the contract descriptor export.
src/native/managed/cdac/tests/DumpTests/cdac-dump-helix.proj Runs single-file debuggees directly when IsSingleFile=true.
src/native/managed/cdac/tests/DumpTests/Debuggees/Directory.Build.props Introduces default PublishModes property for debuggees.
src/native/managed/cdac/tests/DumpTests/Debuggees/Directory.Build.targets Plumbs PublishModes through GetDumpTypes metadata.
src/native/managed/cdac/tests/DumpTests/Debuggees/BasicThreads/BasicThreads.csproj Opts debuggee into Normal;SingleFile.
src/native/managed/cdac/tests/DumpTests/Debuggees/StackWalk/StackWalk.csproj Opts debuggee into Normal;SingleFile.
src/native/managed/cdac/tests/DumpTests/Debuggees/TypeHierarchy/TypeHierarchy.csproj Opts debuggee into Normal;SingleFile.

Comment thread src/native/managed/cdac/tests/DumpTests/DumpTestBase.cs
Comment thread src/native/managed/cdac/tests/DumpTests/DumpTests.targets Outdated
Comment thread src/native/managed/cdac/tests/DumpTests/cdac-dump-helix.proj
@github-actions

This comment has been minimized.

Max Charlamb and others added 2 commits May 29, 2026 15:22
Align _GenerateSingleFileDump with the existing pattern: always publish
with PublishReadyToRun=true and control jit behavior at runtime via
DOTNET_ReadyToRun=0. This matches _GenerateLocalDump, _PublishSingle-
FileDebuggee, and the Helix command generation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use CompoundDirName in skip message so singlefile-r2r shows correctly
  instead of just r2r.
- Add chmod +x before running single-file exe on Unix Helix, since
  archive extraction may not preserve executable bits.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 29, 2026 19:25
@github-actions
Copy link
Copy Markdown
Contributor

Code Review: [cDAC] Add single-file application dump tests

Verdict: ✅ Approve

Summary

This PR adds single-file application dump test support to the cDAC dump test framework. It introduces a PublishModes dimension (orthogonal to R2RModes), fixes module discovery for single-file bundles via a two-pass scan, and wires up the full build/Helix pipeline for opted-in debuggees.

Assessment

The change is well-structured, follows existing patterns in the test infrastructure, and all previous review comments have been addressed (resolved). No new public API surface is introduced.

Findings

💡 suggestion — Minor inefficiency in two-pass module scan

File: ClrMdDumpHost.csFindContractDescriptorAddress()

The second pass scans all modules, including those already checked in the first pass (known runtime modules). You could skip modules that passed IsRuntimeModule in the second pass to avoid redundant GetExportSymbolAddress calls. However, since this is test infrastructure (not production hot path) and the module list is typically small, this is purely cosmetic.

💡 suggestion — GetPublishModes() always yields both modes

File: DumpTestBase.cs

GetPublishModes() unconditionally yields "singlefile" for all debuggees, even those without single-file dumps. These are gracefully skipped via SkipTestException, which is consistent with how GetR2RModes() works — but it does mean xUnit output will show many skipped tests. This is acceptable but worth noting for future test output clarity.

Positive observations

  • Clean separation: PublishModes is orthogonal to R2RModes and DumpTypes
  • Proper validation: <Error> elements for invalid publish mode values
  • Correct Helix integration: chmod +x for Unix single-file executables, DOTNET_DbgEnableMiniDump properly inherited from pre-commands
  • _GenerateSingleFileDump always publishes with R2R (matching the existing pattern where runtime behavior is toggled via DOTNET_ReadyToRun env var)
  • Good documentation in comments and XML docs

Models contributing: claude-opus-4.6 (primary)

Generated by Code Review for issue #128781 · ● 5.3M ·

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 11 out of 11 changed files in this pull request and generated no new comments.

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