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.
5 // COM+99 EE to Debugger Interface Header
10 #ifndef _eedbginterface_h_
11 #define _eedbginterface_h_
20 #include "stackwalk.h"
27 #include "../debug/inc/common.h"
32 // The purpose of this object is to provide EE funcationality back to
33 // the debugger. This represents the entire set of EE functions used
36 // We will make this interface smaller over time to minimize the link
37 // between the EE and the Debugger.
40 typedef BOOL (*HashMapEnumCallback)(HashMap* h,
44 typedef enum AttachAppDomainEventsEnum
46 ONLY_SEND_APP_DOMAIN_CREATE_EVENTS,
47 DONT_SEND_CLASS_EVENTS,
48 ONLY_SEND_CLASS_EVENTS
49 } AttachAppDomainEventsEnum;
51 typedef VPTR(class EEDebugInterface) PTR_EEDebugInterface;
53 // Used for communicating EH Handler info between the LS and EE (DetermineIfOffsetsInFilterOrHandler)
54 struct DebugOffsetToHandlerInfo
56 // Native offset of interest, or -1 if this entry should be ignored
59 // Set to true by the EE if the specified native offset is in an EH filter or handler.
60 BOOL isInFilterOrHandler;
63 class EEDebugInterface
65 VPTR_BASE_VTABLE_CLASS_AND_CTOR(EEDebugInterface);
70 // Functions exported from the EE to the debugger.
73 virtual Thread* GetThread(void) = 0;
75 #ifndef DACCESS_COMPILE
77 virtual void SetEEThreadPtr(VOID* newPtr) = 0;
79 virtual StackWalkAction StackWalkFramesEx(Thread* pThread,
81 PSTACKWALKFRAMESCALLBACK pCallback,
83 unsigned int flags) = 0;
85 virtual Frame *GetFrame(CrawlFrame*) = 0;
87 virtual bool InitRegDisplay(Thread* pThread,
88 const PREGDISPLAY pRD,
89 const PT_CONTEXT pctx,
90 bool validContext) = 0;
92 virtual BOOL IsStringObject(Object* o) = 0;
94 virtual BOOL IsTypedReference(MethodTable* pMT) = 0;
96 virtual WCHAR* StringObjectGetBuffer(StringObject* so) = 0;
98 virtual DWORD StringObjectGetStringLength(StringObject* so) = 0;
100 virtual void *GetObjectFromHandle(OBJECTHANDLE handle) = 0;
102 virtual OBJECTHANDLE GetHandleFromObject(void *obj,
104 AppDomain *pAppDomain) = 0;
106 virtual void DbgDestroyHandle( OBJECTHANDLE oh, bool fStrongNewRef ) = 0;
108 virtual OBJECTHANDLE GetThreadException(Thread *pThread) = 0;
110 virtual bool IsThreadExceptionNull(Thread *pThread) = 0;
112 virtual void ClearThreadException(Thread *pThread) = 0;
114 virtual bool StartSuspendForDebug(AppDomain *pAppDomain,
115 BOOL fHoldingThreadStoreLock = FALSE) = 0;
117 virtual void ResumeFromDebug(AppDomain *pAppDomain)= 0;
119 virtual void MarkThreadForDebugSuspend(Thread* pRuntimeThread) = 0;
121 virtual void MarkThreadForDebugStepping(Thread* pRuntimeThread,
124 virtual void SetThreadFilterContext(Thread *thread,
125 T_CONTEXT *context) = 0;
127 virtual T_CONTEXT *GetThreadFilterContext(Thread *thread) = 0;
129 virtual VOID *GetThreadDebuggerWord(Thread *thread) = 0;
131 virtual void SetThreadDebuggerWord(Thread *thread,
134 virtual BOOL IsManagedNativeCode(const BYTE *address) = 0;
136 #endif // #ifndef DACCESS_COMPILE
138 virtual MethodDesc *GetNativeCodeMethodDesc(const PCODE address) = 0;
140 #ifndef DACCESS_COMPILE
142 #ifndef USE_GC_INFO_DECODER
143 virtual BOOL IsInPrologOrEpilog(const BYTE *address,
144 size_t* prologSize) = 0;
147 // Determine whether certain native offsets of the specified function are within
148 // an exception filter or handler.
149 virtual void DetermineIfOffsetsInFilterOrHandler(const BYTE *functionAddress,
150 DebugOffsetToHandlerInfo *pOffsetToHandlerInfo,
151 unsigned offsetToHandlerInfoLength) = 0;
153 #endif // #ifndef DACCESS_COMPILE
155 virtual void GetMethodRegionInfo(const PCODE pStart,
158 size_t * coldSize) = 0;
160 #if defined(WIN64EXCEPTIONS)
161 virtual DWORD GetFuncletStartOffsets(const BYTE *pStart, DWORD* pStartOffsets, DWORD dwLength) = 0;
162 virtual StackFrame FindParentStackFrame(CrawlFrame* pCF) = 0;
163 #endif // WIN64EXCEPTIONS
165 virtual size_t GetFunctionSize(MethodDesc *pFD) = 0;
167 virtual const PCODE GetFunctionAddress(MethodDesc *pFD) = 0;
169 #ifndef DACCESS_COMPILE
174 virtual HRESULT EnCApplyChanges(EditAndContinueModule *pModule,
180 // Perform an EnC remap to resume execution in the new version of a method (doesn't return)
181 virtual void ResumeInUpdatedFunction(EditAndContinueModule *pModule,
183 void *debuggerFuncHandle,
185 CONTEXT *pContext) = 0;
186 #endif //EnC_SUPPORTED
189 // New methods to support the new debugger.
192 virtual MethodDesc *FindLoadedMethodRefOrDef(Module* pModule,
193 mdMemberRef memberRef) = 0;
195 virtual MethodDesc *LoadMethodDef(Module* pModule,
196 mdMethodDef methodDef,
197 DWORD numGenericArgs = 0,
198 TypeHandle *pGenericArgs = NULL,
199 TypeHandle *pOwnerType = NULL) = 0;
201 // These will lookup a type, and if it's not loaded, return the null TypeHandle
202 virtual TypeHandle FindLoadedClass(Module *pModule,
203 mdTypeDef classToken) = 0;
205 virtual TypeHandle FindLoadedElementType(CorElementType et) = 0;
207 virtual TypeHandle FindLoadedInstantiation(Module *pModule,
210 TypeHandle *inst) = 0;
212 virtual TypeHandle FindLoadedFnptrType(TypeHandle *inst,
215 virtual TypeHandle FindLoadedPointerOrByrefType(CorElementType et,
216 TypeHandle elemtype) = 0;
218 virtual TypeHandle FindLoadedArrayType(CorElementType et,
222 // These will lookup a type, and if it's not loaded, will load and run
223 // the class init etc.
224 virtual TypeHandle LoadClass(Module *pModule,
225 mdTypeDef classToken) = 0;
227 virtual TypeHandle LoadElementType(CorElementType et) = 0;
229 virtual TypeHandle LoadInstantiation(Module *pModule,
232 TypeHandle *inst) = 0;
234 virtual TypeHandle LoadFnptrType(TypeHandle *inst,
237 virtual TypeHandle LoadPointerOrByrefType(CorElementType et,
238 TypeHandle elemtype) = 0;
240 virtual TypeHandle LoadArrayType(CorElementType et,
245 virtual HRESULT GetMethodImplProps(Module *pModule,
248 DWORD *pImplFlags) = 0;
250 virtual HRESULT GetParentToken(Module *pModule,
252 mdToken *pParentToken) = 0;
254 virtual bool IsPreemptiveGCDisabled(void) = 0;
256 virtual void DisablePreemptiveGC(void) = 0;
258 virtual void EnablePreemptiveGC(void) = 0;
260 virtual DWORD MethodDescIsStatic(MethodDesc *pFD) = 0;
262 #endif // #ifndef DACCESS_COMPILE
264 virtual Module *MethodDescGetModule(MethodDesc *pFD) = 0;
266 #ifndef DACCESS_COMPILE
268 virtual COR_ILMETHOD* MethodDescGetILHeader(MethodDesc *pFD) = 0;
270 virtual ULONG MethodDescGetRVA(MethodDesc *pFD) = 0;
272 virtual void MarkDebuggerAttached(void) = 0;
274 virtual void MarkDebuggerUnattached(void) = 0;
276 virtual bool CrawlFrameIsGcSafe(CrawlFrame *pCF) = 0;
278 virtual bool SweepThreadsForDebug(bool forceSync) = 0;
280 virtual void GetRuntimeOffsets(SIZE_T *pTLSIndex,
281 SIZE_T *pTLSIsSpecialIndex,
282 SIZE_T *pTLSCantStopIndex,
283 SIZE_T *pEEThreadStateOffset,
284 SIZE_T *pEEThreadStateNCOffset,
285 SIZE_T *pEEThreadPGCDisabledOffset,
286 DWORD *pEEThreadPGCDisabledValue,
287 SIZE_T *pEEThreadDebuggerWordOffset,
288 SIZE_T *pEEThreadFrameOffset,
289 SIZE_T *pEEThreadMaxNeededSize,
290 DWORD *pEEThreadSteppingStateMask,
291 DWORD *pEEMaxFrameValue,
292 SIZE_T *pEEThreadDebuggerFilterContextOffset,
293 SIZE_T *pEEThreadCantStopMask,
294 SIZE_T *pEEFrameNextOffset,
295 DWORD *pEEIsManagedExceptionStateMask) = 0;
297 virtual bool IsStub(const BYTE *ip) = 0;
299 #endif // #ifndef DACCESS_COMPILE
301 virtual bool DetectHandleILStubs(Thread *thread) = 0;
303 virtual bool TraceStub(const BYTE *ip, TraceDestination *trace) = 0;
305 #ifndef DACCESS_COMPILE
307 virtual bool FollowTrace(TraceDestination *trace) = 0;
309 virtual bool TraceFrame(Thread *thread,
312 TraceDestination *trace,
313 REGDISPLAY *regs) = 0;
315 virtual bool TraceManager(Thread *thread,
316 StubManager *stubManager,
317 TraceDestination *trace,
319 BYTE **pRetAddr) = 0;
321 virtual void EnableTraceCall(Thread *thread) = 0;
322 virtual void DisableTraceCall(Thread *thread) = 0;
324 #endif // #ifndef DACCESS_COMPILE
326 #ifndef DACCESS_COMPILE
328 virtual void DebuggerModifyingLogSwitch (int iNewLevel,
329 const WCHAR *pLogSwitchName) = 0;
331 virtual HRESULT SetIPFromSrcToDst(Thread *pThread,
339 EHRangeTree *pEHRT) = 0;
341 virtual void SetDebugState(Thread *pThread,
342 CorDebugThreadState state) = 0;
344 virtual void SetAllDebugState(Thread *et,
345 CorDebugThreadState state) = 0;
347 virtual CorDebugUserState GetPartialUserState( Thread *pThread ) = 0;
349 #ifdef FEATURE_PREJIT
350 #ifndef DACCESS_COMPILE
351 virtual void SetNGENDebugFlags(BOOL fAllowOpt) = 0;
353 virtual void GetNGENDebugFlags(BOOL *fAllowOpt) = 0;
355 #endif // FEATURE_PREJIT
357 #endif // #ifndef DACCESS_COMPILE
359 #ifdef DACCESS_COMPILE
360 virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) = 0;
363 virtual unsigned GetSizeForCorElementType(CorElementType etyp) = 0;
365 #ifndef DACCESS_COMPILE
366 virtual BOOL ObjIsInstanceOf(Object *pElement, TypeHandle toTypeHnd) = 0;
369 virtual void ClearAllDebugInterfaceReferences(void) = 0;
371 #ifndef DACCESS_COMPILE
373 virtual void ObjectRefFlush(Thread *pThread) = 0;
378 #endif // _eedbginterface_h_