1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 #pragma once 5 6 // TODO: Debugger/DAC support (look for TODO: JIT) 7 8 struct REGDISPLAY; 9 10 #define GC_CALL_INTERIOR 0x1 11 #define GC_CALL_PINNED 0x2 12 #define GC_CALL_CHECK_APP_DOMAIN 0x4 13 #define GC_CALL_STATIC 0x8 14 15 typedef void (*GCEnumCallback)( 16 void * hCallback, // callback data 17 PTR_PTR_VOID pObject, // address of object-reference we are reporting 18 UInt32 flags // is this a pinned and/or interior pointer 19 ); 20 21 struct GCEnumContext 22 { 23 GCEnumCallback pCallback; 24 }; 25 26 enum GCRefKind : unsigned char 27 { 28 GCRK_Scalar = 0x00, 29 GCRK_Object = 0x01, 30 GCRK_Byref = 0x02, 31 GCRK_Unknown = 0xFF, 32 }; 33 34 // 35 // MethodInfo is placeholder type used to allocate space for MethodInfo. Maximum size 36 // of the actual method should be less or equal to the placeholder size. 37 // It avoids memory allocation during stackwalk. 38 // 39 class MethodInfo 40 { 41 TADDR dummyPtrs[5]; 42 Int32 dummyInts[8]; 43 }; 44 45 class EHEnumState 46 { 47 TADDR dummyPtrs[2]; 48 Int32 dummyInts[2]; 49 }; 50 51 enum EHClauseKind 52 { 53 EH_CLAUSE_TYPED = 0, 54 EH_CLAUSE_FAULT = 1, 55 EH_CLAUSE_FILTER = 2, 56 EH_CLAUSE_UNUSED = 3, 57 }; 58 59 struct EHClause 60 { 61 EHClauseKind m_clauseKind; 62 UInt32 m_tryStartOffset; 63 UInt32 m_tryEndOffset; 64 UInt8* m_filterAddress; 65 UInt8* m_handlerAddress; 66 void* m_pTargetType; 67 }; 68 69 // Constants used with RhpGetClasslibFunction, to indicate which classlib function 70 // we are interested in. 71 // Note: make sure you change the def in System\Runtime\exceptionhandling.cs if you change this! 72 enum class ClasslibFunctionId 73 { 74 GetRuntimeException = 0, 75 FailFast = 1, 76 UnhandledExceptionHandler = 2, 77 AppendExceptionStackFrame = 3, 78 CheckStaticClassConstruction = 4, 79 GetSystemArrayEEType = 5, 80 OnFirstChanceException = 6, 81 }; 82 83 enum class AssociatedDataFlags : unsigned char 84 { 85 None = 0, 86 HasUnboxingStubTarget = 1, 87 }; 88 89 class ICodeManager 90 { 91 public: 92 virtual bool FindMethodInfo(PTR_VOID ControlPC, 93 MethodInfo * pMethodInfoOut) = 0; 94 95 virtual bool IsFunclet(MethodInfo * pMethodInfo) = 0; 96 97 virtual PTR_VOID GetFramePointer(MethodInfo * pMethodInfo, 98 REGDISPLAY * pRegisterSet) = 0; 99 100 virtual void EnumGcRefs(MethodInfo * pMethodInfo, 101 PTR_VOID safePointAddress, 102 REGDISPLAY * pRegisterSet, 103 GCEnumContext * hCallback) = 0; 104 105 virtual bool UnwindStackFrame(MethodInfo * pMethodInfo, 106 REGDISPLAY * pRegisterSet, // in/out 107 PTR_VOID * ppPreviousTransitionFrame) = 0; // out 108 109 virtual UIntNative GetConservativeUpperBoundForOutgoingArgs(MethodInfo * pMethodInfo, 110 REGDISPLAY * pRegisterSet) = 0; 111 112 virtual bool GetReturnAddressHijackInfo(MethodInfo * pMethodInfo, 113 REGDISPLAY * pRegisterSet, // in 114 PTR_PTR_VOID * ppvRetAddrLocation, // out 115 GCRefKind * pRetValueKind) = 0; // out 116 117 virtual void UnsynchronizedHijackMethodLoops(MethodInfo * pMethodInfo) = 0; 118 119 virtual PTR_VOID RemapHardwareFaultToGCSafePoint(MethodInfo * pMethodInfo, PTR_VOID controlPC) = 0; 120 121 virtual bool EHEnumInit(MethodInfo * pMethodInfo, PTR_VOID * pMethodStartAddress, EHEnumState * pEHEnumState) = 0; 122 123 virtual bool EHEnumNext(EHEnumState * pEHEnumState, EHClause * pEHClause) = 0; 124 125 virtual PTR_VOID GetMethodStartAddress(MethodInfo * pMethodInfo) = 0; 126 127 virtual PTR_VOID GetOsModuleHandle() = 0; 128 129 virtual void * GetClasslibFunction(ClasslibFunctionId functionId) = 0; 130 131 // Returns any custom data attached to the method. Format: 132 // AssociatedDataFlags // 1 byte. Flags describing the data stored 133 // Data (stream of bytes) // Variable size (depending on flags). Custom data associated with method 134 virtual PTR_VOID GetAssociatedData(PTR_VOID ControlPC) = 0; 135 }; 136