[WIP] Implement IXCLRDataExceptionState state comparison#131011
Conversation
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
Implements IXCLRDataExceptionState.IsSameState / IsSameState2 in the cDAC legacy shim and adds unit tests to validate the HRESULT behavior when comparing exception state based on exception address and “first-chance” semantics.
Changes:
- Implement
IXCLRDataExceptionState.IsSameStateandIsSameState2inClrDataExceptionState(including DEBUG-only validation against the legacy DAC implementation). - Add unit tests for state comparison (
IsSameState/IsSameState2) and flag validation behavior.
Show a summary per file
| File | Description |
|---|---|
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataExceptionState.cs | Adds cDAC implementation of exception state comparison logic for IsSameState/IsSameState2. |
| src/native/managed/cdac/tests/UnitTests/ClrDataExceptionStateTests.cs | Adds unit tests covering matching/different exception addresses and IsSameState2 flag handling. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
| ThreadData threadData = _target.Contracts.Thread.GetThreadData(_threadAddress); | ||
| TargetPointer exceptionAddress = _target.ReadPointer( | ||
| threadData.OSExceptionRecord + (ulong)(sizeof(uint) * 2 + _target.PointerSize)); |
| [Theory] | ||
| [ClassData(typeof(MockTarget.StdArch))] | ||
| public void IsSameState2_DifferentAddress(MockTarget.Architecture arch) | ||
| { | ||
| const ulong exceptionAddress = 0x1234_5678; | ||
| IXCLRDataExceptionState exceptionState = CreateExceptionStateWithRecord(arch, exceptionAddress); | ||
| EXCEPTION_RECORD64 inputRecord = new() { ExceptionAddress = exceptionAddress + 1 }; | ||
|
|
||
| int hr = exceptionState.IsSameState2(0, &inputRecord, 0, null); | ||
|
|
||
| Assert.Equal(HResults.S_FALSE, hr); | ||
| } |
|
@copilot 1. please put both flags under CLRDATA_EXCEPTION_PARTIAL in an enum in IXCLRData.cs. |
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Implemented in |
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (1)
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/IXCLRData.cs:969
- This adds a new public enum type to the Legacy assembly. Unless this is intended to be part of the supported public surface, consider making it internal (tests can still access it via InternalsVisibleTo) to avoid expanding public API and triggering API-approval requirements.
[Flags]
public enum CLRDataExceptionSameFlag : uint
{
CLRDATA_EXSAME_SECOND_CHANCE = 0,
CLRDATA_EXSAME_FIRST_CHANCE = 0x1,
}
- Files reviewed: 5/5 changed files
- Comments generated: 1
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (1)
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/IXCLRData.cs:969
- This change introduces new public API surface (CLRDataExceptionSameFlag). The provided PR metadata doesn’t include any linked
api-approvedissue/proposal, which is required for new public APIs in dotnet/runtime. Either (1) link the approved API proposal/issue, or (2) make this enuminternalif it’s only intended for internal/test use (the Legacy csproj already has InternalsVisibleTo for the tests).
[Flags]
public enum CLRDataExceptionSameFlag : uint
{
CLRDATA_EXSAME_SECOND_CHANCE = 0,
CLRDATA_EXSAME_FIRST_CHANCE = 0x1,
}
- Files reviewed: 5/5 changed files
- Comments generated: 1
| const ulong exceptionAddress = 0x1234_5678; | ||
| IXCLRDataExceptionState exceptionState = CreateExceptionStateWithRecord(arch, exceptionAddress); | ||
| EXCEPTION_RECORD64 inputRecord = new() { ExceptionAddress = exceptionAddress + 1 }; | ||
|
|
||
| int hr = exceptionState.IsSameState2((uint)CLRDataExceptionSameFlag.CLRDATA_EXSAME_SECOND_CHANCE, &inputRecord, 0, null); | ||
|
|
||
| Assert.Equal(HResults.S_FALSE, hr); | ||
| } |
No description provided.