提交 3b6a6cd5 编写于 作者: A Andrew Casey

Suppress expansion of void* rows

...because they would have type ```void```, which can't be instantiated.
上级 29e3b549
......@@ -710,11 +710,54 @@ internal C(long p)
EvalResult(fullName, "{4}", "System.IntPtr", fullName, DkmEvaluationResultFlags.Expandable));
children = GetChildren(children[0]);
Verify(children,
EvalResult("m_value", PointerToString(new IntPtr(i)), "void*", string.Format("({0}).m_value", fullName), DkmEvaluationResultFlags.Expandable),
EvalResult("m_value", PointerToString(new IntPtr(i)), "void*", string.Format("({0}).m_value", fullName)),
EvalResult("Static members", null, "", "System.IntPtr", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Class));
}
}
[WorkItem(1154608)]
[Fact]
public void VoidPointer()
{
var source = @"
using System;
unsafe class C
{
internal C(long p)
{
this.v = (void*)p;
this.vv = (void**)p;
}
void* v;
void** vv;
}";
var assembly = GetUnsafeAssembly(source);
unsafe
{
// NOTE: We're depending on endian-ness to put
// the interesting bytes first when we run this
// test as 32-bit.
long i = 4;
long p = (long)&i;
long pp = (long)&p;
var type = assembly.GetType("C");
var rootExpr = $"new C({pp})";
var value = CreateDkmClrValue(type.Instantiate(pp));
var evalResult = FormatResult(rootExpr, value);
Verify(evalResult,
EvalResult(rootExpr, "{C}", "C", rootExpr, DkmEvaluationResultFlags.Expandable));
var children = GetChildren(evalResult);
Verify(children,
EvalResult("v", PointerToString(new IntPtr(pp)), "void*", $"({rootExpr}).v"),
EvalResult("vv", PointerToString(new IntPtr(pp)), "void**", $"({rootExpr}).vv", DkmEvaluationResultFlags.Expandable));
string fullName = $"*({rootExpr}).vv";
children = GetChildren(children[1]);
Verify(children,
EvalResult(fullName, PointerToString(new IntPtr(p)), "void*", fullName));
}
}
[WorkItem(1064176)]
[Fact]
public void NullPointer()
......
......@@ -819,7 +819,10 @@ private void GetEvaluationResultsAndContinue(ArrayBuilder<EvalResultDataItem> ro
{
// If this ever happens, the element type info is just .SkipOne().
Debug.Assert(!new DynamicFlagsCustomTypeInfo(declaredTypeAndInfo.Info).Any());
return !value.IsNull ? new PointerDereferenceExpansion(new TypeAndCustomInfo(declaredType.GetElementType())) : null;
var elementType = declaredType.GetElementType();
return value.IsNull || elementType.IsVoid()
? null
: new PointerDereferenceExpansion(new TypeAndCustomInfo(elementType));
}
if (value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown) &&
......
......@@ -98,7 +98,7 @@ public DkmClrValue Dereference(DkmInspectionContext inspectionContext)
value = e;
evalFlags |= DkmEvaluationResultFlags.ExceptionThrown;
}
var valueType = new DkmClrType(this.Type.RuntimeInstance, (value == null) ? elementType : (TypeImpl)value.GetType());
var valueType = new DkmClrType(this.Type.RuntimeInstance, (value == null || elementType.IsPointer) ? elementType : (TypeImpl)value.GetType());
return new DkmClrValue(
value,
value,
......@@ -489,13 +489,13 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare
{
unsafe
{
if (Marshal.SizeOf(typeof(void*)) == 4)
if (Environment.Is64BitProcess)
{
value = (int)System.Reflection.Pointer.Unbox(value);
value = (long)System.Reflection.Pointer.Unbox(value);
}
else
{
value = (long)System.Reflection.Pointer.Unbox(value);
value = (int)System.Reflection.Pointer.Unbox(value);
}
}
type = declaredType;
......@@ -711,7 +711,10 @@ private unsafe static object Dereference(IntPtr ptr, Type elementType)
{
throw new InvalidOperationException("Dereferencing null");
}
return Marshal.PtrToStructure(ptr, ((TypeImpl)elementType).Type);
var destinationType = elementType.IsPointer
? (Environment.Is64BitProcess ? typeof(long) : typeof(int))
: ((TypeImpl)elementType).Type;
return Marshal.PtrToStructure(ptr, destinationType);
default:
throw new InvalidOperationException();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册