Implement ISOSDacInterface::GetRegisterName in cDAC SOSDacImpl#124803
Implement ISOSDacInterface::GetRegisterName in cDAC SOSDacImpl#124803
Conversation
Replace the legacy-only delegation with a full contract-based implementation that uses IRuntimeInfo.GetTargetArchitecture() to select the correct register name arrays for each architecture (X64, X86, ARM, ARM64, LoongArch64, RiscV64). Add comprehensive unit tests covering all architectures, caller frame prefix, edge cases (null buffers, out-of-range, small buffer), and unsupported architectures. Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
The regName parameter is mutated inside the try block for caller frame decoding. Save the original value before mutation so the DEBUG assertion correctly compares against the legacy DAC with the original parameter. Also add missing blank line before GetStackLimits method. Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Outdated
Show resolved
Hide resolved
|
@copilot, fix the failing CI run and address feedback |
Instead of saving regName to originalRegName before mutation, use a separate regIndex local for the decoded register index. This keeps regName unchanged so it can be used directly in the DEBUG validation block without needing a separate #if DEBUG section. Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
This PR implements the GetRegisterName method in the cDAC SOSDacImpl class, replacing the legacy DAC delegation with a contract-based implementation. The implementation uses the RuntimeInfo contract to dynamically determine the target architecture at runtime, eliminating the need for compile-time #ifdef guards used in the C++ version.
Changes:
- Implements
GetRegisterNameusingIRuntimeInfo.GetTargetArchitecture()to select architecture-specific register name arrays - Adds register name arrays for all six supported architectures (X64, X86, ARM, ARM64, LoongArch64, RiscV64)
- Includes comprehensive test coverage with 32 tests across all architectures and edge cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs |
Implements GetRegisterName with architecture-specific register arrays, caller frame encoding, error handling, and DEBUG legacy comparison |
src/native/managed/cdac/tests/GetRegisterNameTests.cs |
Adds comprehensive tests covering all architectures, caller frames, null/small buffers, out-of-range indices, and unsupported architecture scenarios |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Outdated
Show resolved
Hide resolved
Instead of returning E_POINTER before the try block, throw a NullReferenceException inside it. The catch block converts ex.HResult to E_POINTER (0x80004003) automatically, and the DEBUG comparison block now runs for this error path as well. Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
Description
Implements
GetRegisterNameinSOSDacImpl.csusing theRuntimeInfocontract instead of delegating to the legacy DAC. This mirrors the logic inClrDataAccess::GetRegisterName(request.cpp) but usesIRuntimeInfo.GetTargetArchitecture()at runtime to select register names, rather than compile-time#ifdefguards.Implementation (
SOSDacImpl.cs)regNum→"caller.<reg>"via-(reg+1), using a separateregIndexlocal to avoid mutating the parameterNullReferenceExceptionthrown inside the try block when bothbufferandpNeededare null (HResult maps toE_POINTER), following the established pattern in the file (e.g.,IsRCWDCOMProxy)E_UNEXPECTEDfor out-of-range register indexS_FALSEwhen buffer is too small (partial copy viaOutputBufferHelpers)#if DEBUGlegacy DAC comparison using the unmutatedregNameparameter directlyTests (
GetRegisterNameTests.cs)Fixes #124823
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.