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 StackWalkAction StackWalkFramesEx(Thread* pThread,
79 PSTACKWALKFRAMESCALLBACK pCallback,
81 unsigned int flags) = 0;
83 virtual Frame *GetFrame(CrawlFrame*) = 0;
85 virtual bool InitRegDisplay(Thread* pThread,
86 const PREGDISPLAY pRD,
87 const PT_CONTEXT pctx,
88 bool validContext) = 0;
90 virtual BOOL IsStringObject(Object* o) = 0;
92 virtual BOOL IsTypedReference(MethodTable* pMT) = 0;
94 virtual WCHAR* StringObjectGetBuffer(StringObject* so) = 0;
96 virtual DWORD StringObjectGetStringLength(StringObject* so) = 0;
98 virtual void *GetObjectFromHandle(OBJECTHANDLE handle) = 0;
100 virtual OBJECTHANDLE GetHandleFromObject(void *obj,
102 AppDomain *pAppDomain) = 0;
104 virtual void DbgDestroyHandle( OBJECTHANDLE oh, bool fStrongNewRef ) = 0;
106 virtual OBJECTHANDLE GetThreadException(Thread *pThread) = 0;
108 virtual bool IsThreadExceptionNull(Thread *pThread) = 0;
110 virtual void ClearThreadException(Thread *pThread) = 0;
112 virtual bool StartSuspendForDebug(AppDomain *pAppDomain,
113 BOOL fHoldingThreadStoreLock = FALSE) = 0;
115 virtual void ResumeFromDebug(AppDomain *pAppDomain)= 0;
117 virtual void MarkThreadForDebugSuspend(Thread* pRuntimeThread) = 0;
119 virtual void MarkThreadForDebugStepping(Thread* pRuntimeThread,
122 virtual void SetThreadFilterContext(Thread *thread,
123 T_CONTEXT *context) = 0;
125 virtual T_CONTEXT *GetThreadFilterContext(Thread *thread) = 0;
127 #ifdef FEATURE_INTEROP_DEBUGGING
128 virtual VOID *GetThreadDebuggerWord() = 0;
130 virtual void SetThreadDebuggerWord(VOID *dw) = 0;
133 virtual BOOL IsManagedNativeCode(const BYTE *address) = 0;
135 #endif // #ifndef DACCESS_COMPILE
137 virtual PCODE GetNativeCodeStartAddress(PCODE address) = 0;
139 virtual MethodDesc *GetNativeCodeMethodDesc(const PCODE address) = 0;
141 #ifndef DACCESS_COMPILE
143 #ifndef USE_GC_INFO_DECODER
144 virtual BOOL IsInPrologOrEpilog(const BYTE *address,
145 size_t* prologSize) = 0;
148 // Determine whether certain native offsets of the specified function are within
149 // an exception filter or handler.
150 virtual void DetermineIfOffsetsInFilterOrHandler(const BYTE *functionAddress,
151 DebugOffsetToHandlerInfo *pOffsetToHandlerInfo,
152 unsigned offsetToHandlerInfoLength) = 0;
154 #endif // #ifndef DACCESS_COMPILE
156 virtual void GetMethodRegionInfo(const PCODE pStart,
159 size_t * coldSize) = 0;
161 #if defined(WIN64EXCEPTIONS)
162 virtual DWORD GetFuncletStartOffsets(const BYTE *pStart, DWORD* pStartOffsets, DWORD dwLength) = 0;
163 virtual StackFrame FindParentStackFrame(CrawlFrame* pCF) = 0;
164 #endif // WIN64EXCEPTIONS
166 virtual size_t GetFunctionSize(MethodDesc *pFD) = 0;
168 virtual const PCODE GetFunctionAddress(MethodDesc *pFD) = 0;
170 #ifndef DACCESS_COMPILE
175 virtual HRESULT EnCApplyChanges(EditAndContinueModule *pModule,
181 // Perform an EnC remap to resume execution in the new version of a method (doesn't return)
182 virtual void ResumeInUpdatedFunction(EditAndContinueModule *pModule,
184 void *debuggerFuncHandle,
186 CONTEXT *pContext) = 0;
187 #endif //EnC_SUPPORTED
190 // New methods to support the new debugger.
193 virtual MethodDesc *FindLoadedMethodRefOrDef(Module* pModule,
194 mdMemberRef memberRef) = 0;
196 virtual MethodDesc *LoadMethodDef(Module* pModule,
197 mdMethodDef methodDef,
198 DWORD numGenericArgs = 0,
199 TypeHandle *pGenericArgs = NULL,
200 TypeHandle *pOwnerType = NULL) = 0;
202 // These will lookup a type, and if it's not loaded, return the null TypeHandle
203 virtual TypeHandle FindLoadedClass(Module *pModule,
204 mdTypeDef classToken) = 0;
206 virtual TypeHandle FindLoadedElementType(CorElementType et) = 0;
208 virtual TypeHandle FindLoadedInstantiation(Module *pModule,
211 TypeHandle *inst) = 0;
213 virtual TypeHandle FindLoadedFnptrType(TypeHandle *inst,
216 virtual TypeHandle FindLoadedPointerOrByrefType(CorElementType et,
217 TypeHandle elemtype) = 0;
219 virtual TypeHandle FindLoadedArrayType(CorElementType et,
223 // These will lookup a type, and if it's not loaded, will load and run
224 // the class init etc.
225 virtual TypeHandle LoadClass(Module *pModule,
226 mdTypeDef classToken) = 0;
228 virtual TypeHandle LoadElementType(CorElementType et) = 0;
230 virtual TypeHandle LoadInstantiation(Module *pModule,
233 TypeHandle *inst) = 0;
235 virtual TypeHandle LoadFnptrType(TypeHandle *inst,
238 virtual TypeHandle LoadPointerOrByrefType(CorElementType et,
239 TypeHandle elemtype) = 0;
241 virtual TypeHandle LoadArrayType(CorElementType et,
246 virtual HRESULT GetMethodImplProps(Module *pModule,
249 DWORD *pImplFlags) = 0;
251 virtual HRESULT GetParentToken(Module *pModule,
253 mdToken *pParentToken) = 0;
255 virtual bool IsPreemptiveGCDisabled(void) = 0;
257 virtual void DisablePreemptiveGC(void) = 0;
259 virtual void EnablePreemptiveGC(void) = 0;
261 virtual DWORD MethodDescIsStatic(MethodDesc *pFD) = 0;
263 #endif // #ifndef DACCESS_COMPILE
265 virtual Module *MethodDescGetModule(MethodDesc *pFD) = 0;
267 #ifndef DACCESS_COMPILE
269 virtual COR_ILMETHOD* MethodDescGetILHeader(MethodDesc *pFD) = 0;
271 virtual ULONG MethodDescGetRVA(MethodDesc *pFD) = 0;
273 virtual void MarkDebuggerAttached(void) = 0;
275 virtual void MarkDebuggerUnattached(void) = 0;
277 virtual bool CrawlFrameIsGcSafe(CrawlFrame *pCF) = 0;
279 virtual bool SweepThreadsForDebug(bool forceSync) = 0;
281 virtual void GetRuntimeOffsets(SIZE_T *pTLSIndex,
282 SIZE_T *pTLSIsSpecialIndex,
283 SIZE_T *pTLSCantStopIndex,
284 SIZE_T *pEEThreadStateOffset,
285 SIZE_T *pEEThreadStateNCOffset,
286 SIZE_T *pEEThreadPGCDisabledOffset,
287 DWORD *pEEThreadPGCDisabledValue,
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_