diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
index d75174246bf125..6f3b7bfeb09502 100644
--- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -133,6 +133,7 @@
+
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.TypeDataWalk.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.TypeDataWalk.cs
new file mode 100644
index 00000000000000..c25a5b4c4fb4cd
--- /dev/null
+++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.TypeDataWalk.cs
@@ -0,0 +1,254 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Buffers.Binary;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Diagnostics;
+
+public static partial class Debugger
+{
+ internal sealed unsafe partial class FunctionEvaluation
+ {
+ // DebuggerIPCE_TypeArgData uses fixed-width, little-endian debugger cookies, not native pointers.
+ // corelib.h verifies this layout against the native record.
+ [ExtendedLayout(ExtendedLayoutKind.CStruct)]
+ internal struct NativeTypeArgument
+ {
+ internal NativeExpandedTypeData Data;
+ internal uint ChildCount;
+ }
+
+ [ExtendedLayout(ExtendedLayoutKind.CStruct)]
+ internal struct NativeExpandedTypeData
+ {
+ internal uint ElementType;
+ internal NativeTypeDataUnion TypeData;
+ }
+
+ [ExtendedLayout(ExtendedLayoutKind.CUnion)]
+ internal struct NativeTypeDataUnion
+ {
+ internal NativeClassTypeData ClassTypeData;
+ internal NativeUnaryTypeData UnaryTypeData;
+ internal NativeArrayTypeData ArrayTypeData;
+ internal NativeNaryTypeData NaryTypeData;
+ }
+
+ [ExtendedLayout(ExtendedLayoutKind.CStruct)]
+ internal struct NativeBasicTypeData
+ {
+ internal uint ElementType;
+ internal uint MetadataToken;
+ internal ulong Assembly;
+ internal ulong TypeHandle;
+ }
+
+ [ExtendedLayout(ExtendedLayoutKind.CStruct)]
+ internal struct NativeClassTypeData
+ {
+ internal uint MetadataToken;
+ internal ulong Assembly;
+ internal ulong TypeHandle;
+ }
+
+ [ExtendedLayout(ExtendedLayoutKind.CStruct)]
+ internal struct NativeUnaryTypeData
+ {
+ internal NativeBasicTypeData UnaryTypeArgument;
+ }
+
+ [ExtendedLayout(ExtendedLayoutKind.CStruct)]
+ internal struct NativeArrayTypeData
+ {
+ internal NativeBasicTypeData ArrayTypeArgument;
+ internal uint ArrayRank;
+ }
+
+ [ExtendedLayout(ExtendedLayoutKind.CStruct)]
+ internal struct NativeNaryTypeData
+ {
+ internal ulong TypeHandle;
+ }
+
+ [DebuggerHidden]
+ internal static RuntimeType[] ReadTypeArguments(ReadOnlySpan typeData, int count)
+ {
+ if (typeData.Length % sizeof(NativeTypeArgument) != 0)
+ {
+ throw new ArgumentException();
+ }
+
+ TypeDataWalk walk = new(MemoryMarshal.Cast(typeData));
+ RuntimeType[] types = walk.ReadTypeHandles(count);
+ if (!walk.IsFinished)
+ {
+ throw new ArgumentException();
+ }
+
+ return types;
+ }
+
+ private static ReadOnlySpan GetTypeData(byte* data, uint nodeCount) =>
+ new(data, checked((int)nodeCount * sizeof(NativeTypeArgument)));
+
+ private static RuntimeModule GetModule(nint nativeAssembly)
+ {
+ if (nativeAssembly == 0)
+ {
+ throw new ArgumentException();
+ }
+
+ return (RuntimeModule)RuntimeAssembly.GetAssemblyFromHandle(nativeAssembly).ManifestModule;
+ }
+
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
+ Justification = "The debugger supplies tokens from the target's actual loaded metadata.")]
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern",
+ Justification = "The debugger supplies the target's actual runtime generic arguments.")]
+ private static RuntimeType ReadInstantiation(
+ RuntimeModule module, int token, RuntimeType[] arguments, bool allowUninstantiated = false)
+ {
+ RuntimeType type = (RuntimeType)module.ResolveType(token);
+ if (arguments.Length != 0 || (!allowUninstantiated && type.IsGenericTypeDefinition))
+ {
+ type = (RuntimeType)type.MakeGenericType(arguments);
+ }
+
+ return type;
+ }
+
+ [StackTraceHidden]
+ private ref struct TypeDataWalk
+ {
+ private ReadOnlySpan _remaining;
+
+ internal TypeDataWalk(ReadOnlySpan data)
+ {
+ _remaining = data;
+ }
+
+ internal readonly bool IsFinished => _remaining.IsEmpty;
+
+ internal RuntimeType[] ReadTypeHandles(int count)
+ {
+ if ((uint)count > (uint)_remaining.Length)
+ {
+ throw new ArgumentException();
+ }
+
+ RuntimeType[] types = count == 0 ? [] : new RuntimeType[count];
+ for (int i = 0; i < types.Length; i++)
+ {
+ types[i] = ReadTypeHandle();
+ }
+
+ return types;
+ }
+
+ private RuntimeType ReadTypeHandle()
+ {
+ if (_remaining.IsEmpty)
+ {
+ throw new ArgumentException();
+ }
+
+ NativeTypeArgument node = _remaining[0];
+ _remaining = _remaining[1..];
+ if (!BitConverter.IsLittleEndian)
+ {
+ node.Data.ElementType = BinaryPrimitives.ReverseEndianness(node.Data.ElementType);
+ node.Data.TypeData.ClassTypeData.MetadataToken =
+ BinaryPrimitives.ReverseEndianness(node.Data.TypeData.ClassTypeData.MetadataToken);
+ node.Data.TypeData.ClassTypeData.Assembly =
+ BinaryPrimitives.ReverseEndianness(node.Data.TypeData.ClassTypeData.Assembly);
+ node.Data.TypeData.ArrayTypeData.ArrayRank =
+ BinaryPrimitives.ReverseEndianness(node.Data.TypeData.ArrayTypeData.ArrayRank);
+ node.ChildCount = BinaryPrimitives.ReverseEndianness(node.ChildCount);
+ }
+
+ uint elementValue = node.Data.ElementType;
+ if (elementValue > byte.MaxValue)
+ {
+ throw new ArgumentException();
+ }
+
+ CorElementType elementType = (CorElementType)elementValue;
+ uint childCount = node.ChildCount;
+ if (childCount > (uint)_remaining.Length)
+ {
+ throw new ArgumentException();
+ }
+
+ switch (elementType)
+ {
+ case CorElementType.ELEMENT_TYPE_ARRAY:
+ case CorElementType.ELEMENT_TYPE_SZARRAY:
+ case CorElementType.ELEMENT_TYPE_PTR:
+ case CorElementType.ELEMENT_TYPE_BYREF:
+ if (childCount != 1)
+ {
+ throw new ArgumentException();
+ }
+
+ RuntimeType element = ReadTypeHandle();
+ return elementType switch
+ {
+ CorElementType.ELEMENT_TYPE_ARRAY => (RuntimeType)element.MakeArrayType(
+ unchecked((int)node.Data.TypeData.ArrayTypeData.ArrayRank)),
+ CorElementType.ELEMENT_TYPE_SZARRAY => (RuntimeType)element.MakeArrayType(),
+ CorElementType.ELEMENT_TYPE_PTR => (RuntimeType)element.MakePointerType(),
+ _ => (RuntimeType)element.MakeByRefType(),
+ };
+
+ case CorElementType.ELEMENT_TYPE_CLASS:
+ case CorElementType.ELEMENT_TYPE_VALUETYPE:
+ nint assembly = (nint)checked((nuint)node.Data.TypeData.ClassTypeData.Assembly);
+ RuntimeModule module = GetModule(assembly);
+ int token = unchecked((int)node.Data.TypeData.ClassTypeData.MetadataToken);
+ return ReadInstantiation(module, token, ReadTypeHandles((int)childCount));
+
+ case CorElementType.ELEMENT_TYPE_FNPTR:
+ if (childCount == 0)
+ {
+ throw new ArgumentException();
+ }
+
+ RuntimeType[] signature = ReadTypeHandles((int)childCount);
+ return signature[0].TypeHandle.MakeFunctionPointer(signature.AsSpan(1).ToArray(), isUnmanaged: false);
+
+ default:
+ if (childCount != 0)
+ {
+ throw new ArgumentException();
+ }
+
+ return (RuntimeType)(elementType switch
+ {
+ CorElementType.ELEMENT_TYPE_VOID => typeof(void),
+ CorElementType.ELEMENT_TYPE_BOOLEAN => typeof(bool),
+ CorElementType.ELEMENT_TYPE_CHAR => typeof(char),
+ CorElementType.ELEMENT_TYPE_I1 => typeof(sbyte),
+ CorElementType.ELEMENT_TYPE_U1 => typeof(byte),
+ CorElementType.ELEMENT_TYPE_I2 => typeof(short),
+ CorElementType.ELEMENT_TYPE_U2 => typeof(ushort),
+ CorElementType.ELEMENT_TYPE_I4 => typeof(int),
+ CorElementType.ELEMENT_TYPE_U4 => typeof(uint),
+ CorElementType.ELEMENT_TYPE_I8 => typeof(long),
+ CorElementType.ELEMENT_TYPE_U8 => typeof(ulong),
+ CorElementType.ELEMENT_TYPE_R4 => typeof(float),
+ CorElementType.ELEMENT_TYPE_R8 => typeof(double),
+ CorElementType.ELEMENT_TYPE_STRING => typeof(string),
+ CorElementType.ELEMENT_TYPE_TYPEDBYREF => typeof(TypedReference),
+ CorElementType.ELEMENT_TYPE_I => typeof(nint),
+ CorElementType.ELEMENT_TYPE_U => typeof(nuint),
+ CorElementType.ELEMENT_TYPE_OBJECT => typeof(object),
+ _ => throw new ArgumentException(),
+ });
+ }
+ }
+ }
+ }
+}
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.cs
index bd38a742659562..57b9e438a6b157 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.cs
@@ -35,12 +35,28 @@ internal struct Context
internal void* ResultData;
// GC Handle to result (if boxed).
internal IntPtr ResultHandle;
- internal void* Module;
+ internal void* Assembly;
+ internal byte* TypeArguments;
+ internal void* EvaluationData;
+ internal nuint StringSize;
+ internal nuint ArrayRank;
internal uint ArgumentCount;
internal uint ParameterCount;
internal EvaluationFlags Flags;
- internal uint MethodToken;
+ internal uint MemberToken;
internal uint GenericArgsCount;
+ internal uint GenericArgsNodeCount;
+ internal EvaluationKind Kind;
+ }
+
+ // Values must match DebuggerIPCE_FuncEvalType (DB_IPCE_FET_*) and native DebuggerFuncEvalKind.
+ internal enum EvaluationKind : uint
+ {
+ Normal,
+ NewObject,
+ NewObjectNoConstructor,
+ NewString,
+ NewArray,
}
[Flags]
@@ -63,8 +79,10 @@ internal enum ArgumentFlags : uint
internal struct NativeArgument
{
internal byte* Literal;
+ internal byte* TypeData;
internal uint ElementType;
internal ArgumentFlags Flags;
+ internal uint TypeNodeCount;
internal readonly bool IsLiteral => (Flags & ArgumentFlags.Literal) != 0;
internal readonly bool IsHandle => (Flags & ArgumentFlags.Handle) != 0;
@@ -117,6 +135,20 @@ private struct Argument
[DebuggerHidden]
internal static void Run(Context* context)
{
+ switch (context->Kind)
+ {
+ case EvaluationKind.NewObjectNoConstructor:
+ case EvaluationKind.NewString:
+ case EvaluationKind.NewArray:
+ RunSimple(context);
+ return;
+ case EvaluationKind.Normal:
+ case EvaluationKind.NewObject:
+ break;
+ default:
+ throw new UnreachableException();
+ }
+
const int MaxStackArguments = 14;
int argumentCount = checked((int)context->ArgumentCount);
int storageCount = checked(argumentCount + 2);
@@ -149,6 +181,160 @@ internal static void Run(Context* context)
}
}
+ [DebuggerHidden]
+ [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode",
+ Justification = "Debugger function evaluation constructs arrays from the target's actual runtime types.")]
+ private static void RunSimple(Context* context)
+ {
+ RuntimeType[] typeArguments = ReadTypeArguments(
+ GetTypeData(context->TypeArguments, context->GenericArgsNodeCount),
+ checked((int)context->GenericArgsCount));
+ object? result;
+ RuntimeType resultType;
+ switch (context->Kind)
+ {
+ case EvaluationKind.NewObjectNoConstructor:
+ resultType = ReadInstantiation(GetModule((nint)context->Assembly),
+ (int)context->MemberToken, typeArguments, allowUninstantiated: true);
+ if (resultType.ContainsGenericParameters)
+ {
+ throw new ArgumentException(SR.Argument_InvalidGenericArg);
+ }
+
+ ValidateConstructorType(resultType);
+ InitializeType(resultType);
+ PrepareResult(context, new QCallTypeHandle(ref resultType));
+ if (resultType.IsByRefLike)
+ {
+ return;
+ }
+
+ // Initialization is explicit: raw allocation must not initialize additional base types
+ // or substitute Nullable's underlying type.
+ result = resultType.IsAbstract ? null :
+ RuntimeTypeHandle.InternalAllocNoChecks(resultType.GetNativeTypeHandle().AsMethodTable());
+ GC.KeepAlive(resultType);
+ break;
+
+ case EvaluationKind.NewString:
+ result = context->EvaluationData is null || context->StringSize == 0
+ ? string.Empty
+ : new string((char*)context->EvaluationData, 0,
+ checked((int)(context->StringSize / sizeof(char))));
+ resultType = (RuntimeType)typeof(string);
+ PrepareResult(context, new QCallTypeHandle(ref resultType));
+ break;
+
+ case EvaluationKind.NewArray:
+ if (context->ArrayRank > 1)
+ {
+ throw new RankException(SR.Rank_MultiDimNotSupported);
+ }
+ if (typeArguments.Length != 1)
+ {
+ throw new ArgumentException(SR.Argument_InvalidGenericArg);
+ }
+
+ RuntimeType elementType = typeArguments[0];
+ CorElementType element = elementType.GetCorElementType();
+ if ((element < CorElementType.ELEMENT_TYPE_BOOLEAN || element > CorElementType.ELEMENT_TYPE_R8) &&
+ !IsObject(element))
+ {
+ throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_Enum);
+ }
+
+ // The debugger allocation protocol narrows the native-sized dimension to DWORD.
+ int length = unchecked((int)(uint)*(nuint*)context->EvaluationData);
+ if (length < 0)
+ {
+ throw new OverflowException();
+ }
+
+ result = Array.CreateInstance(elementType, length);
+ resultType = (RuntimeType)result.GetType();
+ PrepareResult(context, new QCallTypeHandle(ref resultType));
+ break;
+
+ default:
+ throw new UnreachableException();
+ }
+
+ context->ResultHandle = GCHandle.ToIntPtr(GCHandle.Alloc(result));
+ }
+
+ private static void ValidateConstructorType(RuntimeType type)
+ {
+ if (type.IsInterface)
+ {
+ throw new MemberAccessException(SR.Acc_CreateInterface);
+ }
+ if (type == typeof(string))
+ {
+ throw new ArgumentException(SR.Argument_NoUninitializedStrings);
+ }
+ }
+
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2059:UnrecognizedReflectionPattern",
+ Justification = "The debugger explicitly requests initialization of a runtime type from the target.")]
+ private static void InitializeType(RuntimeType type) =>
+ RuntimeHelpers.RunClassConstructor(type.TypeHandle);
+
+ [DebuggerHidden]
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
+ Justification = "The debugger supplies the MethodDef token and runtime generic arguments from the target's loaded metadata.")]
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern",
+ Justification = "The debugger supplies the target's actual runtime generic arguments.")]
+ private static MethodBase GetMethod(Context* context, RuntimeType[] typeArguments, out RuntimeType declaringType)
+ {
+ RuntimeModule module = GetModule((nint)context->Assembly);
+ MethodBase? method = module.ResolveMethod((int)context->MemberToken);
+ Debug.Assert(method is RuntimeMethodInfo or RuntimeConstructorInfo);
+ declaringType = RuntimeMethodHandle.GetDeclaringType((IRuntimeMethodInfo)method);
+ int classArgumentCount = declaringType.IsGenericType ? declaringType.GetGenericArguments().Length : 0;
+ int methodArgumentCount = method.IsGenericMethod ? method.GetGenericArguments().Length : 0;
+ if (classArgumentCount + methodArgumentCount != typeArguments.Length)
+ {
+ throw new TargetParameterCountException();
+ }
+
+ if (classArgumentCount != 0)
+ {
+ declaringType = (RuntimeType)declaringType.MakeGenericType(typeArguments[..classArgumentCount]);
+ }
+ if (methodArgumentCount != 0)
+ {
+ IRuntimeMethodInfo owner = (IRuntimeMethodInfo)method;
+ RuntimeType[] methodArguments = typeArguments[classArgumentCount..];
+ RuntimeMethodHandleInternal handle = RuntimeMethodHandle.GetStubIfNeeded(
+ IRuntimeMethodInfo.GetValue(owner), declaringType, methodArguments);
+ method = RuntimeType.GetMethodBase(declaringType, handle);
+ Debug.Assert(method is not null);
+ GC.KeepAlive(owner);
+ GC.KeepAlive(methodArguments);
+ }
+ else if (classArgumentCount != 0)
+ {
+ method = (MethodBase)declaringType.GetMemberWithSameMetadataDefinitionAs(method);
+ }
+ if (method.ContainsGenericParameters)
+ {
+ throw new ArgumentException(SR.Argument_InvalidGenericArg);
+ }
+
+ if (context->Kind == EvaluationKind.NewObject)
+ {
+ ValidateConstructorType(declaringType);
+ if (!method.IsConstructor)
+ {
+ throw new ArgumentException(SR.Arg_TargetMethodNotConstructor);
+ }
+ }
+
+ InitializeType(declaringType);
+ context->ParameterCount = (uint)method.GetParametersAsSpan().Length;
+ return method;
+ }
+
[DebuggerHidden]
private FunctionEvaluation(Context* context, void** storage)
{
@@ -159,14 +345,10 @@ private FunctionEvaluation(Context* context, void** storage)
// Resolve the target only after capturing values; resolution can run its class initializer.
CapturePrimitiveArguments();
- RuntimeType? declaringType = null;
- IRuntimeMethodInfo? methodOwner = null;
- GetMethod(context,
- ObjectHandleOnStack.Create(ref declaringType), ObjectHandleOnStack.Create(ref methodOwner));
- Debug.Assert(declaringType is not null);
- Debug.Assert(methodOwner is not null);
- MethodBase? method = RuntimeType.GetMethodBase(declaringType, methodOwner);
- Debug.Assert(method is RuntimeMethodInfo or RuntimeConstructorInfo);
+ RuntimeType[] typeArguments = ReadTypeArguments(
+ GetTypeData(context->TypeArguments, context->GenericArgsNodeCount),
+ checked((int)context->GenericArgsCount));
+ MethodBase method = GetMethod(context, typeArguments, out RuntimeType declaringType);
Debug.Assert(!IsNewObject() || method is RuntimeConstructorInfo);
Debug.Assert((ulong)context->ArgumentCount + (IsNewObject() ? 1UL : 0UL) ==
@@ -339,9 +521,8 @@ private void PrepareArgument(int index, RuntimeType type, bool isByRef)
{
if (!type.IsValueType && (isThis || !isByRef))
{
- RuntimeType? actualType = null;
- GetArgumentType(_context, (uint)index, ObjectHandleOnStack.Create(ref actualType));
- if (actualType is null || !actualType.IsValueType)
+ RuntimeType actualType = ReadTypeArguments(GetTypeData(input.TypeData, input.TypeNodeCount), 1)[0];
+ if (!actualType.IsValueType)
{
throw new ArgumentException(SR.Argument_BadObjRef);
}
@@ -782,18 +963,10 @@ private void WriteObjectArgument(int index, ref object? value)
Unsafe.As(ref destination) = value;
}
- [ErrorHandler(typeof(QCallExceptionStatusMarshaller), ErrorLocation.HiddenLastParameter)]
- [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_GetFuncEvalMethod")]
- private static partial void GetMethod(Context* context, ObjectHandleOnStack declaringType, ObjectHandleOnStack methodOwner);
-
[ErrorHandler(typeof(QCallExceptionStatusMarshaller), ErrorLocation.HiddenLastParameter)]
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_PrepareFuncEvalResult")]
private static partial void PrepareResult(Context* context, QCallTypeHandle resultType);
- [ErrorHandler(typeof(QCallExceptionStatusMarshaller), ErrorLocation.HiddenLastParameter)]
- [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_GetFuncEvalArgumentType")]
- private static partial void GetArgumentType(Context* context, uint index, ObjectHandleOnStack type);
-
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_ReadFuncEvalPrimitiveRegister")]
[SuppressGCTransition]
private static partial int ReadPrimitiveRegister(Context* context, uint index, out ulong value);
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
index 1a8f0941b39131..9bdb02e87ccc70 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
@@ -36,6 +36,18 @@ internal sealed partial class RuntimeAssembly : Assembly
internal IntPtr GetUnderlyingNativeHandle() => m_assembly;
+ internal static RuntimeAssembly GetAssemblyFromHandle(nint nativeAssembly)
+ {
+ RuntimeAssembly? assembly = null;
+ GetAssemblyFromHandle(nativeAssembly, ObjectHandleOnStack.Create(ref assembly));
+ Debug.Assert(assembly is not null);
+ return assembly;
+ }
+
+ [ErrorHandler(typeof(QCallExceptionStatusMarshaller), ErrorLocation.HiddenLastParameter)]
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetAssemblyFromHandle")]
+ private static partial void GetAssemblyFromHandle(nint nativeAssembly, ObjectHandleOnStack assembly);
+
private sealed class ManifestResourceStream : UnmanagedMemoryStream
{
// ensures the RuntimeAssembly is kept alive for as long as the stream lives
diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp
index 480312c1065a73..b3ce98c9358cec 100644
--- a/src/coreclr/debug/ee/debugger.cpp
+++ b/src/coreclr/debug/ee/debugger.cpp
@@ -11647,110 +11647,6 @@ HRESULT Debugger::BasicTypeInfoToTypeHandle(DebuggerIPCE_BasicTypeData *data, Ty
return S_OK;
}
-// Iterate through the type argument data, creating type handles as we go.
-void Debugger::TypeDataWalk::ReadTypeHandles(unsigned int nTypeArgs, TypeHandle *ppResults)
-{
- WRAPPER_NO_CONTRACT;
-
- for (unsigned int i = 0; i < nTypeArgs; i++)
- ppResults[i] = ReadTypeHandle();
- }
-
-TypeHandle Debugger::TypeDataWalk::ReadInstantiation(Module *pModule, mdTypeDef tok, unsigned int nTypeArgs)
-{
- WRAPPER_NO_CONTRACT;
-
- DWORD dwAllocSize;
- if (!ClrSafeInt::multiply(nTypeArgs, sizeof(TypeHandle), dwAllocSize))
- {
- ThrowHR(COR_E_OVERFLOW);
- }
- TypeHandle * inst = (TypeHandle *) _alloca(dwAllocSize);
- ReadTypeHandles(nTypeArgs, inst) ;
- TypeHandle th = g_pEEInterface->LoadInstantiation(pModule, tok, nTypeArgs, inst);
- if (th.IsNull())
- COMPlusThrow(kArgumentException, W("Argument_InvalidGenericArg"));
- return th;
-}
-
-TypeHandle Debugger::TypeDataWalk::ReadTypeHandle()
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- DebuggerIPCE_TypeArgData * data = ReadOne();
- if (!data)
- COMPlusThrow(kArgumentException, W("Argument_InvalidGenericArg"));
-
- LOG((LF_CORDB, LL_INFO10000,
- "D::ETITTH: expanding right-side type to left-side type, ELEMENT_TYPE: %d.\n",
- static_cast(data->data.elementType)));
-
- TypeHandle th;
- CorElementType et = data->data.elementType;
- switch (et)
- {
- case ELEMENT_TYPE_ARRAY:
- case ELEMENT_TYPE_SZARRAY:
- case ELEMENT_TYPE_PTR:
- case ELEMENT_TYPE_BYREF:
- if(data->numTypeArgs == (UINT)1)
- {
- TypeHandle typar = ReadTypeHandle();
- switch (et)
- {
- case ELEMENT_TYPE_ARRAY:
- case ELEMENT_TYPE_SZARRAY:
- th = g_pEEInterface->LoadArrayType(data->data.elementType, typar, data->data.ArrayTypeData.arrayRank);
- break;
- case ELEMENT_TYPE_PTR:
- case ELEMENT_TYPE_BYREF:
- th = g_pEEInterface->LoadPointerOrByrefType(data->data.elementType, typar);
- break;
- default:
- _ASSERTE(0);
- }
- }
- break;
-
- case ELEMENT_TYPE_CLASS:
- case ELEMENT_TYPE_VALUETYPE:
- {
- DebuggerModule *pDebuggerModule = g_pDebugger->LookupOrCreateModule(data->data.ClassTypeData.vmAssembly);
- th = ReadInstantiation(pDebuggerModule->GetRuntimeModule(), data->data.ClassTypeData.metadataToken, data->numTypeArgs);
- break;
- }
-
- case ELEMENT_TYPE_FNPTR:
- {
- SIZE_T cbAllocSize;
- if ((!ClrSafeInt::multiply(data->numTypeArgs, sizeof(TypeHandle), cbAllocSize)) ||
- (cbAllocSize != (size_t)(cbAllocSize)))
- {
- _ASSERTE(COR_E_OVERFLOW);
- cbAllocSize = UINT_MAX;
- }
- TypeHandle * inst = (TypeHandle *) _alloca(cbAllocSize);
- ReadTypeHandles(data->numTypeArgs, inst) ;
- th = g_pEEInterface->LoadFnptrType(inst, data->numTypeArgs);
- break;
- }
-
- default:
- th = g_pEEInterface->LoadElementType(data->data.elementType);
- break;
- }
- if (th.IsNull())
- COMPlusThrow(kArgumentNullException, W("ArgumentNull_Type"));
- return th;
-
-}
-
//
// GetAndSendTransitionStubInfo figures out if an address is a stub
// address and sends the result back to the right side.
diff --git a/src/coreclr/debug/ee/debugger.h b/src/coreclr/debug/ee/debugger.h
index 12bee567728d7f..eaf8ec3e060656 100644
--- a/src/coreclr/debug/ee/debugger.h
+++ b/src/coreclr/debug/ee/debugger.h
@@ -2136,30 +2136,6 @@ class Debugger : public DebugInterface
TypeHandle th,
DebuggerIPCE_ExpandedTypeData *res);
- class TypeDataWalk
- {
- DebuggerIPCE_TypeArgData *m_curdata;
- unsigned int m_remaining;
-
- public:
- TypeDataWalk(DebuggerIPCE_TypeArgData *pData, unsigned int nData)
- {
- m_curdata = pData;
- m_remaining = nData;
- }
-
-
- // These are for type arguments in the funceval case.
- // They throw COMPLUS exceptions if they fail, so can only be used during funceval.
- void ReadTypeHandles(unsigned int nTypeArgs, TypeHandle *pRes);
- TypeHandle ReadInstantiation(Module *pModule, mdTypeDef tok, unsigned int nTypeArgs);
- TypeHandle ReadTypeHandle();
-
- BOOL Finished() { LIMITED_METHOD_CONTRACT; return m_remaining == 0; }
- DebuggerIPCE_TypeArgData *ReadOne() { LIMITED_METHOD_CONTRACT; if (m_remaining) { m_remaining--; return m_curdata++; } else return NULL; }
-
- };
-
void GetAndSendTransitionStubInfo(CORDB_ADDRESS_TYPE *stubAddress);
void SendBreakpoint(Thread *thread, T_CONTEXT *context,
@@ -2541,11 +2517,8 @@ class Debugger : public DebugInterface
HRESULT FuncEvalCleanup(DebuggerEval *debuggerEvalKey);
#ifndef DACCESS_COMPILE
- virtual bool ReadFuncEvalTypeHandles(
- DebuggerEval* pDE, TypeHandle* pTypes, uint32_t count);
virtual void* AllocateFuncEvalExternalResult(DebuggerEval* pDE, TypeHandle resultType);
virtual void ProtectFuncEvalByRefResult(DebuggerEval* pDE, TypeHandle resultType);
- virtual TypeHandle GetFuncEvalArgumentType(DebuggerEval* pDE, UINT32 index);
virtual BOOL ReadFuncEvalPrimitiveRegister(
DebuggerEval* pDE, UINT32 index, UINT64* pValue);
virtual void WriteFuncEvalRegister(
@@ -3405,13 +3378,6 @@ class DebuggerEval
return (DebuggerIPCE_FuncEvalArgData*) (m_argData + m_genericArgsNodeCount * sizeof(DebuggerIPCE_TypeArgData));
}
- WCHAR *GetNewStringArgData()
- {
- LIMITED_METHOD_CONTRACT;
- _ASSERTE(m_evalType == DB_IPCE_FET_NEW_STRING);
- return (WCHAR*)m_argData;
- }
-
~DebuggerEval()
{
WRAPPER_NO_CONTRACT;
diff --git a/src/coreclr/debug/ee/funceval.cpp b/src/coreclr/debug/ee/funceval.cpp
index 40465cb6265f5b..d4265cbc44ee06 100644
--- a/src/coreclr/debug/ee/funceval.cpp
+++ b/src/coreclr/debug/ee/funceval.cpp
@@ -718,6 +718,8 @@ static void GCProtectAllPassedArgs(DebuggerEval *pDE,
DebuggerIPCE_FuncEvalArgData *pFEAD = &argData[currArgIndex];
DebuggerFuncEvalArgument* pArgument = &pArguments[currArgIndex];
pArgument->pLiteral = pFEAD->argLiteralData[0].GetNativeAddress();
+ pArgument->pTypeData = static_cast(CORDB_ADDRESS_TO_PTR(pFEAD->fullArgType));
+ pArgument->typeNodeCount = pFEAD->fullArgTypeNodeCount;
pArgument->elementType = pFEAD->argElementType;
pArgument->flags = (pFEAD->argIsLiteral ? FuncEvalLiteral : 0) |
(pFEAD->argIsHandleValue ? FuncEvalHandle : 0) |
@@ -1030,22 +1032,6 @@ static HRESULT ProtectFuncEvalArgumentStorage(
return S_OK;
}
-bool Debugger::ReadFuncEvalTypeHandles(DebuggerEval* pDE, TypeHandle* pTypes, uint32_t count)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- _ASSERTE(count == pDE->m_genericArgsCount);
- TypeDataWalk walk(pDE->GetTypeArgData(), pDE->m_genericArgsNodeCount);
- walk.ReadTypeHandles(count, pTypes);
- return walk.Finished();
-}
-
static BYTE* AllocateFuncEvalExternalResult(DebuggerEval* pDE)
{
CONTRACTL
@@ -1097,24 +1083,6 @@ void Debugger::ProtectFuncEvalByRefResult(DebuggerEval* pDE, TypeHandle resultTy
pDE->m_funcEvalResult = new (interopsafe) DebuggerFuncEvalResult(pDE, resultType);
}
-TypeHandle Debugger::GetFuncEvalArgumentType(DebuggerEval* pDE, UINT32 index)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- _ASSERTE(index < pDE->m_argCount);
- DebuggerIPCE_FuncEvalArgData* pArg = &pDE->GetArgData()[index];
- Debugger::TypeDataWalk walk(
- reinterpret_cast(CORDB_ADDRESS_TO_PTR(pArg->fullArgType)),
- pArg->fullArgTypeNodeCount);
- return walk.ReadTypeHandle();
-}
-
BOOL Debugger::ReadFuncEvalPrimitiveRegister(
DebuggerEval* pDE, UINT32 index, UINT64* pValue)
{
@@ -1154,46 +1122,6 @@ void Debugger::WriteFuncEvalRegister(
SetFuncEvalRegisterValue(pDE, &pDE->GetArgData()[index], pValue, size);
}
-/*
- * FuncEvalWrapper
- *
- * Helper function for func-eval. We have to split it out so that we can put a __try / __finally in to
- * notify on a Catch-Handler found.
- *
- * Parameters:
- * pContext - native roots and debugger state used by managed evaluation.
- * pCatcherStackAddr - stack address to report as the Catch Handler Found location.
- *
- * Returns:
- * None.
- *
- */
-void FuncEvalWrapper(UnmanagedCallersOnlyCaller* pCaller, DebuggerFuncEvalContext* pContext,
- BYTE* pCatcherStackAddr)
-{
- struct Param : NotifyOfCHFFilterWrapperParam
- {
- UnmanagedCallersOnlyCaller* pCaller;
- DebuggerFuncEvalContext* pContext;
- };
-
- Param param;
- param.pFrame = pCatcherStackAddr; // Inherited from NotifyOfCHFFilterWrapperParam
- param.pCaller = pCaller;
- param.pContext = pContext;
-
- PAL_TRY(Param *, pParam, ¶m)
- {
- pParam->pCaller->InvokeDirect(reinterpret_cast(pParam->pContext));
- }
- PAL_EXCEPT_FILTER(NotifyOfCHFFilterWrapper)
- {
- // Should never reach here b/c handler should always continue search.
- _ASSERTE(false);
- }
- PAL_ENDTRY
-}
-
/*
* RecordFuncEvalException
*
@@ -1353,7 +1281,7 @@ static void ValidateFuncEvalArgumentCount(DebuggerEval* pDE)
}
}
-static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext, BYTE* pCatcherStackAddr)
+static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext)
{
CONTRACTL
{
@@ -1363,14 +1291,17 @@ static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext, BYTE* pCatc
}
CONTRACTL_END;
- ValidateFuncEvalArgumentCount(pContext->pEval);
+ if (pContext->kind == DebuggerFuncEvalKind::Normal || pContext->kind == DebuggerFuncEvalKind::NewObject)
+ {
+ ValidateFuncEvalArgumentCount(pContext->pEval);
+ }
if (VolatileLoad(&g_pDebuggerInvokeFunctionMethodDesc) == nullptr)
{
VolatileStore(&g_pDebuggerInvokeFunctionMethodDesc, CoreLibBinder::GetMethod(METHOD__DEBUGGER__INVOKE_FUNCTION));
}
UnmanagedCallersOnlyCaller caller(METHOD__DEBUGGER__INVOKE_FUNCTION);
- FuncEvalWrapper(&caller, pContext, pCatcherStackAddr);
+ caller.InvokeDirect(reinterpret_cast(pContext));
{
DebuggerEval* pDE = pContext->pEval;
@@ -1381,8 +1312,7 @@ static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext, BYTE* pCatc
boxed ? Debugger::AllBoxed : Debugger::OnlyPrimitivesUnboxed;
if (pContext->resultHandle != nullptr)
{
- // The strong handle was created in managed code (Debugger.FunctionEvaluation.Invoke),
- // right after the call, while the result was still reachable as a tracked local/field.
+ // Managed evaluation created the strong handle while the result was still GC-tracked.
OBJECTHANDLE handle = static_cast(pContext->resultHandle);
pDE->m_result[0] = static_cast(reinterpret_cast(handle));
pDE->m_vmObjectHandle = VMPTR_OBJECTHANDLE::MakePtr(handle);
@@ -1399,14 +1329,12 @@ static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext, BYTE* pCatc
*
* Parameters:
* pDE - pointer to the DebuggerEval object being processed.
- * pCatcherStackAddr - stack address to report as the Catch Handler Found location.
*
* Returns:
* None. DebuggerEval owns any persistent raw-byref result root.
*
*/
-static void GCProtectArgsAndInvokeManagedFuncEval(DebuggerEval *pDE,
- BYTE *pCatcherStackAddr)
+static void GCProtectArgsAndInvokeManagedFuncEval(DebuggerEval *pDE)
{
CONTRACTL
{
@@ -1481,11 +1409,18 @@ static void GCProtectArgsAndInvokeManagedFuncEval(DebuggerEval *pDE,
context.pCapturedArguments = pBufferForArgsArray;
context.pResultByRefs = reinterpret_cast(pDE->m_result);
context.pResultData = pDE->m_result;
- context.pModule = pDE->m_debuggerModule->GetRuntimeModule();
+ context.pAssembly = pDE->m_pAssembly;
+ context.pTypeArguments = reinterpret_cast(pDE->GetTypeArgData());
+ context.pEvaluationData = pDE->m_argData == nullptr ? nullptr : pDE->GetArgData();
+ context.stringSize = pDE->m_stringSize;
+ context.arrayRank = pDE->m_arrayRank;
context.argumentCount = pDE->m_argCount;
- context.flags = pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT ? FuncEvalNewObject : 0;
- context.methodToken = pDE->m_methodToken;
+ context.flags = pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT || pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT_NC
+ ? FuncEvalNewObject : 0;
+ context.memberToken = pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT_NC ? pDE->m_classToken : pDE->m_methodToken;
context.genericArgsCount = pDE->m_genericArgsCount;
+ context.genericArgsNodeCount = pDE->m_genericArgsNodeCount;
+ context.kind = static_cast(pDE->m_evalType);
LifetimeHolder argumentHandles(pArgumentHandles);
LifetimeHolder temporaryResultHolder(&context);
@@ -1520,7 +1455,7 @@ static void GCProtectArgsAndInvokeManagedFuncEval(DebuggerEval *pDE,
}
IfFailThrow(captureResult);
- InvokeManagedFuncEval(&context, pCatcherStackAddr);
+ InvokeManagedFuncEval(&context);
}
EX_CATCH
{
@@ -1554,198 +1489,10 @@ static void GCProtectArgsAndInvokeManagedFuncEval(DebuggerEval *pDE,
}
-void FuncEvalHijackRealWorker(DebuggerEval *pDE, Thread* pThread, FuncEvalFrame* pFEFrame)
-{
- BYTE * pCatcherStackAddr = (BYTE*) pFEFrame;
-
- // Normal calls and constructors use the managed evaluator.
- // TODO-ManagedFuncEval: Move the other func eval types to the managed evaluator.
- if ((pDE->m_evalType == DB_IPCE_FET_NEW_OBJECT) || (pDE->m_evalType == DB_IPCE_FET_NORMAL))
- {
- GCProtectArgsAndInvokeManagedFuncEval(pDE, pCatcherStackAddr);
- return;
- }
-
- OBJECTREF newObj = NULL;
- GCPROTECT_BEGIN(newObj);
-
- // Wrap everything in a EX_TRY so we catch any exceptions that could be thrown.
- // Note that we don't let any thrown exceptions cross the AppDomain boundary because we don't
- // want them to get marshalled.
- EX_TRY
- {
- DebuggerIPCE_TypeArgData *firstdata = pDE->GetTypeArgData();
- DWORD nGenericArgs = pDE->m_genericArgsCount;
-
- SIZE_T cbAllocSize;
- if ((!ClrSafeInt::multiply(nGenericArgs, sizeof(TypeHandle *), cbAllocSize)) ||
- (cbAllocSize != (size_t)(cbAllocSize)))
- {
- ThrowHR(COR_E_OVERFLOW);
- }
- TypeHandle *pGenericArgs = (nGenericArgs == 0) ? NULL : (TypeHandle *) _alloca(cbAllocSize);
- //
- // Snag the type arguments from the input and get the
- // method desc that corresponds to the instantiated desc.
- //
- Debugger::TypeDataWalk walk(firstdata, pDE->m_genericArgsNodeCount);
- walk.ReadTypeHandles(nGenericArgs, pGenericArgs);
-
- // better error message
- if (!walk.Finished())
- COMPlusThrow(kArgumentException, W("Argument_InvalidGenericArg"));
-
- switch (pDE->m_evalType)
- {
- case DB_IPCE_FET_NEW_OBJECT_NC:
- {
-
- // Find the class.
- TypeHandle thClass = g_pEEInterface->LoadClass(pDE->m_debuggerModule->GetRuntimeModule(),
- pDE->m_classToken);
-
- if (thClass.IsNull())
- COMPlusThrow(kArgumentNullException, W("ArgumentNull_Type"));
-
- // Apply any type arguments
- TypeHandle th =
- (nGenericArgs == 0)
- ? thClass
- : g_pEEInterface->LoadInstantiation(pDE->m_debuggerModule->GetRuntimeModule(),
- pDE->m_classToken, nGenericArgs, pGenericArgs);
-
- if (th.IsNull() || th.ContainsGenericVariables())
- COMPlusThrow(kArgumentException, W("Argument_InvalidGenericArg"));
-
- ValidateFuncEvalConstructorType(th.GetMethodTable());
-
- // Run the Class Init for this type, if necessary.
- MethodTable * pOwningMT = th.GetMethodTable();
- pOwningMT->EnsureInstanceActive();
- pOwningMT->CheckRunClassInitThrowing();
-
- // Create a new instance of the class
-
- pDE->m_resultType = th;
- if (th.IsByRefLike())
- {
- AllocateFuncEvalExternalResult(pDE);
- pDE->m_retValueBoxing = Debugger::NoValueTypeBoxing;
- }
- else
- {
- newObj = pOwningMT->IsAbstract() ? NULL : AllocateObject(pOwningMT);
- pDE->m_retValueBoxing = Debugger::AllBoxed;
-
- OBJECTHANDLE oh = AppDomain::GetCurrentDomain()->CreateStrongHandle(newObj);
- pDE->m_result[0] = (ARG_SLOT)(LONG_PTR)oh;
- pDE->m_vmObjectHandle = VMPTR_OBJECTHANDLE::MakePtr(oh);
- }
-
- pDE->m_successful = true;
-
- break;
- }
-
- case DB_IPCE_FET_NEW_STRING:
- {
- // Create the string. m_argData is not necessarily null terminated...
- // The numeration parameter represents the string length, not the buffer size, but
- // we have passed the buffer size across to copy our data properly, so must divide back out.
- // NewString will return NULL if pass null, but want an empty string in that case, so
- // just create an EmptyString explicitly.
- if ((pDE->m_argData == NULL) || (pDE->m_stringSize == 0))
- {
- newObj = StringObject::GetEmptyString();
- }
- else
- {
- newObj = StringObject::NewString(pDE->GetNewStringArgData(), (int)(pDE->m_stringSize/sizeof(WCHAR)));
- }
-
- // No exception, so it worked.
- pDE->m_successful = true;
-
- // Result type is, of course, a string.
- pDE->m_resultType = newObj->GetTypeHandle();
-
- // Place the result in a strong handle to protect it from a collection.
- OBJECTHANDLE oh = AppDomain::GetCurrentDomain()->CreateStrongHandle(newObj);
- pDE->m_result[0] = (ARG_SLOT)(LONG_PTR)oh;
- pDE->m_vmObjectHandle = VMPTR_OBJECTHANDLE::MakePtr(oh);
-
- break;
- }
-
- case DB_IPCE_FET_NEW_ARRAY:
- {
- // @todo: We're only gonna handle SD arrays for right now.
- if (pDE->m_arrayRank > 1)
- COMPlusThrow(kRankException, W("Rank_MultiDimNotSupported"));
-
- // Grab the elementType from the arg/data area.
- _ASSERTE(nGenericArgs == 1);
- TypeHandle th = pGenericArgs[0];
-
- CorElementType et = th.GetSignatureCorElementType();
- // Gotta be a primitive, class, or System.Object.
- if (((et < ELEMENT_TYPE_BOOLEAN) || (et > ELEMENT_TYPE_R8)) &&
- !CorTypeInfo::IsObjRef_NoThrow(et))
- {
- COMPlusThrow(kArgumentOutOfRangeException, W("ArgumentOutOfRange_Enum"));
- }
-
- // Grab the dims from the arg/data area. These come after the type arguments.
- SIZE_T *dims;
- dims = (SIZE_T*) (firstdata + pDE->m_genericArgsNodeCount);
-
- if (CorTypeInfo::IsObjRef_NoThrow(et))
- {
- newObj = AllocateObjectArray((DWORD)dims[0], th);
- }
- else
- {
- // Create a simple array. Note: we can only do this type of create here due to the checks above.
- newObj = AllocatePrimitiveArray(et, (DWORD)dims[0]);
- }
-
- // No exception, so it worked.
- pDE->m_successful = true;
-
- // Result type is, of course, the type of the array.
- pDE->m_resultType = newObj->GetTypeHandle();
-
- // Place the result in a strong handle to protect it from a collection.
- OBJECTHANDLE oh = AppDomain::GetCurrentDomain()->CreateStrongHandle(newObj);
- pDE->m_result[0] = (ARG_SLOT)(LONG_PTR)oh;
- pDE->m_vmObjectHandle = VMPTR_OBJECTHANDLE::MakePtr(oh);
-
- break;
- }
-
- default:
- _ASSERTE(!"Invalid eval type!");
- }
- }
- EX_CATCH
- {
- // We got an exception. Make the exception into our result.
- OBJECTREF ppException = GET_THROWABLE();
- GCX_FORBID();
- RecordFuncEvalException( pDE, ppException);
- }
- // Note: we need to catch all exceptioins here because they all get reported as the result of
- // the funceval.
- EX_END_CATCH
-
- GCPROTECT_END();
-}
-
//
-// FuncEvalHijackWorker is the function that managed threads start executing in order to perform a function
-// evaluation. Control is transferred here on the proper thread by hijacking that that's IP to this method in
-// Debugger::FuncEvalSetup. This function can also be called directly by a Runtime thread that is stopped sending a
-// first or second chance exception to the Right Side.
+// Managed threads enter through the architecture-specific FuncEvalHijack stub, which calls this worker to
+// perform the evaluation. Debugger::FuncEvalSetup redirects the thread's IP to the stub. Runtime threads stopped
+// while reporting a first- or second-chance exception can also call this worker directly.
//
// The DebuggerEval object may get deleted by the helper thread doing a CleanupFuncEval while this thread is blocked
// sending the eval complete.
@@ -1830,7 +1577,7 @@ void * STDCALL FuncEvalHijackWorker(DebuggerEval *pDE)
pDE->m_thread->DisableSingleStep();
#endif
- FuncEvalHijackRealWorker(pDE, pThread, &FEFrame);
+ GCProtectArgsAndInvokeManagedFuncEval(pDE);
#ifdef FEATURE_EMULATE_SINGLESTEP
if (ssEnabled)
diff --git a/src/coreclr/vm/assemblynative.cpp b/src/coreclr/vm/assemblynative.cpp
index 8cbca636b7dc2b..5a2e5ea7518987 100644
--- a/src/coreclr/vm/assemblynative.cpp
+++ b/src/coreclr/vm/assemblynative.cpp
@@ -1134,6 +1134,20 @@ extern "C" void QCALLTYPE AssemblyNative_GetFullName(QCall::AssemblyHandle pAsse
END_QCALL;
}
+extern "C" void QCALLTYPE AssemblyNative_GetAssemblyFromHandle(Assembly* pAssembly, QCall::ObjectHandleOnStack retAssembly, QCallExceptionStatus* qcallError)
+{
+ QCALL_CONTRACT;
+
+ _ASSERTE(pAssembly != nullptr);
+
+ BEGIN_QCALL;
+
+ GCX_COOP();
+ retAssembly.Set(pAssembly->GetExposedObject());
+
+ END_QCALL;
+}
+
extern "C" void QCALLTYPE AssemblyNative_GetExecutingAssembly(QCall::StackCrawlMarkHandle stackMark, QCall::ObjectHandleOnStack retAssembly, QCallExceptionStatus* qcallError)
{
QCALL_CONTRACT;
diff --git a/src/coreclr/vm/assemblynative.hpp b/src/coreclr/vm/assemblynative.hpp
index 0b5698eaa880f3..50a8afe622b21e 100644
--- a/src/coreclr/vm/assemblynative.hpp
+++ b/src/coreclr/vm/assemblynative.hpp
@@ -37,6 +37,8 @@ extern "C" void QCALLTYPE AssemblyNative_GetEntryAssembly(QCall::ObjectHandleOnS
extern "C" void QCALLTYPE AssemblyNative_GetExecutingAssembly(QCall::StackCrawlMarkHandle stackMark, QCall::ObjectHandleOnStack retAssembly, QCallExceptionStatus* qcallError);
+extern "C" void QCALLTYPE AssemblyNative_GetAssemblyFromHandle(Assembly* pAssembly, QCall::ObjectHandleOnStack retAssembly, QCallExceptionStatus* qcallError);
+
extern "C" void QCALLTYPE AssemblyNative_GetLocale(QCall::AssemblyHandle pAssembly, QCall::StringHandleOnStack retString, QCallExceptionStatus* qcallError);
diff --git a/src/coreclr/vm/binder.cpp b/src/coreclr/vm/binder.cpp
index 5dae647034d595..fa3725e0eb3140 100644
--- a/src/coreclr/vm/binder.cpp
+++ b/src/coreclr/vm/binder.cpp
@@ -24,6 +24,10 @@
#include "interoplibinterface.h"
#include "assemblynative.hpp"
+#if defined(_DEBUG) && defined(DEBUGGING_SUPPORTED)
+#include "../debug/inc/dbgipcevents.h"
+#endif
+
//
// Retrieve structures from ID.
//
diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h
index ff3f49784035b8..7b604574ae15da 100644
--- a/src/coreclr/vm/corelib.h
+++ b/src/coreclr/vm/corelib.h
@@ -1007,20 +1007,72 @@ DEFINE_FIELD_U(TemporaryResultHandle, DebuggerFuncEvalContext, pTemporaryResult)
DEFINE_FIELD_U(ResultByRefs, DebuggerFuncEvalContext, pResultByRefs)
DEFINE_FIELD_U(ResultData, DebuggerFuncEvalContext, pResultData)
DEFINE_FIELD_U(ResultHandle, DebuggerFuncEvalContext, resultHandle)
-DEFINE_FIELD_U(Module, DebuggerFuncEvalContext, pModule)
+DEFINE_FIELD_U(Assembly, DebuggerFuncEvalContext, pAssembly)
+DEFINE_FIELD_U(TypeArguments, DebuggerFuncEvalContext, pTypeArguments)
+DEFINE_FIELD_U(EvaluationData, DebuggerFuncEvalContext, pEvaluationData)
+DEFINE_FIELD_U(StringSize, DebuggerFuncEvalContext, stringSize)
+DEFINE_FIELD_U(ArrayRank, DebuggerFuncEvalContext, arrayRank)
DEFINE_FIELD_U(ArgumentCount, DebuggerFuncEvalContext, argumentCount)
DEFINE_FIELD_U(ParameterCount, DebuggerFuncEvalContext, parameterCount)
DEFINE_FIELD_U(Flags, DebuggerFuncEvalContext, flags)
-DEFINE_FIELD_U(MethodToken, DebuggerFuncEvalContext, methodToken)
+DEFINE_FIELD_U(MemberToken, DebuggerFuncEvalContext, memberToken)
DEFINE_FIELD_U(GenericArgsCount, DebuggerFuncEvalContext, genericArgsCount)
+DEFINE_FIELD_U(GenericArgsNodeCount, DebuggerFuncEvalContext, genericArgsNodeCount)
+DEFINE_FIELD_U(Kind, DebuggerFuncEvalContext, kind)
DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeArgument, DebuggerFuncEvalArgument)
DEFINE_FIELD_U(Literal, DebuggerFuncEvalArgument, pLiteral)
+DEFINE_FIELD_U(TypeData, DebuggerFuncEvalArgument, pTypeData)
DEFINE_FIELD_U(ElementType, DebuggerFuncEvalArgument, elementType)
DEFINE_FIELD_U(Flags, DebuggerFuncEvalArgument, flags)
+DEFINE_FIELD_U(TypeNodeCount, DebuggerFuncEvalArgument, typeNodeCount)
+
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeTypeArgument, DebuggerIPCE_TypeArgData)
+DEFINE_FIELD_U(Data, DebuggerIPCE_TypeArgData, data)
+DEFINE_FIELD_U(ChildCount, DebuggerIPCE_TypeArgData, numTypeArgs)
+
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeExpandedTypeData, DebuggerIPCE_ExpandedTypeData)
+DEFINE_FIELD_U(ElementType, DebuggerIPCE_ExpandedTypeData, elementType)
+// The native union is anonymous; ArrayTypeData is its largest member.
+DEFINE_FIELD_U(TypeData, DebuggerIPCE_ExpandedTypeData, ArrayTypeData)
+
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeBasicTypeData, DebuggerIPCE_BasicTypeData)
+DEFINE_FIELD_U(ElementType, DebuggerIPCE_BasicTypeData, elementType)
+DEFINE_FIELD_U(MetadataToken, DebuggerIPCE_BasicTypeData, metadataToken)
+DEFINE_FIELD_U(Assembly, DebuggerIPCE_BasicTypeData, vmAssembly)
+DEFINE_FIELD_U(TypeHandle, DebuggerIPCE_BasicTypeData, vmTypeHandle)
+
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeClassTypeData, decltype(DebuggerIPCE_ExpandedTypeData::ClassTypeData))
+DEFINE_FIELD_U(MetadataToken, decltype(DebuggerIPCE_ExpandedTypeData::ClassTypeData), metadataToken)
+DEFINE_FIELD_U(Assembly, decltype(DebuggerIPCE_ExpandedTypeData::ClassTypeData), vmAssembly)
+DEFINE_FIELD_U(TypeHandle, decltype(DebuggerIPCE_ExpandedTypeData::ClassTypeData), typeHandle)
+
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeUnaryTypeData, decltype(DebuggerIPCE_ExpandedTypeData::UnaryTypeData))
+DEFINE_FIELD_U(UnaryTypeArgument, decltype(DebuggerIPCE_ExpandedTypeData::UnaryTypeData), unaryTypeArg)
+
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeArrayTypeData, decltype(DebuggerIPCE_ExpandedTypeData::ArrayTypeData))
+DEFINE_FIELD_U(ArrayTypeArgument, decltype(DebuggerIPCE_ExpandedTypeData::ArrayTypeData), arrayTypeArg)
+DEFINE_FIELD_U(ArrayRank, decltype(DebuggerIPCE_ExpandedTypeData::ArrayTypeData), arrayRank)
+
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeNaryTypeData, decltype(DebuggerIPCE_ExpandedTypeData::NaryTypeData))
+DEFINE_FIELD_U(TypeHandle, decltype(DebuggerIPCE_ExpandedTypeData::NaryTypeData), typeHandle)
END_ILLINK_FEATURE_SWITCH()
#endif // DEBUGGING_SUPPORTED
+#ifdef FOR_ILLINK
+// Preserve all wire-layout fields, including ignored slots, for parsing and native binder checks.
+BEGIN_ILLINK_FEATURE_SWITCH(System.Diagnostics.Debugger.IsSupported, true, true)
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeTypeArgument, DebuggerIPCE_TypeArgData)
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeExpandedTypeData, DebuggerIPCE_ExpandedTypeData)
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeTypeDataUnion, NoClass)
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeBasicTypeData, DebuggerIPCE_BasicTypeData)
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeClassTypeData, decltype(DebuggerIPCE_ExpandedTypeData::ClassTypeData))
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeUnaryTypeData, decltype(DebuggerIPCE_ExpandedTypeData::UnaryTypeData))
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeArrayTypeData, decltype(DebuggerIPCE_ExpandedTypeData::ArrayTypeData))
+DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeNaryTypeData, decltype(DebuggerIPCE_ExpandedTypeData::NaryTypeData))
+END_ILLINK_FEATURE_SWITCH()
+#endif // FOR_ILLINK
+
DEFINE_CLASS(BUFFER, System, Buffer)
DEFINE_METHOD(BUFFER, MEMCPY_PTRBYTE_ARRBYTE, Memcpy, SM_PtrByte_Int_ArrByte_Int_Int_RetVoid)
DEFINE_METHOD(BUFFER, MEMCPY, Memcpy, SM_PtrByte_PtrByte_Int_RetVoid)
diff --git a/src/coreclr/vm/dbginterface.h b/src/coreclr/vm/dbginterface.h
index 8aa82571c32e90..629b4fc9edc563 100644
--- a/src/coreclr/vm/dbginterface.h
+++ b/src/coreclr/vm/dbginterface.h
@@ -368,11 +368,8 @@ class DebugInterface
virtual void SendCreateThreadAtInterpreterEntry(Thread* pRuntimeThread) = 0;
- virtual bool ReadFuncEvalTypeHandles(
- DebuggerEval* pDE, TypeHandle* pTypes, uint32_t count) = 0;
virtual void* AllocateFuncEvalExternalResult(DebuggerEval* pDE, TypeHandle resultType) = 0;
virtual void ProtectFuncEvalByRefResult(DebuggerEval* pDE, TypeHandle resultType) = 0;
- virtual TypeHandle GetFuncEvalArgumentType(DebuggerEval* pDE, UINT32 index) = 0;
virtual BOOL ReadFuncEvalPrimitiveRegister(
DebuggerEval* pDE, UINT32 index, UINT64* pValue) = 0;
virtual void WriteFuncEvalRegister(
@@ -382,11 +379,4 @@ class DebugInterface
#endif //DACCESS_COMPILE
};
-#ifndef DACCESS_COMPILE
-// Helper to make GCC compile. GCC can't handle putting a virtual call in a filter.
-struct NotifyOfCHFFilterWrapperParam { void *pFrame; };
-LONG NotifyOfCHFFilterWrapper(EXCEPTION_POINTERS *pExceptionInfo, PVOID pNotifyOfCHFFilterWrapperParam);
-#endif
-
-
#endif // _dbgInterface_h_
diff --git a/src/coreclr/vm/debugdebugger.cpp b/src/coreclr/vm/debugdebugger.cpp
index 42a2d5ea9323d6..07b16f15366979 100644
--- a/src/coreclr/vm/debugdebugger.cpp
+++ b/src/coreclr/vm/debugdebugger.cpp
@@ -1011,119 +1011,7 @@ extern "C" BOOL QCALLTYPE DebugDebugger_IsManagedDebuggerAttached()
}
#ifdef DEBUGGING_SUPPORTED
-void ValidateFuncEvalConstructorType(MethodTable* pMT)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- // COMPAT: Abstract/static class construction forces class initialization and returns null.
- if (pMT->IsInterface())
- {
- COMPlusThrow(kMemberAccessException, W("Acc_CreateInterface"));
- }
- if (pMT == g_pStringClass)
- {
- COMPlusThrow(kArgumentException, W("Argument_CannotCreateString"));
- }
-}
-
-namespace
-{
- MethodDesc* ResolveFuncEvalMethod(DebuggerFuncEvalContext* pContext, TypeHandle& declaringType)
- {
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_PREEMPTIVE;
- }
- CONTRACTL_END;
-
- SIZE_T size;
- if (!ClrSafeInt::multiply(pContext->genericArgsCount, sizeof(TypeHandle), size))
- {
- ThrowHR(COR_E_OVERFLOW);
- }
- TypeHandle* types = size == 0 ? nullptr : static_cast(_alloca(size));
- if (!g_pDebugInterface->ReadFuncEvalTypeHandles(pContext->pEval, types, pContext->genericArgsCount))
- {
- COMPlusThrow(kArgumentException, W("Argument_InvalidGenericArg"));
- }
- MethodDesc* pMD = MemberLoader::GetMethodDescFromMethodDef(
- pContext->pModule, pContext->methodToken, FALSE);
- MethodTable* pMT = pMD->GetMethodTable();
-
- uint32_t classArgumentCount = pMT->GetInstantiation().GetNumArgs();
- uint32_t methodArgumentCount = pMD->GetMethodInstantiation().GetNumArgs();
- if (classArgumentCount + methodArgumentCount != pContext->genericArgsCount)
- {
- COMPlusThrowHR(COR_E_TARGETPARAMCOUNT);
- }
-
- if (classArgumentCount != 0)
- {
- pMT = ClassLoader::LoadGenericInstantiationThrowing(pContext->pModule, pMT->GetCl(), Instantiation(types, classArgumentCount)).AsMethodTable();
- }
-
- if (classArgumentCount != 0 || methodArgumentCount != 0)
- {
- pMD = MethodDesc::FindOrCreateAssociatedMethodDesc(pMD, pMT,
- FALSE, /* forceBoxedEntryPoint */
- Instantiation(types + classArgumentCount, methodArgumentCount),
- FALSE /* allowInstParam */);
- }
- // Shared method descriptors can have canonical method tables.
- declaringType = TypeHandle(pMT);
-
- bool isNewObject = (pContext->flags & FuncEvalNewObject) != 0;
- if (isNewObject)
- {
- ValidateFuncEvalConstructorType(pMD->GetMethodTable());
- if (!pMD->IsCtor())
- {
- COMPlusThrow(kArgumentException, W("Arg_TargetMethodNotConstructor"));
- }
- }
- pMD->EnsureActive();
- pMT->EnsureInstanceActive();
- pMT->CheckRunClassInitThrowing();
- return pMD;
- }
-}
-
// Function evaluation entrypoints require an active debugger-owned evaluation.
-extern "C" void QCALLTYPE DebugDebugger_GetFuncEvalMethod(
- DebuggerFuncEvalContext* pContext,
- QCall::ObjectHandleOnStack declaringType, QCall::ObjectHandleOnStack methodOwner,
- QCallExceptionStatus* qcallError)
-{
- QCALL_CONTRACT;
- BEGIN_QCALL;
- _ASSERTE(g_pDebugInterface != nullptr);
- TypeHandle ownerType;
- MethodDesc* method = ResolveFuncEvalMethod(pContext, ownerType);
- MetaSig sig(method);
- if (!isCallConv(sig.GetCallingConvention(), IMAGE_CEE_CS_CALLCONV_DEFAULT))
- {
- COMPlusThrow(kArgumentException, W("Argument_CORDBBadVarArgCallConv"));
- }
- pContext->parameterCount = sig.NumFixedArgs();
- {
- GCX_COOP();
- OBJECTREF loaderAllocator = method->GetLoaderAllocator()->GetExposedObject();
- GCPROTECT_BEGIN(loaderAllocator);
- methodOwner.Set(method->AllocateStubMethodInfo());
- declaringType.Set(ownerType.GetManagedClassObject());
- GCPROTECT_END();
- }
- END_QCALL;
-}
-
extern "C" void QCALLTYPE DebugDebugger_PrepareFuncEvalResult(
DebuggerFuncEvalContext* pContext, QCall::TypeHandle type,
QCallExceptionStatus* qcallError)
@@ -1145,9 +1033,12 @@ extern "C" void QCALLTYPE DebugDebugger_PrepareFuncEvalResult(
pContext->flags |= FuncEvalExternalResult;
}
}
- else if (resultType.GetSignatureCorElementType() == ELEMENT_TYPE_VALUETYPE ||
- ((pContext->flags & FuncEvalNewObject) != 0 && resultType.IsValueType()))
+ else if (pContext->kind != DebuggerFuncEvalKind::NewObjectNoConstructor &&
+ (resultType.GetSignatureCorElementType() == ELEMENT_TYPE_VALUETYPE ||
+ ((pContext->flags & FuncEvalNewObject) != 0 && resultType.IsValueType())))
{
+ // No-constructor value types are allocated as objects directly, preserving true Nullable boxes.
+ // This scratch space is only needed for invocation results that are boxed afterward.
MethodTable* pMT = resultType.GetMethodTable();
pMT->EnsureInstanceActive();
SIZE_T size = pMT->GetNumInstanceFieldBytes();
@@ -1166,25 +1057,6 @@ extern "C" void QCALLTYPE DebugDebugger_PrepareFuncEvalResult(
END_QCALL;
}
-extern "C" void QCALLTYPE DebugDebugger_GetFuncEvalArgumentType(
- DebuggerFuncEvalContext* pContext, UINT32 index, QCall::ObjectHandleOnStack type,
- QCallExceptionStatus* qcallError)
-{
- QCALL_CONTRACT;
- BEGIN_QCALL;
- _ASSERTE(g_pDebugInterface != nullptr);
- TypeHandle th = g_pDebugInterface->GetFuncEvalArgumentType(pContext->pEval, index);
- if (th.IsNull())
- {
- COMPlusThrow(kArgumentException, W("Argument_BadObjRef"));
- }
- {
- GCX_COOP();
- type.Set(th.GetManagedClassObject());
- }
- END_QCALL;
-}
-
extern "C" BOOL QCALLTYPE DebugDebugger_ReadFuncEvalPrimitiveRegister(
DebuggerFuncEvalContext* pContext, UINT32 index, UINT64* pValue)
{
diff --git a/src/coreclr/vm/debugdebugger.h b/src/coreclr/vm/debugdebugger.h
index d01f1ba0035d44..3f1f41d656628d 100644
--- a/src/coreclr/vm/debugdebugger.h
+++ b/src/coreclr/vm/debugdebugger.h
@@ -25,9 +25,19 @@ class DebuggerEval;
class ExternalMemoryHandle;
struct DebuggerFuncEvalArgument;
-void ValidateFuncEvalConstructorType(MethodTable* pMT);
HRESULT ValidateObject(Object* objPtr);
+// Values must match DebuggerIPCE_FuncEvalType (DB_IPCE_FET_*) and
+// Debugger.FunctionEvaluation.EvaluationKind in CoreLib.
+enum class DebuggerFuncEvalKind : UINT32
+{
+ Normal,
+ NewObject,
+ NewObjectNoConstructor,
+ NewString,
+ NewArray,
+};
+
struct DebuggerFuncEvalCapturedArgument
{
#if BIGENDIAN
@@ -61,12 +71,18 @@ struct DebuggerFuncEvalContext
void** pResultByRefs;
void* pResultData;
void* resultHandle;
- Module* pModule;
+ Assembly* pAssembly;
+ BYTE* pTypeArguments;
+ void* pEvaluationData;
+ SIZE_T stringSize;
+ SIZE_T arrayRank;
UINT32 argumentCount;
UINT32 parameterCount;
UINT32 flags;
- mdMethodDef methodToken;
+ mdToken memberToken;
uint32_t genericArgsCount;
+ uint32_t genericArgsNodeCount;
+ DebuggerFuncEvalKind kind;
};
enum DebuggerFuncEvalFlags
@@ -79,8 +95,10 @@ enum DebuggerFuncEvalFlags
struct DebuggerFuncEvalArgument
{
BYTE* pLiteral;
+ BYTE* pTypeData;
UINT32 elementType;
UINT32 flags;
+ UINT32 typeNodeCount;
};
enum DebuggerFuncEvalArgumentFlags
@@ -91,15 +109,9 @@ enum DebuggerFuncEvalArgumentFlags
FuncEvalRegister = 8,
};
-extern "C" void QCALLTYPE DebugDebugger_GetFuncEvalMethod(
- DebuggerFuncEvalContext* pContext,
- QCall::ObjectHandleOnStack declaringType, QCall::ObjectHandleOnStack methodOwner,
- QCallExceptionStatus* qcallError);
extern "C" void QCALLTYPE DebugDebugger_PrepareFuncEvalResult(
DebuggerFuncEvalContext* pContext, QCall::TypeHandle resultType,
QCallExceptionStatus* qcallError);
-extern "C" void QCALLTYPE DebugDebugger_GetFuncEvalArgumentType(
- DebuggerFuncEvalContext* pContext, UINT32 index, QCall::ObjectHandleOnStack type, QCallExceptionStatus* qcallError);
extern "C" BOOL QCALLTYPE DebugDebugger_ReadFuncEvalPrimitiveRegister(
DebuggerFuncEvalContext* pContext, UINT32 index, UINT64* pValue);
extern "C" void QCALLTYPE DebugDebugger_WriteFuncEvalObjectRegister(
diff --git a/src/coreclr/vm/eedbginterface.h b/src/coreclr/vm/eedbginterface.h
index c157e3b5b9bca8..f15500c285c909 100644
--- a/src/coreclr/vm/eedbginterface.h
+++ b/src/coreclr/vm/eedbginterface.h
@@ -201,28 +201,6 @@ class EEDebugInterface
TypeHandle elemtype,
unsigned rank) = 0;
- // These will lookup a type, and if it's not loaded, will load and run
- // the class init etc.
- virtual TypeHandle LoadClass(Module *pModule,
- mdTypeDef classToken) = 0;
-
- virtual TypeHandle LoadElementType(CorElementType et) = 0;
-
- virtual TypeHandle LoadInstantiation(Module *pModule,
- mdTypeDef typeDef,
- DWORD ntypars,
- TypeHandle *inst) = 0;
-
- virtual TypeHandle LoadFnptrType(TypeHandle *inst,
- DWORD ntypars) = 0;
-
- virtual TypeHandle LoadPointerOrByrefType(CorElementType et,
- TypeHandle elemtype) = 0;
-
- virtual TypeHandle LoadArrayType(CorElementType et,
- TypeHandle elemtype,
- unsigned rank) = 0;
-
__checkReturn
virtual HRESULT GetMethodImplProps(Module *pModule,
mdToken tk,
diff --git a/src/coreclr/vm/eedbginterfaceimpl.cpp b/src/coreclr/vm/eedbginterfaceimpl.cpp
index 45e25100fd75cd..61f41b31466c38 100644
--- a/src/coreclr/vm/eedbginterfaceimpl.cpp
+++ b/src/coreclr/vm/eedbginterfaceimpl.cpp
@@ -732,109 +732,6 @@ TypeHandle EEDbgInterfaceImpl::FindLoadedElementType(CorElementType et)
return TypeHandle(m);
}
-TypeHandle EEDbgInterfaceImpl::LoadClass(Module *pModule,
- mdTypeDef classToken)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- PRECONDITION(CheckPointer(pModule));
- }
- CONTRACTL_END;
-
- return ClassLoader::LoadTypeDefOrRefThrowing(pModule, classToken,
- ClassLoader::ThrowIfNotFound,
- ClassLoader::PermitUninstDefOrRef);
-
-}
-
-TypeHandle EEDbgInterfaceImpl::LoadInstantiation(Module *pModule,
- mdTypeDef typeDef,
- DWORD ntypars,
- TypeHandle *inst)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- PRECONDITION(CheckPointer(pModule));
- }
- CONTRACTL_END;
-
- return ClassLoader::LoadGenericInstantiationThrowing(pModule, typeDef, Instantiation(inst, ntypars));
-}
-
-TypeHandle EEDbgInterfaceImpl::LoadArrayType(CorElementType et,
- TypeHandle elemtype,
- unsigned rank)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- if (elemtype.IsNull())
- return TypeHandle();
- else
- return ClassLoader::LoadArrayTypeThrowing(elemtype, et, rank);
-}
-
-TypeHandle EEDbgInterfaceImpl::LoadPointerOrByrefType(CorElementType et,
- TypeHandle elemtype)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- return ClassLoader::LoadPointerOrByrefTypeThrowing(et, elemtype);
-}
-
-TypeHandle EEDbgInterfaceImpl::LoadFnptrType(TypeHandle *inst,
- DWORD ntypars)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- /* @TODO : CALLCONV? */
- return ClassLoader::LoadFnptrTypeThrowing(0, ntypars, inst);
-}
-
-TypeHandle EEDbgInterfaceImpl::LoadElementType(CorElementType et)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- MethodTable *m = CoreLibBinder::GetElementType(et);
-
- if (m == NULL)
- {
- return TypeHandle();
- }
-
- return TypeHandle(m);
-}
-
-
HRESULT EEDbgInterfaceImpl::GetMethodImplProps(Module *pModule,
mdToken tk,
DWORD *pRVA,
diff --git a/src/coreclr/vm/eedbginterfaceimpl.h b/src/coreclr/vm/eedbginterfaceimpl.h
index 3f3d4a6275bb6c..edbfe15e04a264 100644
--- a/src/coreclr/vm/eedbginterfaceimpl.h
+++ b/src/coreclr/vm/eedbginterfaceimpl.h
@@ -168,26 +168,6 @@ class EEDbgInterfaceImpl : public EEDebugInterface
TypeHandle FindLoadedElementType(CorElementType et);
- TypeHandle LoadClass(Module *pModule,
- mdTypeDef classToken);
-
- TypeHandle LoadInstantiation(Module *pModule,
- mdTypeDef typeDef,
- DWORD numGenericArgs,
- TypeHandle *pGenericArgs);
-
- TypeHandle LoadArrayType(CorElementType et,
- TypeHandle elemtype,
- unsigned rank);
-
- TypeHandle LoadPointerOrByrefType(CorElementType et,
- TypeHandle elemtype);
-
- TypeHandle LoadFnptrType(TypeHandle *inst,
- DWORD ntypars);
-
- TypeHandle LoadElementType(CorElementType et);
-
__checkReturn
HRESULT GetMethodImplProps(Module *pModule,
mdToken tk,
diff --git a/src/coreclr/vm/excep.h b/src/coreclr/vm/excep.h
index fc571d12b7751d..6ee29782689dcf 100644
--- a/src/coreclr/vm/excep.h
+++ b/src/coreclr/vm/excep.h
@@ -165,6 +165,11 @@ void CrashDumpAndTerminateProcess(UINT exitCode);
LONG ThreadBaseExceptionAppDomainFilter(PEXCEPTION_POINTERS pExceptionInfo, PVOID pvParam);
+#ifndef DACCESS_COMPILE
+struct NotifyOfCHFFilterWrapperParam { void *pFrame; };
+LONG NotifyOfCHFFilterWrapper(EXCEPTION_POINTERS *pExceptionInfo, PVOID pNotifyOfCHFFilterWrapperParam);
+#endif // !DACCESS_COMPILE
+
void STDMETHODCALLTYPE DefaultCatchHandler(PEXCEPTION_POINTERS pExceptionInfo,
OBJECTREF *Throwable = NULL,
BOOL useLastThrownObject = FALSE,
diff --git a/src/coreclr/vm/runtimehelpers.cpp b/src/coreclr/vm/runtimehelpers.cpp
index 4592a31de4c6e4..92044cd06a678d 100644
--- a/src/coreclr/vm/runtimehelpers.cpp
+++ b/src/coreclr/vm/runtimehelpers.cpp
@@ -117,6 +117,7 @@ static const Entry s_RuntimeHelpers[] =
DllImportEntry(AssemblyName_InitializeAssemblySpec)
DllImportEntry(AssemblyNative_ApplyUpdate)
DllImportEntry(AssemblyNative_GetAssemblyCount)
+ DllImportEntry(AssemblyNative_GetAssemblyFromHandle)
DllImportEntry(AssemblyNative_GetCodeBase)
DllImportEntry(AssemblyNative_GetEntryAssembly)
DllImportEntry(AssemblyNative_GetEntryPoint)
@@ -177,10 +178,6 @@ static const Entry s_RuntimeHelpers[] =
DllImportEntry(CustomAttribute_ParseAttributeUsageAttribute)
DllImportEntry(DebugDebugger_Break)
DllImportEntry(DebugDebugger_CustomNotification)
-#if defined(DEBUGGING_SUPPORTED)
- DllImportEntry(DebugDebugger_GetFuncEvalArgumentType)
- DllImportEntry(DebugDebugger_GetFuncEvalMethod)
-#endif // DEBUGGING_SUPPORTED
DllImportEntry(DebugDebugger_IsLoggingHelper)
DllImportEntry(DebugDebugger_IsManagedDebuggerAttached)
DllImportEntry(DebugDebugger_Launch)
diff --git a/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp b/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp
index a898f38d71dab6..2e979b25c7bf0c 100644
--- a/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp
+++ b/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp
@@ -343,6 +343,7 @@ extern "C" {
int32_t RuntimeHelper_AssemblyLoadContext_IsTracingEnabled (uintptr_t, uintptr_t) __asm__("AssemblyLoadContext_IsTracingEnabled");
void RuntimeHelper_AssemblyName_InitializeAssemblySpec (void *, void *, void *) __asm__("AssemblyName_InitializeAssemblySpec");
void RuntimeHelper_AssemblyNative_ApplyUpdate (void *, void *, int32_t, void *, int32_t, void *, int32_t, void *) __asm__("AssemblyNative_ApplyUpdate");
+ void RuntimeHelper_AssemblyNative_GetAssemblyFromHandle (void *, void *, void *) __asm__("AssemblyNative_GetAssemblyFromHandle");
int32_t RuntimeHelper_AssemblyNative_GetCodeBase (void *, void *, void *) __asm__("AssemblyNative_GetCodeBase");
void RuntimeHelper_AssemblyNative_GetEntryAssembly (void *, void *) __asm__("AssemblyNative_GetEntryAssembly");
void RuntimeHelper_AssemblyNative_GetEntryPoint (void *, void *, void *) __asm__("AssemblyNative_GetEntryPoint");
@@ -385,8 +386,6 @@ extern "C" {
int32_t RuntimeHelper_CustomAttribute_ParseAttributeUsageAttribute (void *, int32_t, void *, void *, void *) __asm__("CustomAttribute_ParseAttributeUsageAttribute");
void RuntimeHelper_DebugDebugger_Break (void *) __asm__("DebugDebugger_Break");
void RuntimeHelper_DebugDebugger_CustomNotification (void *, void *) __asm__("DebugDebugger_CustomNotification");
- void RuntimeHelper_DebugDebugger_GetFuncEvalArgumentType (void *, uint32_t, void *, void *) __asm__("DebugDebugger_GetFuncEvalArgumentType");
- void RuntimeHelper_DebugDebugger_GetFuncEvalMethod (void *, void *, void *, void *) __asm__("DebugDebugger_GetFuncEvalMethod");
int32_t RuntimeHelper_DebugDebugger_IsLoggingHelper () __asm__("DebugDebugger_IsLoggingHelper");
int32_t RuntimeHelper_DebugDebugger_IsManagedDebuggerAttached () __asm__("DebugDebugger_IsManagedDebuggerAttached");
int32_t RuntimeHelper_DebugDebugger_Launch () __asm__("DebugDebugger_Launch");
@@ -850,6 +849,7 @@ static const Entry s_RuntimeHelpers[] = {
{ "AssemblyLoadContext_IsTracingEnabled", (void*)&RuntimeHelper_AssemblyLoadContext_IsTracingEnabled },
{ "AssemblyName_InitializeAssemblySpec", (void*)&RuntimeHelper_AssemblyName_InitializeAssemblySpec },
{ "AssemblyNative_ApplyUpdate", (void*)&RuntimeHelper_AssemblyNative_ApplyUpdate },
+ { "AssemblyNative_GetAssemblyFromHandle", (void*)&RuntimeHelper_AssemblyNative_GetAssemblyFromHandle },
{ "AssemblyNative_GetCodeBase", (void*)&RuntimeHelper_AssemblyNative_GetCodeBase },
{ "AssemblyNative_GetEntryAssembly", (void*)&RuntimeHelper_AssemblyNative_GetEntryAssembly },
{ "AssemblyNative_GetEntryPoint", (void*)&RuntimeHelper_AssemblyNative_GetEntryPoint },
@@ -892,8 +892,6 @@ static const Entry s_RuntimeHelpers[] = {
{ "CustomAttribute_ParseAttributeUsageAttribute", (void*)&RuntimeHelper_CustomAttribute_ParseAttributeUsageAttribute },
{ "DebugDebugger_Break", (void*)&RuntimeHelper_DebugDebugger_Break },
{ "DebugDebugger_CustomNotification", (void*)&RuntimeHelper_DebugDebugger_CustomNotification },
- { "DebugDebugger_GetFuncEvalArgumentType", (void*)&RuntimeHelper_DebugDebugger_GetFuncEvalArgumentType },
- { "DebugDebugger_GetFuncEvalMethod", (void*)&RuntimeHelper_DebugDebugger_GetFuncEvalMethod },
{ "DebugDebugger_IsLoggingHelper", (void*)&RuntimeHelper_DebugDebugger_IsLoggingHelper },
{ "DebugDebugger_IsManagedDebuggerAttached", (void*)&RuntimeHelper_DebugDebugger_IsManagedDebuggerAttached },
{ "DebugDebugger_Launch", (void*)&RuntimeHelper_DebugDebugger_Launch },
diff --git a/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp b/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp
index e585ec7cf5f4d4..3dd3f101a319ea 100644
--- a/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp
+++ b/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp
@@ -622,6 +622,7 @@ extern "C" {
void RuntimeHelper_AssemblyName_InitializeAssemblySpec (void *, void *, void *) __asm__("AssemblyName_InitializeAssemblySpec");
void RuntimeHelper_AssemblyNative_ApplyUpdate (void *, void *, int32_t, void *, int32_t, void *, int32_t, void *) __asm__("AssemblyNative_ApplyUpdate");
uint32_t RuntimeHelper_AssemblyNative_GetAssemblyCount () __asm__("AssemblyNative_GetAssemblyCount");
+ void RuntimeHelper_AssemblyNative_GetAssemblyFromHandle (void *, void *, void *) __asm__("AssemblyNative_GetAssemblyFromHandle");
int32_t RuntimeHelper_AssemblyNative_GetCodeBase (void *, void *, void *) __asm__("AssemblyNative_GetCodeBase");
void RuntimeHelper_AssemblyNative_GetEntryAssembly (void *, void *) __asm__("AssemblyNative_GetEntryAssembly");
void RuntimeHelper_AssemblyNative_GetEntryPoint (void *, void *, void *) __asm__("AssemblyNative_GetEntryPoint");
@@ -665,8 +666,6 @@ extern "C" {
int32_t RuntimeHelper_CustomAttribute_ParseAttributeUsageAttribute (void *, int32_t, void *, void *, void *) __asm__("CustomAttribute_ParseAttributeUsageAttribute");
void RuntimeHelper_DebugDebugger_Break (void *) __asm__("DebugDebugger_Break");
void RuntimeHelper_DebugDebugger_CustomNotification (void *, void *) __asm__("DebugDebugger_CustomNotification");
- void RuntimeHelper_DebugDebugger_GetFuncEvalArgumentType (void *, uint32_t, void *, void *) __asm__("DebugDebugger_GetFuncEvalArgumentType");
- void RuntimeHelper_DebugDebugger_GetFuncEvalMethod (void *, void *, void *, void *) __asm__("DebugDebugger_GetFuncEvalMethod");
int32_t RuntimeHelper_DebugDebugger_IsLoggingHelper () __asm__("DebugDebugger_IsLoggingHelper");
int32_t RuntimeHelper_DebugDebugger_IsManagedDebuggerAttached () __asm__("DebugDebugger_IsManagedDebuggerAttached");
int32_t RuntimeHelper_DebugDebugger_Launch () __asm__("DebugDebugger_Launch");
@@ -1131,6 +1130,7 @@ static const Entry s_RuntimeHelpers[] = {
{ "AssemblyName_InitializeAssemblySpec", (void*)&RuntimeHelper_AssemblyName_InitializeAssemblySpec },
{ "AssemblyNative_ApplyUpdate", (void*)&RuntimeHelper_AssemblyNative_ApplyUpdate },
{ "AssemblyNative_GetAssemblyCount", (void*)&RuntimeHelper_AssemblyNative_GetAssemblyCount },
+ { "AssemblyNative_GetAssemblyFromHandle", (void*)&RuntimeHelper_AssemblyNative_GetAssemblyFromHandle },
{ "AssemblyNative_GetCodeBase", (void*)&RuntimeHelper_AssemblyNative_GetCodeBase },
{ "AssemblyNative_GetEntryAssembly", (void*)&RuntimeHelper_AssemblyNative_GetEntryAssembly },
{ "AssemblyNative_GetEntryPoint", (void*)&RuntimeHelper_AssemblyNative_GetEntryPoint },
@@ -1174,8 +1174,6 @@ static const Entry s_RuntimeHelpers[] = {
{ "CustomAttribute_ParseAttributeUsageAttribute", (void*)&RuntimeHelper_CustomAttribute_ParseAttributeUsageAttribute },
{ "DebugDebugger_Break", (void*)&RuntimeHelper_DebugDebugger_Break },
{ "DebugDebugger_CustomNotification", (void*)&RuntimeHelper_DebugDebugger_CustomNotification },
- { "DebugDebugger_GetFuncEvalArgumentType", (void*)&RuntimeHelper_DebugDebugger_GetFuncEvalArgumentType },
- { "DebugDebugger_GetFuncEvalMethod", (void*)&RuntimeHelper_DebugDebugger_GetFuncEvalMethod },
{ "DebugDebugger_IsLoggingHelper", (void*)&RuntimeHelper_DebugDebugger_IsLoggingHelper },
{ "DebugDebugger_IsManagedDebuggerAttached", (void*)&RuntimeHelper_DebugDebugger_IsManagedDebuggerAttached },
{ "DebugDebugger_Launch", (void*)&RuntimeHelper_DebugDebugger_Launch },