[cDAC] Implement GetArgumentByIndex and GetLocalVariableByIndex on ClrDataFrame#125463
Conversation
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
Implements cDAC-backed IXCLRDataFrame.GetArgumentByIndex / GetLocalVariableByIndex and introduces supporting DebugInfo/StackWalk contract APIs plus a new managed IXCLRDataValue implementation, with dump-based integration tests to validate behavior against the legacy DAC.
Changes:
- Extend DebugInfo contract v2 to decode/resolve native variable locations (vars section) and StackWalk contract to expose frame instruction pointers.
- Implement
ClrDataFrame.GetArgumentByIndex/GetLocalVariableByIndexusing cDAC debug info, and add a new managedClrDataValue(IXCLRDataValue) for returned argument/local values. - Add new dump debuggee (
LocalVariables) and dump-based integration tests forIXCLRDataFrame,IXCLRDataValue, andIXCLRDataAppDomain.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/managed/cdac/tests/DumpTests/IXCLRDataValueDumpTests.cs | New dump tests validating IXCLRDataValue returned from arg/local APIs |
| src/native/managed/cdac/tests/DumpTests/IXCLRDataFrameDumpTests.cs | New dump tests covering IXCLRDataFrame APIs including arg/local retrieval |
| src/native/managed/cdac/tests/DumpTests/IXCLRDataAppDomainDumpTests.cs | New dump tests for IXCLRDataAppDomain behavior via frame GetAppDomain |
| src/native/managed/cdac/tests/DumpTests/DumpTestBase.cs | Adds overload to initialize dump tests with per-test debuggee + dump type |
| src/native/managed/cdac/tests/DumpTests/Debuggees/StackWalk/Program.cs | Adjusts debuggee to ensure locals/args exist for stack inspection |
| src/native/managed/cdac/tests/DumpTests/Debuggees/LocalVariables/Program.cs | New debuggee producing known args/locals for value inspection |
| src/native/managed/cdac/tests/DumpTests/Debuggees/LocalVariables/LocalVariables.csproj | New debuggee project enabling full dumps |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/IXCLRData.cs | Updates COM signatures to use DacComNullableByRef for AppDomain methods |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs | New managed IXCLRDataValue implementation with legacy cross-validation |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataTask.cs | Updates ClrDataAppDomain construction to include Target |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs | Implements cDAC versions of GetAppDomain, arg/local-by-index, and helper parsing |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataAppDomain.cs | Implements cDAC AppDomain methods (GetName, GetUniqueID, GetFlags) |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs | Adds GetInstructionPointer for frame IP retrieval |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs | Returns "DefaultDomain" when FriendlyName is null |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/NativeVarInfo.cs | Adds internal var-loc types/struct mirroring runtime encoding |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/DebugInfo_2.cs | Implements GetMethodVarInfo + GetVariableLocations for v2 |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/DebugInfoHelpers.cs | Adds vars nibble-decoder and var-loc resolution across architectures |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IStackWalk.cs | Extends abstraction with GetInstructionPointer |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IDebugInfo.cs | Adds public stable DebugVarInfo/NativeVarLocation APIs |
| docs/design/datacontracts/Loader.md | Documents "DefaultDomain" fallback behavior |
| docs/design/datacontracts/DebugInfo.md | Documents DebugInfo v2 vars decoding + new APIs |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/DebugInfoHelpers.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/tests/DumpTests/IXCLRDataValueDumpTests.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/tests/DumpTests/IXCLRDataValueDumpTests.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/tests/DumpTests/IXCLRDataValueDumpTests.cs
Outdated
Show resolved
Hide resolved
50b6258 to
487d34e
Compare
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Outdated
Show resolved
Hide resolved
...cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/NativeVarInfo.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
5ec7202 to
47b23bf
Compare
47b23bf to
790f597
Compare
src/native/managed/cdac/tests/DumpTests/IXCLRDataFrameDumpTests.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Outdated
Show resolved
Hide resolved
...cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/NativeVarInfo.cs
Outdated
Show resolved
Hide resolved
790f597 to
9b0a451
Compare
9b0a451 to
dafa127
Compare
dafa127 to
f00fc33
Compare
src/native/managed/cdac/tests/DumpTests/IXCLRDataFrameDumpTests.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/tests/DumpTests/IXCLRDataValueDumpTests.cs
Outdated
Show resolved
Hide resolved
...e/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IStackWalk.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
f00fc33 to
0d65124
Compare
8a5ac15 to
14e2764
Compare
14e2764 to
6da2d24
Compare
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/DebugInfoHelpers.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/DebugInfoHelpers.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/tests/DumpTests/IXCLRDataValueDumpTests.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/tests/DumpTests/IXCLRDataFrameDumpTests.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Show resolved
Hide resolved
baa8a3c to
ae8782c
Compare
ae8782c to
4e9d328
Compare
4e9d328 to
00fd3c6
Compare
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Show resolved
Hide resolved
...c/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/DebugInfoHelpers.cs
Show resolved
Hide resolved
00fd3c6 to
8325e2d
Compare
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataValue.cs
Show resolved
Hide resolved
…nd IXCLRDataValue in managed cDAC Adds managed cDAC implementations for variable inspection APIs: - ClrDataFrame: GetArgumentByIndex, GetLocalVariableByIndex with signature decoding, debug info lookup, and register/stack variable resolution - ClrDataValue: GetFlags, GetAddress, GetSize, GetBytes, GetNumLocations, GetLocationByIndex with full type flag computation from metadata signatures - DebugInfo contract: GetMethodVarInfo with code offset computation - Integration tests covering all new APIs against real process dumps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8325e2d to
fb9d865
Compare
...e/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IDebugInfo.cs
Outdated
Show resolved
Hide resolved
The force push re-writing commit history makes it harder to compare what changed from the last time I reviewed. I'd prefer if we keep the history intact while reviews are happening and then squash at the end. |
…n, comment - Fix GetMethodSignatureInfo to skip generic arity before reading paramCount for generic method signatures (ECMA-335 compliance) - Fix GetArgumentByIndex to write empty string when GetParameterName returns null instead of leaving name buffer untouched - Replace unused 'out uint token' with 'out _' in GetLocalVariableByIndex - Fix outdated comment about GenericInstAndByRefVars parameter count Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs
Show resolved
Hide resolved
NativeVarLocation is an implementation detail of the IXCLRData interface, not part of the contract API surface. Move it to ClrDataValue.cs in the Legacy project where it is consumed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/ba-g test failures unrelated to cDAC change |
[cDAC] Implement GetArgumentByIndex and GetLocalVariableByIndex on ClrDataFrame
Builds on #125064 (GetContext/GetAppDomain) to add variable inspection support to the managed cDAC.
What this PR does
DebugInfo contract (variable location resolution):
GetMethodVarInfoonIDebugInfofor resolving native variable locations from JIT debug infoNativeVarInfotypes (internal) with DoVars nibble decoderDebugVarInfo/DebugVarLocKind(public stable API in Abstractions)DebugInfo.md(Version 2 section with VarLocType constants and encoding format)SignatureDecoder contract (type resolution):
DecodeMethodSignature-- decodes full method signature resolving all parameter/return types including generic instantiations (VAR, MVAR, GENERICINST)DecodeLocalSignature-- reads IL method body header, finds local signature token, decodes all local variable typesSignatureTypeProviderupdated to resolve class-level generic params (VAR) via MethodDescHandle contextSignatureDecoder.mdRuntimeTypeSystem contract:
IsEnum(TypeHandle)-- detects enum types via GetSignatureCorElementType(ValueType) + InternalCorElementType != ValueTypeGetPrimitiveType(CorElementType)-- returns TypeHandle for a primitive/well-known CorElementTypeRuntimeTypeSystem.md(API section + Version 1 pseudocode)ClrDataFrame.GetArgumentByIndex / GetLocalVariableByIndex:
thishandling for instance methodsISignatureDecodercontracts (DecodeMethodSignature/DecodeLocalSignature)GetMethodVarInfo+ local register/stack resolutionMapCorElementTypeToFlagsmatches native DAC'sGetTypeFieldValueFlags: IS_PRIMITIVE, IS_VALUE_TYPE, IS_REFERENCE, IS_STRING, IS_ARRAY, IS_ENUM, IS_POINTERELEMENT_TYPE_FNPTRunder#ifndef DACCESS_COMPILE-> IntPtr)AllowCdacSuccessvalidation modeClrDataValue (new, implements IXCLRDataValue):
GetFlags,GetSize,GetBytes,GetAddress,GetNumLocations,GetLocationByIndexClrDataValueFlagandClrDataVLocFlagmade public for test accessNative DAC fix:
REGNUM_AMBIENT_SPhandling inGetRegOffsInCONTEXTon AMD64 (util.cpp)Known Gaps (tracked as issues)
ClrDataFrame.GetContextshould usecontextFlagsto compute required context size (currently always returns full platform context)GetConstructedTypecannot resolve cross-module pointer TypeDescs (pointer variables likeint*return DEFAULT flags instead of IS_POINTER)Dump test scenarios
LocalVariablesdebuggee with 13 frames exercising type coverage from simple to complex:PrimitiveVarsNativeIntVarsStructVarsReferenceTypeVarsGenericInstAndByRefVarsInstanceMethodOnStructInstanceMethodVarsClassGenericVarsMethodGenericVarsSingleDimArrayVarsMultiDimArrayVarsPointerVarsCrashIXCLRDataValueDumpTests -- validates GetSize, GetFlags, GetBytes, GetNumLocations, GetLocationByIndex across all frames above.
IXCLRDataFrameDumpTests -- validates GetArgumentByIndex, GetLocalVariableByIndex, GetNumArguments, GetNumLocalVariables, GetContext, GetAppDomain, GetMethodInstance.
Validation