提交 0b2d8a65 编写于 作者: A Andrew Casey

Merge pull request #5133 from amcasey/GH4138

Swallow ArgumentOutOfRangeException while retrieving custom debug info
......@@ -156,17 +156,26 @@ private static void ValidateItems(int actualCount, int bufferLength)
/// </summary>
public static byte[] GetCustomDebugInfoBytes(this ISymUnmanagedReader reader, int methodToken, int methodVersion)
{
return GetItems(
reader,
methodToken,
methodVersion,
(ISymUnmanagedReader pReader, int pMethodToken, int pMethodVersion, int pBufferLength, out int pCount, byte[] pCustomDebugInfo) =>
// Note: Here, we are assuming that the sym reader implementation we're using implements ISymUnmanagedReader3. This is
// necessary so that we get custom debug info for the correct method version in EnC scenarios. However, some sym reader
// implementations do not support this interface (for example, the mscordbi dynamic sym reader). If we need to fall back
// and call ISymUnmanagedReader.GetSymAttribute in those cases (assuming EnC is not supported), then we'll need to ensure
// that incorrect or missing custom debug info will not cause problems for any callers of this method.
((ISymUnmanagedReader3)pReader).GetSymAttributeByVersion(pMethodToken, pMethodVersion, CdiAttributeName, pBufferLength, out pCount, pCustomDebugInfo));
try
{
return GetItems(
reader,
methodToken,
methodVersion,
(ISymUnmanagedReader pReader, int pMethodToken, int pMethodVersion, int pBufferLength, out int pCount, byte[] pCustomDebugInfo) =>
// Note: Here, we are assuming that the sym reader implementation we're using implements ISymUnmanagedReader3. This is
// necessary so that we get custom debug info for the correct method version in EnC scenarios. However, some sym reader
// implementations do not support this interface (for example, the mscordbi dynamic sym reader). If we need to fall back
// and call ISymUnmanagedReader.GetSymAttribute in those cases (assuming EnC is not supported), then we'll need to ensure
// that incorrect or missing custom debug info will not cause problems for any callers of this method.
((ISymUnmanagedReader3)pReader).GetSymAttributeByVersion(pMethodToken, pMethodVersion, CdiAttributeName, pBufferLength, out pCount, pCustomDebugInfo));
}
catch (ArgumentOutOfRangeException)
{
// Sometimes the debugger returns the HRESULT for ArgumentOutOfRangeException, rather than E_FAIL,
// for methods without custom debug info (https://github.com/dotnet/roslyn/issues/4138).
return null;
}
}
public static int GetUserEntryPoint(this ISymUnmanagedReader symReader)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册