From 8ee2fd5303f4962def3c7a439913f84112c6ce65 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 4 Nov 2026 11:33:14 -0800 Subject: [PATCH 1/3] Move debugger func-eval allocation and resolution into managed code Decode debugger type arguments and resolve normal/constructor targets through CoreLib reflection. Move simple allocations to managed code, remove superseded EE loading APIs and debugger-specific resolution QCalls, and retain native GC, result ownership, exception and abort handling. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../System.Private.CoreLib.csproj | 1 + ...ebugger.FunctionEvaluation.TypeDataWalk.cs | 210 +++++++++++++++ .../Debugger.FunctionEvaluation.cs | 213 +++++++++++++-- .../src/System/Reflection/RuntimeAssembly.cs | 12 + src/coreclr/debug/ee/debugger.cpp | 104 ------- src/coreclr/debug/ee/debugger.h | 34 --- src/coreclr/debug/ee/funceval.cpp | 253 ++---------------- src/coreclr/vm/assemblynative.cpp | 14 + src/coreclr/vm/assemblynative.hpp | 2 + src/coreclr/vm/binder.cpp | 4 + src/coreclr/vm/corelib.h | 24 +- src/coreclr/vm/dbginterface.h | 3 - src/coreclr/vm/debugdebugger.cpp | 136 +--------- src/coreclr/vm/debugdebugger.h | 30 ++- src/coreclr/vm/eedbginterface.h | 22 -- src/coreclr/vm/eedbginterfaceimpl.cpp | 103 ------- src/coreclr/vm/eedbginterfaceimpl.h | 20 -- src/coreclr/vm/qcallentrypoints.cpp | 3 +- .../vm/wasm/browser/callhelpers-pinvoke.cpp | 6 +- .../vm/wasm/wasi/callhelpers-pinvoke.cpp | 6 +- 20 files changed, 507 insertions(+), 693 deletions(-) create mode 100644 src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.TypeDataWalk.cs diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 2d673111b28967..099763e70b13f7 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..fd4b900f92b119 --- /dev/null +++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.FunctionEvaluation.TypeDataWalk.cs @@ -0,0 +1,210 @@ +// 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 using the reader's size and offsets. + private const int TypeArgumentDataSize = 48; + private const int TypeArgumentElementTypeOffset = 0; + private const int TypeArgumentTokenOffset = 8; + private const int TypeArgumentAssemblyOffset = 16; + private const int TypeArgumentArrayRankOffset = 32; + private const int TypeArgumentChildCountOffset = 40; + + // Preserve the unused slots in the flattened native union, including padding on 32-bit targets. + [StructLayout(LayoutKind.Sequential)] + internal struct NativeTypeArgument + { + internal uint ElementType; + internal uint ElementTypePadding; + internal uint MetadataToken; + internal uint MetadataTokenPadding; + internal ulong Assembly; + internal ulong TypeHandle; + internal uint ArrayRank; + internal uint ArrayRankPadding; + internal uint ChildCount; + internal uint ChildCountPadding; + } + + [DebuggerHidden] + internal static RuntimeType[] ReadTypeArguments(ReadOnlySpan typeData, int count) + { + TypeDataWalk walk = new(typeData); + RuntimeType[] types = walk.ReadTypeHandles(count); + if (!walk.IsFinished) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + return types; + } + + private static ReadOnlySpan GetTypeData(byte* data, uint nodeCount) => + new(data, checked((int)nodeCount * TypeArgumentDataSize)); + + private static RuntimeModule GetModule(nint nativeAssembly) + { + if (nativeAssembly == 0) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + return (RuntimeModule)RuntimeAssembly.GetExposedObject(nativeAssembly).ManifestModule; + } + + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", + Justification = "The debugger supplies tokens from the target's actual loaded metadata.")] + private static RuntimeType ReadInstantiation(RuntimeModule module, int token, RuntimeType[] arguments) + { + RuntimeType type = (RuntimeType)module.ResolveType(token); + if (arguments.Length != 0) + { + if (!type.IsGenericTypeDefinition || type.GetGenericArguments().Length != arguments.Length) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + type = type.TypeHandle.Instantiate(arguments); + } + + return type; + } + + [StackTraceHidden] + private ref struct TypeDataWalk + { + private ReadOnlySpan _remaining; + + internal TypeDataWalk(ReadOnlySpan data) + { + if (data.Length % TypeArgumentDataSize != 0) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + _remaining = data; + } + + internal readonly bool IsFinished => _remaining.IsEmpty; + + internal RuntimeType[] ReadTypeHandles(int count) + { + if ((uint)count > (uint)(_remaining.Length / TypeArgumentDataSize)) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + 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(SR.Argument_InvalidGenericArg); + } + + ReadOnlySpan node = _remaining[..TypeArgumentDataSize]; + _remaining = _remaining[TypeArgumentDataSize..]; + uint elementValue = BinaryPrimitives.ReadUInt32LittleEndian( + node[TypeArgumentElementTypeOffset..]); + if (elementValue > byte.MaxValue) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + CorElementType elementType = (CorElementType)elementValue; + uint childCount = BinaryPrimitives.ReadUInt32LittleEndian(node[TypeArgumentChildCountOffset..]); + if (childCount > (uint)(_remaining.Length / TypeArgumentDataSize)) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + 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(SR.Argument_InvalidGenericArg); + } + + RuntimeType element = ReadTypeHandle(); + return elementType switch + { + CorElementType.ELEMENT_TYPE_ARRAY => (RuntimeType)element.MakeArrayType( + checked((int)BinaryPrimitives.ReadUInt32LittleEndian(node[TypeArgumentArrayRankOffset..]))), + 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)BinaryPrimitives.ReadUInt64LittleEndian( + node[TypeArgumentAssemblyOffset..])); + RuntimeModule module = GetModule(assembly); + int token = BinaryPrimitives.ReadInt32LittleEndian(node[TypeArgumentTokenOffset..]); + return ReadInstantiation(module, token, ReadTypeHandles((int)childCount)); + + case CorElementType.ELEMENT_TYPE_FNPTR: + if (childCount == 0) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + RuntimeType[] signature = ReadTypeHandles((int)childCount); + return signature[0].TypeHandle.MakeFunctionPointer(signature.AsSpan(1).ToArray(), isUnmanaged: false); + + default: + if (childCount != 0) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + 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(SR.Argument_InvalidGenericArg), + }); + } + } + } + } +} 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 06691c46595370..618008984d971f 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; @@ -106,6 +124,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); @@ -138,6 +170,158 @@ 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); + 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.")] + 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 = declaringType.TypeHandle.Instantiate(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) { @@ -148,14 +332,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) == @@ -328,9 +508,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); } @@ -759,18 +938,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..f36c777b4cc3c4 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 GetExposedObject(nint nativeAssembly) + { + RuntimeAssembly? assembly = null; + GetExposedObject(nativeAssembly, ObjectHandleOnStack.Create(ref assembly)); + Debug.Assert(assembly is not null); + return assembly; + } + + [ErrorHandler(typeof(QCallExceptionStatusMarshaller), ErrorLocation.HiddenLastParameter)] + [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetExposedObject")] + private static partial void GetExposedObject(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 66549ac11986d2..8bdcd0b83d2fa4 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -11645,110 +11645,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 c907559ebb69f3..a0e83d61bc2d07 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, @@ -2536,11 +2512,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( @@ -3384,13 +3357,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 85e682e1d81bfc..89e75a8635b2a5 100644 --- a/src/coreclr/debug/ee/funceval.cpp +++ b/src/coreclr/debug/ee/funceval.cpp @@ -709,6 +709,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) | @@ -1016,22 +1018,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 @@ -1083,24 +1069,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) { @@ -1339,7 +1307,10 @@ 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) { @@ -1357,8 +1328,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); @@ -1456,11 +1426,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); Holder, ReleaseFuncEvalArgumentHandles> argumentHandles(pArgumentHandles); Holder, FreeFuncEvalTemporaryResult> @@ -1531,198 +1508,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. @@ -1807,7 +1596,7 @@ void * STDCALL FuncEvalHijackWorker(DebuggerEval *pDE) pDE->m_thread->DisableSingleStep(); #endif - FuncEvalHijackRealWorker(pDE, pThread, &FEFrame); + GCProtectArgsAndInvokeManagedFuncEval(pDE, reinterpret_cast(&FEFrame)); #ifdef FEATURE_EMULATE_SINGLESTEP if (ssEnabled) diff --git a/src/coreclr/vm/assemblynative.cpp b/src/coreclr/vm/assemblynative.cpp index fa5b6fa61671a1..19b95f6b529c02 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_GetExposedObject(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 0ea20803c8a68b..6b01b6550a045b 100644 --- a/src/coreclr/vm/assemblynative.hpp +++ b/src/coreclr/vm/assemblynative.hpp @@ -42,6 +42,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_GetExposedObject(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 d82d7c68b3f5de..809a0afdadf041 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 e40947779a1dd2..71a49bbc91bdd0 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -1005,19 +1005,39 @@ 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(ElementType, DebuggerIPCE_TypeArgData, data.elementType) +DEFINE_FIELD_U(MetadataToken, DebuggerIPCE_TypeArgData, data.ClassTypeData.metadataToken) +DEFINE_FIELD_U(Assembly, DebuggerIPCE_TypeArgData, data.ClassTypeData.vmAssembly) +DEFINE_FIELD_U(ArrayRank, DebuggerIPCE_TypeArgData, data.ArrayTypeData.arrayRank) +DEFINE_FIELD_U(ChildCount, DebuggerIPCE_TypeArgData, numTypeArgs) #endif // DEBUGGING_SUPPORTED +#ifdef FOR_ILLINK +// The layout-only mirror is not otherwise referenced by managed code. +DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeTypeArgument, DebuggerIPCE_TypeArgData) +#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 e3c42eb12eab52..78823222f33f43 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( diff --git a/src/coreclr/vm/debugdebugger.cpp b/src/coreclr/vm/debugdebugger.cpp index 29181e1d874c5b..56646502390b87 100644 --- a/src/coreclr/vm/debugdebugger.cpp +++ b/src/coreclr/vm/debugdebugger.cpp @@ -1025,119 +1025,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) @@ -1159,8 +1047,9 @@ 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()))) { MethodTable* pMT = resultType.GetMethodTable(); pMT->EnsureInstanceActive(); @@ -1181,25 +1070,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 3f6a252cc7a578..736a1c89c21e1d 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 DebuggerFuncEvalContext { DebuggerEval* pEval; @@ -39,12 +49,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 @@ -57,8 +73,10 @@ enum DebuggerFuncEvalFlags struct DebuggerFuncEvalArgument { BYTE* pLiteral; + BYTE* pTypeData; UINT32 elementType; UINT32 flags; + UINT32 typeNodeCount; }; enum DebuggerFuncEvalArgumentFlags @@ -69,15 +87,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/qcallentrypoints.cpp b/src/coreclr/vm/qcallentrypoints.cpp index 9b36c3f832d0df..eb38cb86e48473 100644 --- a/src/coreclr/vm/qcallentrypoints.cpp +++ b/src/coreclr/vm/qcallentrypoints.cpp @@ -121,9 +121,7 @@ static const Entry s_QCall[] = DllImportEntry(DebugDebugger_IsLoggingHelper) DllImportEntry(DebugDebugger_IsManagedDebuggerAttached) #if defined(DEBUGGING_SUPPORTED) - DllImportEntry(DebugDebugger_GetFuncEvalMethod) DllImportEntry(DebugDebugger_PrepareFuncEvalResult) - DllImportEntry(DebugDebugger_GetFuncEvalArgumentType) DllImportEntry(DebugDebugger_ReadFuncEvalPrimitiveRegister) DllImportEntry(DebugDebugger_WriteFuncEvalObjectRegister) DllImportEntry(DebugDebugger_WriteFuncEvalRegister) @@ -307,6 +305,7 @@ static const Entry s_QCall[] = DllImportEntry(AssemblyNative_GetAssemblyCount) DllImportEntry(AssemblyNative_GetEntryAssembly) DllImportEntry(AssemblyNative_GetExecutingAssembly) + DllImportEntry(AssemblyNative_GetExposedObject) DllImportEntry(TypeMapLazyDictionary_FindPrecachedExternalTypeMapEntry) DllImportEntry(TypeMapLazyDictionary_FindPrecachedProxyTypeMapEntry) DllImportEntry(TypeMapLazyDictionary_ProcessAttributes) diff --git a/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp b/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp index abf461cc5f7699..15e4f582663e32 100644 --- a/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp +++ b/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp @@ -346,6 +346,7 @@ extern "C" { void QCall_AssemblyNative_GetEntryPoint (void *, void *, void *) __asm__("AssemblyNative_GetEntryPoint"); void QCall_AssemblyNative_GetExecutingAssembly (void *, void *, void *) __asm__("AssemblyNative_GetExecutingAssembly"); void QCall_AssemblyNative_GetExportedTypes (void *, void *, void *) __asm__("AssemblyNative_GetExportedTypes"); + void QCall_AssemblyNative_GetExposedObject (void *, void *, void *) __asm__("AssemblyNative_GetExposedObject"); int32_t QCall_AssemblyNative_GetFlags (void *, void *) __asm__("AssemblyNative_GetFlags"); void QCall_AssemblyNative_GetForwardedType (void *, int32_t, void *, void *) __asm__("AssemblyNative_GetForwardedType"); void QCall_AssemblyNative_GetFullName (void *, void *, void *) __asm__("AssemblyNative_GetFullName"); @@ -381,8 +382,6 @@ extern "C" { int32_t QCall_CustomAttribute_ParseAttributeUsageAttribute (void *, int32_t, void *, void *, void *) __asm__("CustomAttribute_ParseAttributeUsageAttribute"); void QCall_DebugDebugger_Break (void *) __asm__("DebugDebugger_Break"); void QCall_DebugDebugger_CustomNotification (void *, void *) __asm__("DebugDebugger_CustomNotification"); - void QCall_DebugDebugger_GetFuncEvalArgumentType (void *, uint32_t, void *, void *) __asm__("DebugDebugger_GetFuncEvalArgumentType"); - void QCall_DebugDebugger_GetFuncEvalMethod (void *, void *, void *, void *) __asm__("DebugDebugger_GetFuncEvalMethod"); int32_t QCall_DebugDebugger_IsLoggingHelper () __asm__("DebugDebugger_IsLoggingHelper"); int32_t QCall_DebugDebugger_IsManagedDebuggerAttached () __asm__("DebugDebugger_IsManagedDebuggerAttached"); int32_t QCall_DebugDebugger_Launch () __asm__("DebugDebugger_Launch"); @@ -649,6 +648,7 @@ static const Entry s_QCall[] = { { "AssemblyNative_GetEntryPoint", (void*)&QCall_AssemblyNative_GetEntryPoint }, { "AssemblyNative_GetExecutingAssembly", (void*)&QCall_AssemblyNative_GetExecutingAssembly }, { "AssemblyNative_GetExportedTypes", (void*)&QCall_AssemblyNative_GetExportedTypes }, + { "AssemblyNative_GetExposedObject", (void*)&QCall_AssemblyNative_GetExposedObject }, { "AssemblyNative_GetFlags", (void*)&QCall_AssemblyNative_GetFlags }, { "AssemblyNative_GetForwardedType", (void*)&QCall_AssemblyNative_GetForwardedType }, { "AssemblyNative_GetFullName", (void*)&QCall_AssemblyNative_GetFullName }, @@ -684,8 +684,6 @@ static const Entry s_QCall[] = { { "CustomAttribute_ParseAttributeUsageAttribute", (void*)&QCall_CustomAttribute_ParseAttributeUsageAttribute }, { "DebugDebugger_Break", (void*)&QCall_DebugDebugger_Break }, { "DebugDebugger_CustomNotification", (void*)&QCall_DebugDebugger_CustomNotification }, - { "DebugDebugger_GetFuncEvalArgumentType", (void*)&QCall_DebugDebugger_GetFuncEvalArgumentType }, - { "DebugDebugger_GetFuncEvalMethod", (void*)&QCall_DebugDebugger_GetFuncEvalMethod }, { "DebugDebugger_IsLoggingHelper", (void*)&QCall_DebugDebugger_IsLoggingHelper }, { "DebugDebugger_IsManagedDebuggerAttached", (void*)&QCall_DebugDebugger_IsManagedDebuggerAttached }, { "DebugDebugger_Launch", (void*)&QCall_DebugDebugger_Launch }, diff --git a/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp b/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp index 3f3431de245b14..a6ee40fe427773 100644 --- a/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp +++ b/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp @@ -633,6 +633,7 @@ extern "C" { void QCall_AssemblyNative_GetEntryPoint (void *, void *, void *) __asm__("AssemblyNative_GetEntryPoint"); void QCall_AssemblyNative_GetExecutingAssembly (void *, void *, void *) __asm__("AssemblyNative_GetExecutingAssembly"); void QCall_AssemblyNative_GetExportedTypes (void *, void *, void *) __asm__("AssemblyNative_GetExportedTypes"); + void QCall_AssemblyNative_GetExposedObject (void *, void *, void *) __asm__("AssemblyNative_GetExposedObject"); int32_t QCall_AssemblyNative_GetFlags (void *, void *) __asm__("AssemblyNative_GetFlags"); void QCall_AssemblyNative_GetForwardedType (void *, int32_t, void *, void *) __asm__("AssemblyNative_GetForwardedType"); void QCall_AssemblyNative_GetFullName (void *, void *, void *) __asm__("AssemblyNative_GetFullName"); @@ -669,8 +670,6 @@ extern "C" { int32_t QCall_CustomAttribute_ParseAttributeUsageAttribute (void *, int32_t, void *, void *, void *) __asm__("CustomAttribute_ParseAttributeUsageAttribute"); void QCall_DebugDebugger_Break (void *) __asm__("DebugDebugger_Break"); void QCall_DebugDebugger_CustomNotification (void *, void *) __asm__("DebugDebugger_CustomNotification"); - void QCall_DebugDebugger_GetFuncEvalArgumentType (void *, uint32_t, void *, void *) __asm__("DebugDebugger_GetFuncEvalArgumentType"); - void QCall_DebugDebugger_GetFuncEvalMethod (void *, void *, void *, void *) __asm__("DebugDebugger_GetFuncEvalMethod"); int32_t QCall_DebugDebugger_IsLoggingHelper () __asm__("DebugDebugger_IsLoggingHelper"); int32_t QCall_DebugDebugger_IsManagedDebuggerAttached () __asm__("DebugDebugger_IsManagedDebuggerAttached"); int32_t QCall_DebugDebugger_Launch () __asm__("DebugDebugger_Launch"); @@ -935,6 +934,7 @@ static const Entry s_QCall[] = { { "AssemblyNative_GetEntryPoint", (void*)&QCall_AssemblyNative_GetEntryPoint }, { "AssemblyNative_GetExecutingAssembly", (void*)&QCall_AssemblyNative_GetExecutingAssembly }, { "AssemblyNative_GetExportedTypes", (void*)&QCall_AssemblyNative_GetExportedTypes }, + { "AssemblyNative_GetExposedObject", (void*)&QCall_AssemblyNative_GetExposedObject }, { "AssemblyNative_GetFlags", (void*)&QCall_AssemblyNative_GetFlags }, { "AssemblyNative_GetForwardedType", (void*)&QCall_AssemblyNative_GetForwardedType }, { "AssemblyNative_GetFullName", (void*)&QCall_AssemblyNative_GetFullName }, @@ -971,8 +971,6 @@ static const Entry s_QCall[] = { { "CustomAttribute_ParseAttributeUsageAttribute", (void*)&QCall_CustomAttribute_ParseAttributeUsageAttribute }, { "DebugDebugger_Break", (void*)&QCall_DebugDebugger_Break }, { "DebugDebugger_CustomNotification", (void*)&QCall_DebugDebugger_CustomNotification }, - { "DebugDebugger_GetFuncEvalArgumentType", (void*)&QCall_DebugDebugger_GetFuncEvalArgumentType }, - { "DebugDebugger_GetFuncEvalMethod", (void*)&QCall_DebugDebugger_GetFuncEvalMethod }, { "DebugDebugger_IsLoggingHelper", (void*)&QCall_DebugDebugger_IsLoggingHelper }, { "DebugDebugger_IsManagedDebuggerAttached", (void*)&QCall_DebugDebugger_IsManagedDebuggerAttached }, { "DebugDebugger_Launch", (void*)&QCall_DebugDebugger_Launch }, From d01db86f98f64626d84f1ea50faff9517f108863 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 11 Nov 2026 11:56:32 -0800 Subject: [PATCH 2/3] Refine managed func-eval dispatch and type decoding Model native type records with CStruct/CUnion layouts and traverse typed spans. Preserve native loader exception types, invoke all evaluation kinds directly, and move the remaining CHF wrapper declarations to the VM exception header. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- ...ebugger.FunctionEvaluation.TypeDataWalk.cs | 130 ++++++++++++------ .../Debugger.FunctionEvaluation.cs | 2 +- src/coreclr/debug/ee/funceval.cpp | 52 +------ src/coreclr/vm/corelib.h | 40 +++++- src/coreclr/vm/dbginterface.h | 7 - src/coreclr/vm/debugdebugger.cpp | 2 + src/coreclr/vm/excep.h | 6 + 7 files changed, 136 insertions(+), 103 deletions(-) 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 index fd4b900f92b119..fd78e0ac289754 100644 --- 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 @@ -13,34 +13,75 @@ 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 using the reader's size and offsets. - private const int TypeArgumentDataSize = 48; - private const int TypeArgumentElementTypeOffset = 0; - private const int TypeArgumentTokenOffset = 8; - private const int TypeArgumentAssemblyOffset = 16; - private const int TypeArgumentArrayRankOffset = 32; - private const int TypeArgumentChildCountOffset = 40; - - // Preserve the unused slots in the flattened native union, including padding on 32-bit targets. - [StructLayout(LayoutKind.Sequential)] + // 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 ElementTypePadding; internal uint MetadataToken; - internal uint MetadataTokenPadding; 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; - internal uint ArrayRankPadding; - internal uint ChildCount; - internal uint ChildCountPadding; + } + + [ExtendedLayout(ExtendedLayoutKind.CStruct)] + internal struct NativeNaryTypeData + { + internal ulong TypeHandle; } [DebuggerHidden] internal static RuntimeType[] ReadTypeArguments(ReadOnlySpan typeData, int count) { - TypeDataWalk walk = new(typeData); + if (typeData.Length % sizeof(NativeTypeArgument) != 0) + { + throw new ArgumentException(SR.Argument_InvalidGenericArg); + } + + TypeDataWalk walk = new(MemoryMarshal.Cast(typeData)); RuntimeType[] types = walk.ReadTypeHandles(count); if (!walk.IsFinished) { @@ -51,7 +92,7 @@ internal static RuntimeType[] ReadTypeArguments(ReadOnlySpan typeData, int } private static ReadOnlySpan GetTypeData(byte* data, uint nodeCount) => - new(data, checked((int)nodeCount * TypeArgumentDataSize)); + new(data, checked((int)nodeCount * sizeof(NativeTypeArgument))); private static RuntimeModule GetModule(nint nativeAssembly) { @@ -65,16 +106,12 @@ private static RuntimeModule GetModule(nint nativeAssembly) [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The debugger supplies tokens from the target's actual loaded metadata.")] - private static RuntimeType ReadInstantiation(RuntimeModule module, int token, RuntimeType[] arguments) + private static RuntimeType ReadInstantiation( + RuntimeModule module, int token, RuntimeType[] arguments, bool allowUninstantiated = false) { RuntimeType type = (RuntimeType)module.ResolveType(token); - if (arguments.Length != 0) + if (!allowUninstantiated || arguments.Length != 0) { - if (!type.IsGenericTypeDefinition || type.GetGenericArguments().Length != arguments.Length) - { - throw new ArgumentException(SR.Argument_InvalidGenericArg); - } - type = type.TypeHandle.Instantiate(arguments); } @@ -84,15 +121,10 @@ private static RuntimeType ReadInstantiation(RuntimeModule module, int token, Ru [StackTraceHidden] private ref struct TypeDataWalk { - private ReadOnlySpan _remaining; + private ReadOnlySpan _remaining; - internal TypeDataWalk(ReadOnlySpan data) + internal TypeDataWalk(ReadOnlySpan data) { - if (data.Length % TypeArgumentDataSize != 0) - { - throw new ArgumentException(SR.Argument_InvalidGenericArg); - } - _remaining = data; } @@ -100,7 +132,7 @@ internal TypeDataWalk(ReadOnlySpan data) internal RuntimeType[] ReadTypeHandles(int count) { - if ((uint)count > (uint)(_remaining.Length / TypeArgumentDataSize)) + if ((uint)count > (uint)_remaining.Length) { throw new ArgumentException(SR.Argument_InvalidGenericArg); } @@ -121,18 +153,29 @@ private RuntimeType ReadTypeHandle() throw new ArgumentException(SR.Argument_InvalidGenericArg); } - ReadOnlySpan node = _remaining[..TypeArgumentDataSize]; - _remaining = _remaining[TypeArgumentDataSize..]; - uint elementValue = BinaryPrimitives.ReadUInt32LittleEndian( - node[TypeArgumentElementTypeOffset..]); + 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(SR.Argument_InvalidGenericArg); } CorElementType elementType = (CorElementType)elementValue; - uint childCount = BinaryPrimitives.ReadUInt32LittleEndian(node[TypeArgumentChildCountOffset..]); - if (childCount > (uint)(_remaining.Length / TypeArgumentDataSize)) + uint childCount = node.ChildCount; + if (childCount > (uint)_remaining.Length) { throw new ArgumentException(SR.Argument_InvalidGenericArg); } @@ -151,8 +194,10 @@ private RuntimeType ReadTypeHandle() RuntimeType element = ReadTypeHandle(); return elementType switch { - CorElementType.ELEMENT_TYPE_ARRAY => (RuntimeType)element.MakeArrayType( - checked((int)BinaryPrimitives.ReadUInt32LittleEndian(node[TypeArgumentArrayRankOffset..]))), + CorElementType.ELEMENT_TYPE_ARRAY when node.Data.TypeData.ArrayTypeData.ArrayRank == 0 => + throw new BadImageFormatException(SR.Arg_BadImageFormatException), + CorElementType.ELEMENT_TYPE_ARRAY => element.TypeHandle.MakeArray( + unchecked((int)node.Data.TypeData.ArrayTypeData.ArrayRank)), CorElementType.ELEMENT_TYPE_SZARRAY => (RuntimeType)element.MakeArrayType(), CorElementType.ELEMENT_TYPE_PTR => (RuntimeType)element.MakePointerType(), _ => (RuntimeType)element.MakeByRefType(), @@ -160,10 +205,9 @@ private RuntimeType ReadTypeHandle() case CorElementType.ELEMENT_TYPE_CLASS: case CorElementType.ELEMENT_TYPE_VALUETYPE: - nint assembly = (nint)checked((nuint)BinaryPrimitives.ReadUInt64LittleEndian( - node[TypeArgumentAssemblyOffset..])); + nint assembly = (nint)checked((nuint)node.Data.TypeData.ClassTypeData.Assembly); RuntimeModule module = GetModule(assembly); - int token = BinaryPrimitives.ReadInt32LittleEndian(node[TypeArgumentTokenOffset..]); + int token = unchecked((int)node.Data.TypeData.ClassTypeData.MetadataToken); return ReadInstantiation(module, token, ReadTypeHandles((int)childCount)); case CorElementType.ELEMENT_TYPE_FNPTR: 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 618008984d971f..0082c7fc27e781 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 @@ -184,7 +184,7 @@ private static void RunSimple(Context* context) { case EvaluationKind.NewObjectNoConstructor: resultType = ReadInstantiation(GetModule((nint)context->Assembly), - (int)context->MemberToken, typeArguments); + (int)context->MemberToken, typeArguments, allowUninstantiated: true); if (resultType.ContainsGenericParameters) { throw new ArgumentException(SR.Argument_InvalidGenericArg); diff --git a/src/coreclr/debug/ee/funceval.cpp b/src/coreclr/debug/ee/funceval.cpp index 89e75a8635b2a5..ac1cab55b3da65 100644 --- a/src/coreclr/debug/ee/funceval.cpp +++ b/src/coreclr/debug/ee/funceval.cpp @@ -1101,46 +1101,6 @@ void Debugger::WriteFuncEvalRegister( SetFuncEvalRegisterValue(pDE, &pDE->GetArgData()[index], value); } -/* - * 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 * @@ -1297,7 +1257,7 @@ static void ValidateFuncEvalArgumentCount(DebuggerEval* pDE) } } -static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext, BYTE* pCatcherStackAddr) +static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext) { CONTRACTL { @@ -1317,7 +1277,7 @@ static void InvokeManagedFuncEval(DebuggerFuncEvalContext* pContext, BYTE* pCatc 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; @@ -1345,14 +1305,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 { @@ -1474,7 +1432,7 @@ static void GCProtectArgsAndInvokeManagedFuncEval(DebuggerEval *pDE, } IfFailThrow(captureResult); - InvokeManagedFuncEval(&context, pCatcherStackAddr); + InvokeManagedFuncEval(&context); } EX_CATCH { @@ -1596,7 +1554,7 @@ void * STDCALL FuncEvalHijackWorker(DebuggerEval *pDE) pDE->m_thread->DisableSingleStep(); #endif - GCProtectArgsAndInvokeManagedFuncEval(pDE, reinterpret_cast(&FEFrame)); + GCProtectArgsAndInvokeManagedFuncEval(pDE); #ifdef FEATURE_EMULATE_SINGLESTEP if (ssEnabled) diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index 71a49bbc91bdd0..91f58d630111f1 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -1026,16 +1026,46 @@ DEFINE_FIELD_U(Flags, DebuggerFuncEvalArgument, flags) DEFINE_FIELD_U(TypeNodeCount, DebuggerFuncEvalArgument, typeNodeCount) DEFINE_CLASS_U(Diagnostics, Debugger+FunctionEvaluation+NativeTypeArgument, DebuggerIPCE_TypeArgData) -DEFINE_FIELD_U(ElementType, DebuggerIPCE_TypeArgData, data.elementType) -DEFINE_FIELD_U(MetadataToken, DebuggerIPCE_TypeArgData, data.ClassTypeData.metadataToken) -DEFINE_FIELD_U(Assembly, DebuggerIPCE_TypeArgData, data.ClassTypeData.vmAssembly) -DEFINE_FIELD_U(ArrayRank, DebuggerIPCE_TypeArgData, data.ArrayTypeData.arrayRank) +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) #endif // DEBUGGING_SUPPORTED #ifdef FOR_ILLINK -// The layout-only mirror is not otherwise referenced by managed code. +// Preserve all wire-layout fields, including ignored slots, for parsing and native binder checks. 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)) #endif // FOR_ILLINK DEFINE_CLASS(BUFFER, System, Buffer) diff --git a/src/coreclr/vm/dbginterface.h b/src/coreclr/vm/dbginterface.h index 78823222f33f43..844bd5b9813b17 100644 --- a/src/coreclr/vm/dbginterface.h +++ b/src/coreclr/vm/dbginterface.h @@ -379,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 56646502390b87..fab2d2d743512d 100644 --- a/src/coreclr/vm/debugdebugger.cpp +++ b/src/coreclr/vm/debugdebugger.cpp @@ -1051,6 +1051,8 @@ extern "C" void QCALLTYPE DebugDebugger_PrepareFuncEvalResult( (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(); diff --git a/src/coreclr/vm/excep.h b/src/coreclr/vm/excep.h index fc571d12b7751d..ce4048c392453f 100644 --- a/src/coreclr/vm/excep.h +++ b/src/coreclr/vm/excep.h @@ -165,6 +165,12 @@ void CrashDumpAndTerminateProcess(UINT exitCode); LONG ThreadBaseExceptionAppDomainFilter(PEXCEPTION_POINTERS pExceptionInfo, PVOID pvParam); +#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 // !DACCESS_COMPILE + void STDMETHODCALLTYPE DefaultCatchHandler(PEXCEPTION_POINTERS pExceptionInfo, OBJECTREF *Throwable = NULL, BOOL useLastThrownObject = FALSE, From 45d3c282d7cf02e4bd2f1d0c909b2751b5117fd6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 19 Nov 2026 15:07:23 -0800 Subject: [PATCH 3/3] Address managed func-eval review feedback Use standard reflection factories and exception messages, align the assembly bridge name across managed/native and WebAssembly helpers, and remove an obsolete comment. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- ...ebugger.FunctionEvaluation.TypeDataWalk.cs | 34 +++++++++---------- .../Debugger.FunctionEvaluation.cs | 4 ++- .../src/System/Reflection/RuntimeAssembly.cs | 8 ++--- src/coreclr/vm/assemblynative.cpp | 2 +- src/coreclr/vm/assemblynative.hpp | 2 +- src/coreclr/vm/excep.h | 1 - src/coreclr/vm/runtimehelpers.cpp | 2 +- .../vm/wasm/browser/callhelpers-pinvoke.cpp | 4 +-- .../vm/wasm/wasi/callhelpers-pinvoke.cpp | 4 +-- 9 files changed, 31 insertions(+), 30 deletions(-) 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 index fd78e0ac289754..c25a5b4c4fb4cd 100644 --- 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 @@ -78,14 +78,14 @@ internal static RuntimeType[] ReadTypeArguments(ReadOnlySpan typeData, int { if (typeData.Length % sizeof(NativeTypeArgument) != 0) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } TypeDataWalk walk = new(MemoryMarshal.Cast(typeData)); RuntimeType[] types = walk.ReadTypeHandles(count); if (!walk.IsFinished) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } return types; @@ -98,21 +98,23 @@ private static RuntimeModule GetModule(nint nativeAssembly) { if (nativeAssembly == 0) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } - return (RuntimeModule)RuntimeAssembly.GetExposedObject(nativeAssembly).ManifestModule; + 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 (!allowUninstantiated || arguments.Length != 0) + if (arguments.Length != 0 || (!allowUninstantiated && type.IsGenericTypeDefinition)) { - type = type.TypeHandle.Instantiate(arguments); + type = (RuntimeType)type.MakeGenericType(arguments); } return type; @@ -134,7 +136,7 @@ internal RuntimeType[] ReadTypeHandles(int count) { if ((uint)count > (uint)_remaining.Length) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } RuntimeType[] types = count == 0 ? [] : new RuntimeType[count]; @@ -150,7 +152,7 @@ private RuntimeType ReadTypeHandle() { if (_remaining.IsEmpty) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } NativeTypeArgument node = _remaining[0]; @@ -170,14 +172,14 @@ private RuntimeType ReadTypeHandle() uint elementValue = node.Data.ElementType; if (elementValue > byte.MaxValue) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } CorElementType elementType = (CorElementType)elementValue; uint childCount = node.ChildCount; if (childCount > (uint)_remaining.Length) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } switch (elementType) @@ -188,15 +190,13 @@ private RuntimeType ReadTypeHandle() case CorElementType.ELEMENT_TYPE_BYREF: if (childCount != 1) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } RuntimeType element = ReadTypeHandle(); return elementType switch { - CorElementType.ELEMENT_TYPE_ARRAY when node.Data.TypeData.ArrayTypeData.ArrayRank == 0 => - throw new BadImageFormatException(SR.Arg_BadImageFormatException), - CorElementType.ELEMENT_TYPE_ARRAY => element.TypeHandle.MakeArray( + 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(), @@ -213,7 +213,7 @@ private RuntimeType ReadTypeHandle() case CorElementType.ELEMENT_TYPE_FNPTR: if (childCount == 0) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } RuntimeType[] signature = ReadTypeHandles((int)childCount); @@ -222,7 +222,7 @@ private RuntimeType ReadTypeHandle() default: if (childCount != 0) { - throw new ArgumentException(SR.Argument_InvalidGenericArg); + throw new ArgumentException(); } return (RuntimeType)(elementType switch @@ -245,7 +245,7 @@ private RuntimeType ReadTypeHandle() CorElementType.ELEMENT_TYPE_I => typeof(nint), CorElementType.ELEMENT_TYPE_U => typeof(nuint), CorElementType.ELEMENT_TYPE_OBJECT => typeof(object), - _ => throw new ArgumentException(SR.Argument_InvalidGenericArg), + _ => 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 f8dc56268e81ae..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 @@ -282,6 +282,8 @@ private static void InitializeType(RuntimeType type) => [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); @@ -297,7 +299,7 @@ private static MethodBase GetMethod(Context* context, RuntimeType[] typeArgument if (classArgumentCount != 0) { - declaringType = declaringType.TypeHandle.Instantiate(typeArguments[..classArgumentCount]); + declaringType = (RuntimeType)declaringType.MakeGenericType(typeArguments[..classArgumentCount]); } if (methodArgumentCount != 0) { 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 f36c777b4cc3c4..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,17 +36,17 @@ internal sealed partial class RuntimeAssembly : Assembly internal IntPtr GetUnderlyingNativeHandle() => m_assembly; - internal static RuntimeAssembly GetExposedObject(nint nativeAssembly) + internal static RuntimeAssembly GetAssemblyFromHandle(nint nativeAssembly) { RuntimeAssembly? assembly = null; - GetExposedObject(nativeAssembly, ObjectHandleOnStack.Create(ref assembly)); + GetAssemblyFromHandle(nativeAssembly, ObjectHandleOnStack.Create(ref assembly)); Debug.Assert(assembly is not null); return assembly; } [ErrorHandler(typeof(QCallExceptionStatusMarshaller), ErrorLocation.HiddenLastParameter)] - [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetExposedObject")] - private static partial void GetExposedObject(nint nativeAssembly, ObjectHandleOnStack assembly); + [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetAssemblyFromHandle")] + private static partial void GetAssemblyFromHandle(nint nativeAssembly, ObjectHandleOnStack assembly); private sealed class ManifestResourceStream : UnmanagedMemoryStream { diff --git a/src/coreclr/vm/assemblynative.cpp b/src/coreclr/vm/assemblynative.cpp index 237ecb3b7a5ee7..5a2e5ea7518987 100644 --- a/src/coreclr/vm/assemblynative.cpp +++ b/src/coreclr/vm/assemblynative.cpp @@ -1134,7 +1134,7 @@ extern "C" void QCALLTYPE AssemblyNative_GetFullName(QCall::AssemblyHandle pAsse END_QCALL; } -extern "C" void QCALLTYPE AssemblyNative_GetExposedObject(Assembly* pAssembly, QCall::ObjectHandleOnStack retAssembly, QCallExceptionStatus* qcallError) +extern "C" void QCALLTYPE AssemblyNative_GetAssemblyFromHandle(Assembly* pAssembly, QCall::ObjectHandleOnStack retAssembly, QCallExceptionStatus* qcallError) { QCALL_CONTRACT; diff --git a/src/coreclr/vm/assemblynative.hpp b/src/coreclr/vm/assemblynative.hpp index 0aa9d6d96eb762..50a8afe622b21e 100644 --- a/src/coreclr/vm/assemblynative.hpp +++ b/src/coreclr/vm/assemblynative.hpp @@ -37,7 +37,7 @@ 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_GetExposedObject(Assembly* pAssembly, 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/excep.h b/src/coreclr/vm/excep.h index ce4048c392453f..6ee29782689dcf 100644 --- a/src/coreclr/vm/excep.h +++ b/src/coreclr/vm/excep.h @@ -166,7 +166,6 @@ void CrashDumpAndTerminateProcess(UINT exitCode); LONG ThreadBaseExceptionAppDomainFilter(PEXCEPTION_POINTERS pExceptionInfo, PVOID pvParam); #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 // !DACCESS_COMPILE diff --git a/src/coreclr/vm/runtimehelpers.cpp b/src/coreclr/vm/runtimehelpers.cpp index 29b4d379ccbad5..92044cd06a678d 100644 --- a/src/coreclr/vm/runtimehelpers.cpp +++ b/src/coreclr/vm/runtimehelpers.cpp @@ -117,12 +117,12 @@ 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) DllImportEntry(AssemblyNative_GetExecutingAssembly) DllImportEntry(AssemblyNative_GetExportedTypes) - DllImportEntry(AssemblyNative_GetExposedObject) DllImportEntry(AssemblyNative_GetFlags) DllImportEntry(AssemblyNative_GetForwardedType) DllImportEntry(AssemblyNative_GetFullName) diff --git a/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp b/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp index c189183e8d60f2..2e979b25c7bf0c 100644 --- a/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp +++ b/src/coreclr/vm/wasm/browser/callhelpers-pinvoke.cpp @@ -343,12 +343,12 @@ 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"); void RuntimeHelper_AssemblyNative_GetExecutingAssembly (void *, void *, void *) __asm__("AssemblyNative_GetExecutingAssembly"); void RuntimeHelper_AssemblyNative_GetExportedTypes (void *, void *, void *) __asm__("AssemblyNative_GetExportedTypes"); - void RuntimeHelper_AssemblyNative_GetExposedObject (void *, void *, void *) __asm__("AssemblyNative_GetExposedObject"); int32_t RuntimeHelper_AssemblyNative_GetFlags (void *, void *) __asm__("AssemblyNative_GetFlags"); void RuntimeHelper_AssemblyNative_GetForwardedType (void *, int32_t, void *, void *) __asm__("AssemblyNative_GetForwardedType"); void RuntimeHelper_AssemblyNative_GetFullName (void *, void *, void *) __asm__("AssemblyNative_GetFullName"); @@ -849,12 +849,12 @@ 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 }, { "AssemblyNative_GetExecutingAssembly", (void*)&RuntimeHelper_AssemblyNative_GetExecutingAssembly }, { "AssemblyNative_GetExportedTypes", (void*)&RuntimeHelper_AssemblyNative_GetExportedTypes }, - { "AssemblyNative_GetExposedObject", (void*)&RuntimeHelper_AssemblyNative_GetExposedObject }, { "AssemblyNative_GetFlags", (void*)&RuntimeHelper_AssemblyNative_GetFlags }, { "AssemblyNative_GetForwardedType", (void*)&RuntimeHelper_AssemblyNative_GetForwardedType }, { "AssemblyNative_GetFullName", (void*)&RuntimeHelper_AssemblyNative_GetFullName }, diff --git a/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp b/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp index bb559b71675bb1..3dd3f101a319ea 100644 --- a/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp +++ b/src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp @@ -622,12 +622,12 @@ 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"); void RuntimeHelper_AssemblyNative_GetExecutingAssembly (void *, void *, void *) __asm__("AssemblyNative_GetExecutingAssembly"); void RuntimeHelper_AssemblyNative_GetExportedTypes (void *, void *, void *) __asm__("AssemblyNative_GetExportedTypes"); - void RuntimeHelper_AssemblyNative_GetExposedObject (void *, void *, void *) __asm__("AssemblyNative_GetExposedObject"); int32_t RuntimeHelper_AssemblyNative_GetFlags (void *, void *) __asm__("AssemblyNative_GetFlags"); void RuntimeHelper_AssemblyNative_GetForwardedType (void *, int32_t, void *, void *) __asm__("AssemblyNative_GetForwardedType"); void RuntimeHelper_AssemblyNative_GetFullName (void *, void *, void *) __asm__("AssemblyNative_GetFullName"); @@ -1130,12 +1130,12 @@ 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 }, { "AssemblyNative_GetExecutingAssembly", (void*)&RuntimeHelper_AssemblyNative_GetExecutingAssembly }, { "AssemblyNative_GetExportedTypes", (void*)&RuntimeHelper_AssemblyNative_GetExportedTypes }, - { "AssemblyNative_GetExposedObject", (void*)&RuntimeHelper_AssemblyNative_GetExposedObject }, { "AssemblyNative_GetFlags", (void*)&RuntimeHelper_AssemblyNative_GetFlags }, { "AssemblyNative_GetForwardedType", (void*)&RuntimeHelper_AssemblyNative_GetForwardedType }, { "AssemblyNative_GetFullName", (void*)&RuntimeHelper_AssemblyNative_GetFullName },