Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,31 @@ public int GetCountOfInternalFrames(ulong vmThread, uint* pRetVal)
public int EnumerateInternalFrames(ulong vmThread, nint fpCallback, nint pUserData)
=> LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.EnumerateInternalFrames(vmThread, fpCallback, pUserData) : HResults.E_NOTIMPL;

// Match native: ExInfo::IsUnwoundToTargetParentFrame is just an equality check.
public int IsMatchingParentFrame(ulong fpToCheck, ulong fpParent, Interop.BOOL* pResult)
=> LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.IsMatchingParentFrame(fpToCheck, fpParent, pResult) : HResults.E_NOTIMPL;
{
*pResult = Interop.BOOL.FALSE;
int hr = HResults.S_OK;
try
{
*pResult = fpToCheck == fpParent ? Interop.BOOL.TRUE : Interop.BOOL.FALSE;
}
catch (System.Exception ex)
{
hr = ex.HResult;
}
#if DEBUG
if (_legacy is not null)
{
Interop.BOOL resultLocal;
int hrLocal = _legacy.IsMatchingParentFrame(fpToCheck, fpParent, &resultLocal);
Debug.ValidateHResult(hr, hrLocal);
if (hr == HResults.S_OK)
Debug.Assert(*pResult == resultLocal, $"cDAC: {*pResult}, DAC: {resultLocal}");
}
#endif
return hr;
}

public int GetStackParameterSize(ulong controlPC, uint* pRetVal)
=> LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetStackParameterSize(controlPC, pRetVal) : HResults.E_NOTIMPL;
Expand Down
54 changes: 54 additions & 0 deletions src/native/managed/cdac/tests/DacDbiImplTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Diagnostics.DataContractReader.Legacy;
using Xunit;

namespace Microsoft.Diagnostics.DataContractReader.Tests;

public class DacDbiImplTests
{
private static DacDbiImpl CreateDacDbi(MockTarget.Architecture arch)
{
var builder = new TestPlaceholderTarget.Builder(arch);
TestPlaceholderTarget target = builder.Build();
return new DacDbiImpl(target, legacyObj: null);
}

[Theory]
[ClassData(typeof(MockTarget.StdArch))]
public unsafe void IsMatchingParentFrame_EqualFramePointers_ReturnsTrue(MockTarget.Architecture arch)
{
DacDbiImpl dbi = CreateDacDbi(arch);

ulong[] testValues = [0x1000, 0, ulong.MaxValue, 0x7FFF_FFFF_FFFF_FFFFul];
foreach (ulong value in testValues)
{
Interop.BOOL result;
int hr = dbi.IsMatchingParentFrame(value, value, &result);
Assert.Equal(System.HResults.S_OK, hr);
Assert.Equal(Interop.BOOL.TRUE, result);
}
}

[Theory]
[ClassData(typeof(MockTarget.StdArch))]
public unsafe void IsMatchingParentFrame_DifferentFramePointers_ReturnsFalse(MockTarget.Architecture arch)
{
DacDbiImpl dbi = CreateDacDbi(arch);

(ulong fpToCheck, ulong fpParent)[] testCases =
[
(0x1000, 0x2000),
(0, 1),
(ulong.MaxValue, 0),
];
foreach ((ulong fpToCheck, ulong fpParent) in testCases)
{
Interop.BOOL result;
int hr = dbi.IsMatchingParentFrame(fpToCheck, fpParent, &result);
Assert.Equal(System.HResults.S_OK, hr);
Assert.Equal(Interop.BOOL.FALSE, result);
}
}
}
Loading