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 StackWalkAction StackWalkFramesEx(Thread* pThread,
65 PSTACKWALKFRAMESCALLBACK pCallback,
69 Frame *GetFrame(CrawlFrame *pCF);
71 bool InitRegDisplay(Thread* pThread,
72 const PREGDISPLAY pRD,
73 const PT_CONTEXT pctx,
76 BOOL IsStringObject(Object* o);
78 BOOL IsTypedReference(MethodTable* pMT);
80 WCHAR* StringObjectGetBuffer(StringObject* so);
82 DWORD StringObjectGetStringLength(StringObject* so);
84 void* GetObjectFromHandle(OBJECTHANDLE handle);
86 OBJECTHANDLE GetHandleFromObject(void *obj,
88 AppDomain *pAppDomain);
90 void DbgDestroyHandle(OBJECTHANDLE oh,
93 OBJECTHANDLE GetThreadException(Thread *pThread);
95 bool IsThreadExceptionNull(Thread *pThread);
97 void ClearThreadException(Thread *pThread);
99 bool StartSuspendForDebug(AppDomain *pAppDomain,
100 BOOL fHoldingThreadStoreLock);
102 bool SweepThreadsForDebug(bool forceSync);
104 void ResumeFromDebug(AppDomain *pAppDomain);
106 void MarkThreadForDebugSuspend(Thread* pRuntimeThread);
108 void MarkThreadForDebugStepping(Thread* pRuntimeThread,
111 void SetThreadFilterContext(Thread *thread,
114 T_CONTEXT *GetThreadFilterContext(Thread *thread);
116 #ifdef FEATURE_INTEROP_DEBUGGING
117 VOID *GetThreadDebuggerWord();
119 VOID SetThreadDebuggerWord(VOID *dw);
122 BOOL IsManagedNativeCode(const BYTE *address);
124 PCODE GetNativeCodeStartAddress(PCODE address) DAC_UNEXPECTED();
126 MethodDesc *GetNativeCodeMethodDesc(const PCODE address) DAC_UNEXPECTED();
128 #ifndef USE_GC_INFO_DECODER
129 BOOL IsInPrologOrEpilog(const BYTE *address,
133 void DetermineIfOffsetsInFilterOrHandler(const BYTE *functionAddress,
134 DebugOffsetToHandlerInfo *pOffsetToHandlerInfo,
135 unsigned offsetToHandlerInfoLength);
137 void GetMethodRegionInfo(const PCODE pStart,
142 #if defined(WIN64EXCEPTIONS)
143 DWORD GetFuncletStartOffsets(const BYTE *pStart, DWORD* pStartOffsets, DWORD dwLength);
144 StackFrame FindParentStackFrame(CrawlFrame* pCF);
145 #endif // WIN64EXCEPTIONS
147 size_t GetFunctionSize(MethodDesc *pFD) DAC_UNEXPECTED();
149 const PCODE GetFunctionAddress(MethodDesc *pFD);
151 void DisablePreemptiveGC(void);
153 void EnablePreemptiveGC(void);
155 bool IsPreemptiveGCDisabled(void);
157 DWORD MethodDescIsStatic(MethodDesc *pFD);
159 Module *MethodDescGetModule(MethodDesc *pFD);
161 COR_ILMETHOD* MethodDescGetILHeader(MethodDesc *pFD);
163 ULONG MethodDescGetRVA(MethodDesc *pFD);
165 MethodDesc *FindLoadedMethodRefOrDef(Module* pModule,
168 MethodDesc *LoadMethodDef(Module* pModule,
169 mdMethodDef methodDef,
170 DWORD numGenericArgs = 0,
171 TypeHandle *pGenericArgs = NULL,
172 TypeHandle *pOwnerTypeRes = NULL);
174 TypeHandle FindLoadedClass(Module *pModule,
175 mdTypeDef classToken);
177 TypeHandle FindLoadedInstantiation(Module *pModule,
179 DWORD numGenericArgs,
180 TypeHandle *pGenericArgs);
182 TypeHandle FindLoadedFnptrType(TypeHandle *inst,
185 TypeHandle FindLoadedPointerOrByrefType(CorElementType et,
186 TypeHandle elemtype);
188 TypeHandle FindLoadedArrayType(CorElementType et,
192 TypeHandle FindLoadedElementType(CorElementType et);
194 TypeHandle LoadClass(Module *pModule,
195 mdTypeDef classToken);
197 TypeHandle LoadInstantiation(Module *pModule,
199 DWORD numGenericArgs,
200 TypeHandle *pGenericArgs);
202 TypeHandle LoadArrayType(CorElementType et,
206 TypeHandle LoadPointerOrByrefType(CorElementType et,
207 TypeHandle elemtype);
209 TypeHandle LoadFnptrType(TypeHandle *inst,
212 TypeHandle LoadElementType(CorElementType et);
215 HRESULT GetMethodImplProps(Module *pModule,
220 HRESULT GetParentToken(Module *pModule,
222 mdToken *pParentToken);
224 void MarkDebuggerAttached(void);
226 void MarkDebuggerUnattached(void);
230 // Apply an EnC edit to the specified module
231 // This function should never return.
232 HRESULT EnCApplyChanges(EditAndContinueModule *pModule,
238 // Remap execution to the latest version of an edited method
239 void ResumeInUpdatedFunction(EditAndContinueModule *pModule,
241 void *debuggerFuncHandle,
243 T_CONTEXT *pContext);
244 #endif // EnC_SUPPORTED
246 bool CrawlFrameIsGcSafe(CrawlFrame *pCF);
248 bool IsStub(const BYTE *ip);
250 bool DetectHandleILStubs(Thread *thread);
252 bool TraceStub(const BYTE *ip,
253 TraceDestination *trace);
255 bool FollowTrace(TraceDestination *trace);
257 bool TraceFrame(Thread *thread,
260 TraceDestination *trace,
263 bool TraceManager(Thread *thread,
264 StubManager *stubManager,
265 TraceDestination *trace,
269 void EnableTraceCall(Thread *thread);
271 void DisableTraceCall(Thread *thread);
273 void GetRuntimeOffsets(SIZE_T *pTLSIndex,
274 SIZE_T *pTLSIsSpecialIndex,
275 SIZE_T *pTLSCantStopIndex,
276 SIZE_T *pEEThreadStateOffset,
277 SIZE_T *pEEThreadStateNCOffset,
278 SIZE_T *pEEThreadPGCDisabledOffset,
279 DWORD *pEEThreadPGCDisabledValue,
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_