summaryrefslogtreecommitdiff
path: root/src/vm/eedbginterface.h
blob: f25884e0013cbb141c1a8fdb21be453b45e0bdea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// COM+99 EE to Debugger Interface Header
//



#ifndef _eedbginterface_h_
#define _eedbginterface_h_

#include "common.h"
#include "corpriv.h"
#include "hash.h"
#include "class.h"
#include "excep.h"
#include "threads.h"
#include "field.h"
#include "stackwalk.h"

#ifdef EnC_SUPPORTED
#include "encee.h"
#endif

#include "cordebug.h"
#include "../debug/inc/common.h"

class MethodDesc;
class Frame;
//
// The purpose of this object is to provide EE funcationality back to
// the debugger. This represents the entire set of EE functions used
// by the debugger.
//
// We will make this interface smaller over time to minimize the link
// between the EE and the Debugger.
//  
//
typedef BOOL (*HashMapEnumCallback)(HashMap* h,
                                    void* pData,
                                    ULONG value);

typedef enum AttachAppDomainEventsEnum
{
    ONLY_SEND_APP_DOMAIN_CREATE_EVENTS,
    DONT_SEND_CLASS_EVENTS,
    ONLY_SEND_CLASS_EVENTS
} AttachAppDomainEventsEnum;

typedef VPTR(class EEDebugInterface) PTR_EEDebugInterface;

// Used for communicating EH Handler info between the LS and EE (DetermineIfOffsetsInFilterOrHandler)
struct DebugOffsetToHandlerInfo 
{
    // Native offset of interest, or -1 if this entry should be ignored
    SIZE_T offset;

    // Set to true by the EE if the specified native offset is in an EH filter or handler.
    BOOL isInFilterOrHandler;
};

class EEDebugInterface
{
    VPTR_BASE_VTABLE_CLASS_AND_CTOR(EEDebugInterface);

public:

    //
    // Functions exported from the EE to the debugger.
    //

    virtual Thread* GetThread(void) = 0;

#ifndef DACCESS_COMPILE

    virtual StackWalkAction StackWalkFramesEx(Thread* pThread,
                                              PREGDISPLAY pRD,
                                              PSTACKWALKFRAMESCALLBACK pCallback,
                                              VOID* pData,
                                              unsigned int flags) = 0;

    virtual Frame *GetFrame(CrawlFrame*) = 0;

    virtual bool InitRegDisplay(Thread* pThread,
                                const PREGDISPLAY pRD,
                                const PT_CONTEXT pctx,
                                bool validContext) = 0;

    virtual BOOL IsStringObject(Object* o) = 0;

    virtual BOOL IsTypedReference(MethodTable* pMT) = 0;

    virtual WCHAR* StringObjectGetBuffer(StringObject* so) = 0;

    virtual DWORD StringObjectGetStringLength(StringObject* so) = 0;

    virtual void *GetObjectFromHandle(OBJECTHANDLE handle) = 0;

    virtual OBJECTHANDLE GetHandleFromObject(void *obj,
                                      bool fStrongNewRef,
                                      AppDomain *pAppDomain) = 0;

    virtual void DbgDestroyHandle( OBJECTHANDLE oh, bool fStrongNewRef ) = 0;

    virtual OBJECTHANDLE GetThreadException(Thread *pThread) = 0;

    virtual bool IsThreadExceptionNull(Thread *pThread) = 0;

    virtual void ClearThreadException(Thread *pThread) = 0;

    virtual bool StartSuspendForDebug(AppDomain *pAppDomain,
                                      BOOL fHoldingThreadStoreLock = FALSE) = 0;

    virtual void ResumeFromDebug(AppDomain *pAppDomain)= 0;

    virtual void MarkThreadForDebugSuspend(Thread* pRuntimeThread) = 0;

    virtual void MarkThreadForDebugStepping(Thread* pRuntimeThread,
                                            bool onOff) = 0;

    virtual void SetThreadFilterContext(Thread *thread,
                                        T_CONTEXT *context) = 0;

    virtual T_CONTEXT *GetThreadFilterContext(Thread *thread) = 0;

#ifdef FEATURE_INTEROP_DEBUGGING
    virtual VOID *GetThreadDebuggerWord() = 0;

    virtual void SetThreadDebuggerWord(VOID *dw) = 0;
#endif

    virtual BOOL IsManagedNativeCode(const BYTE *address) = 0;

#endif // #ifndef DACCESS_COMPILE

    virtual PCODE GetNativeCodeStartAddress(PCODE address) = 0;

    virtual MethodDesc *GetNativeCodeMethodDesc(const PCODE address) = 0;

#ifndef DACCESS_COMPILE

#ifndef USE_GC_INFO_DECODER
    virtual BOOL IsInPrologOrEpilog(const BYTE *address,
                                    size_t* prologSize) = 0;
#endif

    // Determine whether certain native offsets of the specified function are within
    // an exception filter or handler.
    virtual void DetermineIfOffsetsInFilterOrHandler(const BYTE *functionAddress,
                                                          DebugOffsetToHandlerInfo *pOffsetToHandlerInfo,
                                                          unsigned offsetToHandlerInfoLength) = 0;

#endif // #ifndef DACCESS_COMPILE

    virtual void GetMethodRegionInfo(const PCODE    pStart, 
                                           PCODE  * pCold, 
                                           size_t * hotSize, 
                                           size_t * coldSize) = 0;

#if defined(WIN64EXCEPTIONS)
    virtual DWORD GetFuncletStartOffsets(const BYTE *pStart, DWORD* pStartOffsets, DWORD dwLength) = 0;
    virtual StackFrame FindParentStackFrame(CrawlFrame* pCF) = 0;
#endif // WIN64EXCEPTIONS

    virtual size_t GetFunctionSize(MethodDesc *pFD) = 0;

    virtual PCODE GetFunctionAddress(MethodDesc *pFD) = 0;

#ifndef DACCESS_COMPILE

#ifdef EnC_SUPPORTED

    // Apply an EnC edit
    virtual HRESULT EnCApplyChanges(EditAndContinueModule *pModule,
                                    DWORD cbMetadata,
                                    BYTE *pMetadata,
                                    DWORD cbIL,
                                    BYTE *pIL) = 0;

    // Perform an EnC remap to resume execution in the new version of a method (doesn't return)
    virtual void ResumeInUpdatedFunction(EditAndContinueModule *pModule,
                                         MethodDesc *pFD,
                                         void *debuggerFuncHandle,
                                         SIZE_T resumeIP,
                                         CONTEXT *pContext) = 0;
#endif //EnC_SUPPORTED

    //
    // New methods to support the new debugger.
    //

    virtual MethodDesc *FindLoadedMethodRefOrDef(Module* pModule,
                                                   mdMemberRef memberRef) = 0;

    virtual MethodDesc *LoadMethodDef(Module* pModule,
                                      mdMethodDef methodDef,
                                      DWORD numGenericArgs = 0,
                                      TypeHandle *pGenericArgs = NULL,
                                      TypeHandle *pOwnerType = NULL) = 0;

    // These will lookup a type, and if it's not loaded, return the null TypeHandle
    virtual TypeHandle FindLoadedClass(Module *pModule,
                                     mdTypeDef classToken) = 0;

    virtual TypeHandle FindLoadedElementType(CorElementType et) = 0;

    virtual TypeHandle FindLoadedInstantiation(Module *pModule,
                                               mdTypeDef typeDef,
                                               DWORD ntypars,
                                               TypeHandle *inst) = 0;

    virtual TypeHandle FindLoadedFnptrType(TypeHandle *inst,
                                           DWORD ntypars) = 0;

    virtual TypeHandle FindLoadedPointerOrByrefType(CorElementType et,
                                                    TypeHandle elemtype) = 0;

    virtual TypeHandle FindLoadedArrayType(CorElementType et,
                                           TypeHandle elemtype,
                                           unsigned rank) = 0;

    // These will lookup a type, and if it's not loaded, will load and run
    // the class init etc.
    virtual TypeHandle LoadClass(Module *pModule,
                               mdTypeDef classToken) = 0;

    virtual TypeHandle LoadElementType(CorElementType et) = 0;

    virtual TypeHandle LoadInstantiation(Module *pModule,
                                         mdTypeDef typeDef,
                                         DWORD ntypars,
                                         TypeHandle *inst) = 0;

    virtual TypeHandle LoadFnptrType(TypeHandle *inst,
                                     DWORD ntypars) = 0;

    virtual TypeHandle LoadPointerOrByrefType(CorElementType et,
                                              TypeHandle elemtype) = 0;

    virtual TypeHandle LoadArrayType(CorElementType et,
                                     TypeHandle elemtype,
                                     unsigned rank) = 0;
    
    __checkReturn 
    virtual HRESULT GetMethodImplProps(Module *pModule,
                                       mdToken tk,
                                       DWORD *pRVA,
                                       DWORD *pImplFlags) = 0;

    virtual HRESULT GetParentToken(Module *pModule,
                                   mdToken tk,
                                   mdToken *pParentToken) = 0;

    virtual bool IsPreemptiveGCDisabled(void) = 0;

    virtual void DisablePreemptiveGC(void) = 0;

    virtual void EnablePreemptiveGC(void) = 0;

    virtual DWORD MethodDescIsStatic(MethodDesc *pFD) = 0;

#endif // #ifndef DACCESS_COMPILE

    virtual Module *MethodDescGetModule(MethodDesc *pFD) = 0;

#ifndef DACCESS_COMPILE

    virtual COR_ILMETHOD* MethodDescGetILHeader(MethodDesc *pFD) = 0;

    virtual ULONG MethodDescGetRVA(MethodDesc *pFD) = 0;

    virtual void MarkDebuggerAttached(void) = 0;

    virtual void MarkDebuggerUnattached(void) = 0;

    virtual bool CrawlFrameIsGcSafe(CrawlFrame *pCF) = 0;

    virtual bool SweepThreadsForDebug(bool forceSync) = 0;

   virtual void GetRuntimeOffsets(SIZE_T *pTLSIndex,
                                  SIZE_T *pTLSIsSpecialIndex,
                                  SIZE_T *pTLSCantStopIndex,
                                  SIZE_T *pEEThreadStateOffset,
                                  SIZE_T *pEEThreadStateNCOffset,
                                  SIZE_T *pEEThreadPGCDisabledOffset,
                                  DWORD  *pEEThreadPGCDisabledValue,
                                  SIZE_T *pEEThreadFrameOffset,
                                  SIZE_T *pEEThreadMaxNeededSize,
                                  DWORD  *pEEThreadSteppingStateMask,
                                  DWORD  *pEEMaxFrameValue,
                                  SIZE_T *pEEThreadDebuggerFilterContextOffset,
                                  SIZE_T *pEEThreadCantStopMask,
                                  SIZE_T *pEEFrameNextOffset,
                                  DWORD  *pEEIsManagedExceptionStateMask) = 0;

    virtual bool IsStub(const BYTE *ip) = 0;

#endif // #ifndef DACCESS_COMPILE

    virtual bool DetectHandleILStubs(Thread *thread) = 0;

    virtual bool TraceStub(const BYTE *ip, TraceDestination *trace) = 0;

#ifndef DACCESS_COMPILE

    virtual bool FollowTrace(TraceDestination *trace) = 0;

    virtual bool TraceFrame(Thread *thread,
                            Frame *frame,
                            BOOL fromPatch,
                            TraceDestination *trace,
                            REGDISPLAY *regs) = 0;

    virtual bool TraceManager(Thread *thread,
                              StubManager *stubManager,
                              TraceDestination *trace,
                              T_CONTEXT *context,
                              BYTE **pRetAddr) = 0;

    virtual void EnableTraceCall(Thread *thread) = 0;
    virtual void DisableTraceCall(Thread *thread) = 0;

#endif // #ifndef DACCESS_COMPILE

#ifndef DACCESS_COMPILE

    virtual void DebuggerModifyingLogSwitch (int iNewLevel,
                                             const WCHAR *pLogSwitchName) = 0;

    virtual HRESULT SetIPFromSrcToDst(Thread *pThread,
                          SLOT addrStart,
                          DWORD offFrom,
                          DWORD offTo,
                          bool fCanSetIPOnly,
                          PREGDISPLAY pReg,
                          PT_CONTEXT pCtx,
                          void *pDji,
                          EHRangeTree *pEHRT) = 0;

    virtual void SetDebugState(Thread *pThread,
                               CorDebugThreadState state) = 0;

    virtual void SetAllDebugState(Thread *et,
                                  CorDebugThreadState state) = 0;

    virtual CorDebugUserState GetPartialUserState( Thread *pThread ) = 0;

#ifdef FEATURE_PREJIT
#ifndef DACCESS_COMPILE
    virtual void SetNGENDebugFlags(BOOL fAllowOpt) = 0;

    virtual void GetNGENDebugFlags(BOOL *fAllowOpt) = 0;
#endif
#endif // FEATURE_PREJIT

#endif // #ifndef DACCESS_COMPILE

#ifdef DACCESS_COMPILE
    virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) = 0;
#endif

    virtual unsigned GetSizeForCorElementType(CorElementType etyp) = 0;

#ifndef DACCESS_COMPILE
    virtual BOOL ObjIsInstanceOf(Object *pElement, TypeHandle toTypeHnd) = 0;
#endif

    virtual void ClearAllDebugInterfaceReferences(void) = 0;

#ifndef DACCESS_COMPILE
#ifdef _DEBUG
    virtual void ObjectRefFlush(Thread *pThread) = 0;
#endif
#endif

#ifndef DACCESS_COMPILE
    virtual BOOL AdjustContextForWriteBarrierForDebugger(CONTEXT* context) = 0;
#endif
};

#endif // _eedbginterface_h_