Delete debugger regdisplay#129671
Conversation
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
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
DebuggerREGDISPLAYfrom native and managed DacDbi APIs (Debugger_STRDatano longer carriesrd, andConvertContextToDebuggerRegDisplayis deleted). - Delete platform-specific
SetDebuggerREGDISPLAYFromREGDISPLAYhelpers and update callers to useDT_CONTEXT-based accessors. - Refactor
CordbRegisterSet/CordbNativeFrameto store and consumeDT_CONTEXTdirectly, and adjustCORDbgGetSPto returnCORDB_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
| // `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. |
| 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; |
There was a problem hiding this comment.
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.
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.