Skip to content

dbgshim: route live debugging through cDAC-capable DBI first#5940

Open
hoyosjs wants to merge 4 commits into
dotnet:mainfrom
hoyosjs:hoyosjs/cdac-dbi-live-debugging
Open

dbgshim: route live debugging through cDAC-capable DBI first#5940
hoyosjs wants to merge 4 commits into
dotnet:mainfrom
hoyosjs:hoyosjs/cdac-dbi-live-debugging

Conversation

@hoyosjs

@hoyosjs hoyosjs commented Jul 24, 2026

Copy link
Copy Markdown
Member
  • Add a SetCDacLoadPolicy export and process-wide setting lets the live-debugging connection APIs select the cDAC/legacy DAC policy.
  • Call into the bundled DBI to check whether using cDAC with it suceeded. Each path invokes the DBI with the cDAC first and falls back to the legacy provider/side-by-side
    path.
  • Use simple unified helper to ensure cdac errors prevail over non-cdac ones in fallback scenario.
  • Add SetCDacLoadPolicy test wrapper plus live policy tests for the version3 and RegisterForRuntimeStartup3 paths asserting the cDAC/legacy
    gating and provider fallback paths.

- Add a SetCDacLoadPolicy export and process-wide setting lets the live-debugging connection APIs select the cDAC/legacy DAC policy.
- Call into the bundled DBI to check whether using cDAC with it suceeded. Each path invokes the DBI with the cDAC first and falls back to the legacy provider/side-by-side
path.
- Use simple unified helper to ensure cdac errors prevail over non-cdac ones in fallback scenario.
- Add SetCDacLoadPolicy test wrapper plus live policy tests for the version3 and RegisterForRuntimeStartup3 paths asserting the cDAC/legacy
gating and provider fallback paths.
Copilot AI review requested due to automatic review settings July 24, 2026 10:27
@hoyosjs
hoyosjs requested a review from a team as a code owner July 24, 2026 10:27

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

Routes dbgshim’s live debugging activation paths through a cDAC-capable DBI first, controlled by a new process-wide cDAC load policy export, with unit tests validating policy gating and fallback behavior.

Changes:

  • Add SetCDacLoadPolicy dbgshim export + policy enum, and plumb policy into live-debugging creation APIs.
  • Attempt activation via bundled DBI+cDAC first, then fall back to library-provider/side-by-side legacy activation with unified HRESULT selection.
  • Add managed test wrapper + new unit tests covering policy behavior for CreateDebuggingInterfaceFromVersion3 and RegisterForRuntimeStartup3.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/tests/DbgShim.UnitTests/DbgShimTests.cs Adds live policy test matrix and end-to-end tests for Version3 + RuntimeStartup3 policy gating and fallback behavior.
src/tests/DbgShim.UnitTests/DbgShimAPI.cs Adds managed delegate binding and wrapper for SetCDacLoadPolicy export.
src/dbgshim/debugshim.h Moves CDacLoadPolicy to shared header and exposes helpers for bundled cDAC+DBI resolution and activation-result selection.
src/dbgshim/debugshim.cpp Implements bundled cDAC+DBI path resolution helper and shares activation-result selection logic.
src/dbgshim/dbgshim.h Adds include guards, defines CDacLoadPolicy, and declares SetCDacLoadPolicy export.
src/dbgshim/dbgshim.cpp Implements process-wide policy and routes live-debugging creation paths through cDAC-first activation with fallback logic.
src/dbgshim/dbgshim.ntdef Exports SetCDacLoadPolicy on Windows.
src/dbgshim/dbgshim_unixexports.src Exports SetCDacLoadPolicy on Unix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/dbgshim/dbgshim.cpp
Comment on lines +232 to +235
// Policy for the live-debugging paths (RegisterForRuntimeStartup* and
// CreateDebuggingInterfaceFromVersion*), which don't flow through ICLRDebuggingPolicy. Set via the
// SetCDacLoadPolicy export.
static CDacLoadPolicy g_cdacLoadPolicy = CDacLoadPolicy_PreferCDac;
Comment thread src/dbgshim/dbgshim.cpp
Comment on lines +246 to +251
SString cdacPath;
SString dbiPath;
if (!GetCDacAndDbiPaths(cdacPath, dbiPath))
{
return E_FAIL;
}
Comment thread src/dbgshim/debugshim.cpp
Comment on lines 281 to 286
SString dbiModulePath;
if (!GetDbiPath(dbiModulePath))
SString cdacModulePath;
if (!GetCDacAndDbiPaths(cdacModulePath, dbiModulePath))
{
return E_FAIL;
}
Comment thread src/dbgshim/debugshim.h
// overrides), returning false if either is missing.
bool GetCDacAndDbiPaths(SString& cdacPath, SString& dbiPath);

// Picks the final HRESULT after tthe different activation attempts (cDAC vs. fallback) have completed.
Comment on lines +781 to +784

Assert.True(wait.WaitOne());
AssertResult(DbgShimAPI.UnregisterForRuntimeStartup(unregister));
Assert.Null(callbackException);
Comment thread src/dbgshim/debugshim.h Outdated
Co-authored-by: Noah Falk <noahfalk@users.noreply.github.com>
Comment thread src/dbgshim/debugshim.h Outdated
Comment thread src/dbgshim/debugshim.h Outdated
Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants