Skip to content

Delete debugger regdisplay#129671

Open
rcj1 wants to merge 3 commits into
dotnet:mainfrom
rcj1:delete-DebuggerREGDISPLAY
Open

Delete debugger regdisplay#129671
rcj1 wants to merge 3 commits into
dotnet:mainfrom
rcj1:delete-DebuggerREGDISPLAY

Conversation

@rcj1

@rcj1 rcj1 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

This is not intended to be the final form; I intend to delete these platform-specific register readers altogether. This is just the first stage of a larger refactor, separated out such that we can remove the associated DacDbi API as well as remove the data structure from the API surface.

Copilot AI review requested due to automatic review settings June 21, 2026 17:01
@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.

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 removes the DebuggerREGDISPLAY plumbing from the DacDbi surface area and migrates the right-side/debugger register and stack-walk codepaths to operate directly on DT_CONTEXT (including deleting multiple platform-specific regdisplay conversion helpers).

Changes:

  • Remove DebuggerREGDISPLAY from native and managed DacDbi APIs (Debugger_STRData no longer carries rd, and ConvertContextToDebuggerRegDisplay is deleted).
  • Delete platform-specific SetDebuggerREGDISPLAYFromREGDISPLAY helpers and update callers to use DT_CONTEXT-based accessors.
  • Refactor CordbRegisterSet/CordbNativeFrame to store and consume DT_CONTEXT directly, and adjust CORDbgGetSP to return CORDB_ADDRESS.
Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Updates managed interop definitions to match the removed regdisplay pointer/method.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Drops the regdisplay conversion method and updates frame enumeration commentary.
src/coreclr/inc/dacdbi.idl Removes DebuggerREGDISPLAY forward decl and the regdisplay conversion method from the COM IDL.
src/coreclr/debug/shared/riscv64/primitives.cpp Deletes RISCV64 regdisplay conversion helper.
src/coreclr/debug/shared/loongarch64/primitives.cpp Deletes LoongArch64 regdisplay conversion helper.
src/coreclr/debug/shared/i386/primitives.cpp Deletes x86 context/regdisplay conversion helpers.
src/coreclr/debug/shared/arm64/primitives.cpp Deletes ARM64 regdisplay conversion helper.
src/coreclr/debug/shared/arm/primitives.cpp Deletes ARM regdisplay conversion helpers.
src/coreclr/debug/shared/amd64/primitives.cpp Deletes AMD64 context/regdisplay conversion helpers.
src/coreclr/debug/inc/riscv64/primitives.h Changes CORDbgGetSP to return CORDB_ADDRESS.
src/coreclr/debug/inc/loongarch64/primitives.h Changes CORDbgGetSP to return CORDB_ADDRESS.
src/coreclr/debug/inc/i386/primitives.h Changes CORDbgGetSP to return CORDB_ADDRESS.
src/coreclr/debug/inc/dbgipcevents.h Removes DebuggerREGDISPLAY struct and switches SP/FP address helpers to DT_CONTEXT.
src/coreclr/debug/inc/dacdbistructures.h Removes the DebuggerREGDISPLAY* field from Debugger_STRData.
src/coreclr/debug/inc/dacdbiinterface.h Removes ConvertContextToDebuggerRegDisplay from the native interface.
src/coreclr/debug/inc/common.h Removes the DebuggerREGDISPLAY forward decl and related helper declaration.
src/coreclr/debug/inc/arm64/primitives.h Changes CORDbgGetSP to return CORDB_ADDRESS.
src/coreclr/debug/inc/arm/primitives.h Changes CORDbgGetSP to return CORDB_ADDRESS.
src/coreclr/debug/inc/amd64/primitives.h Changes CORDbgGetSP to return CORDB_ADDRESS.
src/coreclr/debug/ee/i386/regdisplayhelper.cpp Renames/rebrands helper file header comment to REGDISPLAY-to-REGDISPLAY transfer.
src/coreclr/debug/ee/debugger.h Removes regdisplay helper declarations/macros no longer applicable.
src/coreclr/debug/ee/CMakeLists.txt Updates source list to new helper filename.
src/coreclr/debug/ee/amd64/regdisplayhelper.cpp Renames/rebrands helper file header comment to REGDISPLAY-to-REGDISPLAY transfer.
src/coreclr/debug/di/shimstackwalk.cpp Adjusts stack pointer handling to the new CORDbgGetSP return type.
src/coreclr/debug/di/rsthread.cpp Refactors register set + native frame code to use DT_CONTEXT instead of DebuggerREGDISPLAY.
src/coreclr/debug/di/rsstackwalk.cpp Stops allocating/passing regdisplay buffers; passes only DT_CONTEXT through Debugger_STRData.
src/coreclr/debug/di/rsregsetcommon.cpp Updates CordbRegisterSet to store a copied DT_CONTEXT and use CORDbgCopyThreadContext.
src/coreclr/debug/di/rspriv.h Updates type members and constructor signatures to remove DebuggerREGDISPLAY usage.
src/coreclr/debug/di/riscv64/cordbregisterset.cpp Removes the unused regdisplay-to-context helper (RISCV64 still NYI for GetRegisters).
src/coreclr/debug/di/loongarch64/cordbregisterset.cpp Refactors register reads to use DT_CONTEXT and deduplicates mapping via a helper.
src/coreclr/debug/di/i386/cordbregisterset.cpp Switches register reads from regdisplay fields to DT_CONTEXT.
src/coreclr/debug/di/arm64/cordbregisterset.cpp Switches register reads from regdisplay fields to DT_CONTEXT.
src/coreclr/debug/di/arm/cordbregisterset.cpp Switches register reads from regdisplay fields to DT_CONTEXT.
src/coreclr/debug/di/amd64/cordbregisterset.cpp Switches register reads from regdisplay fields to DT_CONTEXT.
src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp Deletes regdisplay conversion implementation and stops populating Debugger_STRData::rd.
src/coreclr/debug/daccess/dacdbiimpl.h Removes the regdisplay conversion method declaration from the DAC implementation.

Copilot's findings

  • Files reviewed: 36/36 changed files
  • Comments generated: 4

Comment thread src/coreclr/debug/di/rsregsetcommon.cpp
Comment thread src/coreclr/debug/di/rsstackwalk.cpp Outdated
Comment thread src/coreclr/debug/di/loongarch64/cordbregisterset.cpp
Copilot AI review requested due to automatic review settings June 21, 2026 18:21

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.

Copilot's findings

  • Files reviewed: 36/36 changed files
  • Comments generated: 2

Comment on lines +223 to 226
// `ctx` is a pointer into dbi-allocated memory.
// The DAC writes the populated context into this pointer rather
// than storing them inline. Code paths that do not produce a context/regdisplay
// (e.g. EnumerateInternalFrames for cStubFrame entries) leave them as 0.
Comment on lines +178 to +182
default:
_ASSERTE(false); break;
}

return S_OK;
// This CordbRegisterSet is responsible to free this memory if m_fTakeOwnershipOfDRD is true. Otherwise,
// this memory is freed by the CordbNativeFrame or CordbThread which creates this CordbRegisterSet.
DebuggerREGDISPLAY *m_rd;
DT_CONTEXT m_context;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The full CONTEXT has variable size for optional fields. The optional fields are used to store values of registers that are only present in hardware extensions (e.g. SIMD registers, or the new Intel's APX extension). AllocateOSContextHelper has logic that computes the size of memory required to hold the full CONTEXT.

Storing context in a fixed sized field like this often ends up being a bug since it does not handle optional fields.

I am not sure how much you need to be worried for this PR. I just wanted to mention it since it comes up as a problem regularly.

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.

3 participants