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.
8 * COM+99 EE to Debugger Interface Implementation
11 #ifndef _eedbginterfaceimpl_h_
12 #define _eedbginterfaceimpl_h_
14 #ifdef DEBUGGING_SUPPORTED
23 #include "jitinterface.h"
26 #include "eedbginterface.h"
27 #include "debugdebugger.h"
30 #include "corcompile.h"
31 #endif // FEATURE_PREJIT
36 class EEDbgInterfaceImpl : public EEDebugInterface
38 VPTR_VTABLE_CLASS_AND_CTOR(EEDbgInterfaceImpl, EEDebugInterface);
42 virtual ~EEDbgInterfaceImpl() {}
44 #ifndef DACCESS_COMPILE
47 // Setup and global data used by this interface.
49 static FORCEINLINE void Init(void)
51 g_pEEDbgInterfaceImpl = new EEDbgInterfaceImpl(); // new throws on failure
55 // Cleanup any global data used by this interface.
57 static void Terminate(void);
59 #endif // #ifndef DACCESS_COMPILE
61 Thread* GetThread(void);
63 void SetEEThreadPtr(VOID* newPtr);
65 StackWalkAction StackWalkFramesEx(Thread* pThread,
67 PSTACKWALKFRAMESCALLBACK pCallback,
71 Frame *GetFrame(CrawlFrame *pCF);
73 bool InitRegDisplay(Thread* pThread,
74 const PREGDISPLAY pRD,
75 const PT_CONTEXT pctx,
78 BOOL IsStringObject(Object* o);
80 BOOL IsTypedReference(MethodTable* pMT);
82 WCHAR* StringObjectGetBuffer(StringObject* so);
84 DWORD StringObjectGetStringLength(StringObject* so);
86 void* GetObjectFromHandle(OBJECTHANDLE handle);
88 OBJECTHANDLE GetHandleFromObject(void *obj,
90 AppDomain *pAppDomain);
92 void DbgDestroyHandle(OBJECTHANDLE oh,
95 OBJECTHANDLE GetThreadException(Thread *pThread);
97 bool IsThreadExceptionNull(Thread *pThread);
99 void ClearThreadException(Thread *pThread);
101 bool StartSuspendForDebug(AppDomain *pAppDomain,
102 BOOL fHoldingThreadStoreLock);
104 bool SweepThreadsForDebug(bool forceSync);
106 void ResumeFromDebug(AppDomain *pAppDomain);
108 void MarkThreadForDebugSuspend(Thread* pRuntimeThread);
110 void MarkThreadForDebugStepping(Thread* pRuntimeThread,
113 void SetThreadFilterContext(Thread *thread,
116 T_CONTEXT *GetThreadFilterContext(Thread *thread);
118 VOID *GetThreadDebuggerWord(Thread *thread);
120 void SetThreadDebuggerWord(Thread *thread,
123 BOOL IsManagedNativeCode(const BYTE *address);
125 MethodDesc *GetNativeCodeMethodDesc(const PCODE address) DAC_UNEXPECTED();
127 #ifndef USE_GC_INFO_DECODER
128 BOOL IsInPrologOrEpilog(const BYTE *address,
132 void DetermineIfOffsetsInFilterOrHandler(const BYTE *functionAddress,
133 DebugOffsetToHandlerInfo *pOffsetToHandlerInfo,
134 unsigned offsetToHandlerInfoLength);
136 void GetMethodRegionInfo(const PCODE pStart,
141 #if defined(WIN64EXCEPTIONS)
142 DWORD GetFuncletStartOffsets(const BYTE *pStart, DWORD* pStartOffsets, DWORD dwLength);
143 StackFrame FindParentStackFrame(CrawlFrame* pCF);
144 #endif // WIN64EXCEPTIONS
146 size_t GetFunctionSize(MethodDesc *pFD) DAC_UNEXPECTED();
148 const PCODE GetFunctionAddress(MethodDesc *pFD);
150 void DisablePreemptiveGC(void);
152 void EnablePreemptiveGC(void);
154 bool IsPreemptiveGCDisabled(void);
156 DWORD MethodDescIsStatic(MethodDesc *pFD);
158 Module *MethodDescGetModule(MethodDesc *pFD);
160 COR_ILMETHOD* MethodDescGetILHeader(MethodDesc *pFD);
162 ULONG MethodDescGetRVA(MethodDesc *pFD);
164 MethodDesc *FindLoadedMethodRefOrDef(Module* pModule,
167 MethodDesc *LoadMethodDef(Module* pModule,
168 mdMethodDef methodDef,
169 DWORD numGenericArgs = 0,
170 TypeHandle *pGenericArgs = NULL,
171 TypeHandle *pOwnerTypeRes = NULL);
173 TypeHandle FindLoadedClass(Module *pModule,
174 mdTypeDef classToken);
176 TypeHandle FindLoadedInstantiation(Module *pModule,
178 DWORD numGenericArgs,
179 TypeHandle *pGenericArgs);
181 TypeHandle FindLoadedFnptrType(TypeHandle *inst,
184 TypeHandle FindLoadedPointerOrByrefType(CorElementType et,
185 TypeHandle elemtype);
187 TypeHandle FindLoadedArrayType(CorElementType et,
191 TypeHandle FindLoadedElementType(CorElementType et);
193 TypeHandle LoadClass(Module *pModule,
194 mdTypeDef classToken);
196 TypeHandle LoadInstantiation(Module *pModule,
198 DWORD numGenericArgs,
199 TypeHandle *pGenericArgs);
201 TypeHandle LoadArrayType(CorElementType et,
205 TypeHandle LoadPointerOrByrefType(CorElementType et,
206 TypeHandle elemtype);
208 TypeHandle LoadFnptrType(TypeHandle *inst,
211 TypeHandle LoadElementType(CorElementType et);
214 HRESULT GetMethodImplProps(Module *pModule,
219 HRESULT GetParentToken(Module *pModule,
221 mdToken *pParentToken);
223 void MarkDebuggerAttached(void);
225 void MarkDebuggerUnattached(void);
229 // Apply an EnC edit to the specified module
230 // This function should never return.
231 HRESULT EnCApplyChanges(EditAndContinueModule *pModule,
237 // Remap execution to the latest version of an edited method
238 void ResumeInUpdatedFunction(EditAndContinueModule *pModule,
240 void *debuggerFuncHandle,
242 T_CONTEXT *pContext);
243 #endif // EnC_SUPPORTED
245 bool CrawlFrameIsGcSafe(CrawlFrame *pCF);
247 bool IsStub(const BYTE *ip);
249 bool DetectHandleILStubs(Thread *thread);
251 bool TraceStub(const BYTE *ip,
252 TraceDestination *trace);
254 bool FollowTrace(TraceDestination *trace);
256 bool TraceFrame(Thread *thread,
259 TraceDestination *trace,
262 bool TraceManager(Thread *thread,
263 StubManager *stubManager,
264 TraceDestination *trace,
268 void EnableTraceCall(Thread *thread);
270 void DisableTraceCall(Thread *thread);
272 void GetRuntimeOffsets(SIZE_T *pTLSIndex,
273 SIZE_T *pTLSIsSpecialIndex,
274 SIZE_T *pTLSCantStopIndex,
275 SIZE_T *pEEThreadStateOffset,
276 SIZE_T *pEEThreadStateNCOffset,
277 SIZE_T *pEEThreadPGCDisabledOffset,
278 DWORD *pEEThreadPGCDisabledValue,
279 SIZE_T *pEEThreadDebuggerWordOffset,
280 SIZE_T *pEEThreadFrameOffset,
281 SIZE_T *pEEThreadMaxNeededSize,
282 DWORD *pEEThreadSteppingStateMask,
283 DWORD *pEEMaxFrameValue,
284 SIZE_T *pEEThreadDebuggerFilterContextOffset,
285 SIZE_T *pEEThreadCantStopOffset,
286 SIZE_T *pEEFrameNextOffset,
287 DWORD *pEEIsManagedExceptionStateMask);
289 void DebuggerModifyingLogSwitch (int iNewLevel,
290 const WCHAR *pLogSwitchName);
292 HRESULT SetIPFromSrcToDst(Thread *pThread,
302 void SetDebugState(Thread *pThread,
303 CorDebugThreadState state);
305 void SetAllDebugState(Thread *et,
306 CorDebugThreadState state);
308 // This is pretty much copied from VM\COMSynchronizable's
309 // INT32 __stdcall ThreadNative::GetThreadState, so propogate changes
311 CorDebugUserState GetPartialUserState( Thread *pThread );
313 #ifdef FEATURE_PREJIT
314 #ifndef DACCESS_COMPILE
315 virtual void SetNGENDebugFlags(BOOL fAllowOpt)
317 LIMITED_METHOD_CONTRACT;
318 PEFile::SetNGENDebugFlags(fAllowOpt);
321 virtual void GetNGENDebugFlags(BOOL *fAllowOpt)
323 LIMITED_METHOD_CONTRACT;
324 PEFile::GetNGENDebugFlags(fAllowOpt);
327 #endif // FEATURE_PREJIT
329 #ifdef DACCESS_COMPILE
330 virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags);
333 virtual unsigned GetSizeForCorElementType(CorElementType etyp);
335 #ifndef DACCESS_COMPILE
336 virtual BOOL ObjIsInstanceOf(Object *pElement, TypeHandle toTypeHnd);
339 virtual void ClearAllDebugInterfaceReferences(void);
341 #ifndef DACCESS_COMPILE
343 virtual void ObjectRefFlush(Thread *pThread);
348 #endif // DEBUGGING_SUPPORTED
350 #endif // _eedbginterfaceimpl_h_