[Tizen] Unify dnetmemoryenumlib terms to match the codebase (#291)
[platform/upstream/coreclr.git] / src / vm / debugdebugger.h
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.
4
5 /*============================================================
6 **
7 ** Header: DebugDebugger.h
8 **
9 ** Purpose: Native methods on System.Debug.Debugger
10 **
11 **
12
13 ===========================================================*/
14
15 #ifndef __DEBUG_DEBUGGER_h__
16 #define __DEBUG_DEBUGGER_h__
17 #include <object.h>
18
19
20 class DebugDebugger
21 {
22 public:
23     static FCDECL0(void, Break);
24     static FCDECL0(FC_BOOL_RET, Launch);
25     static FCDECL0(FC_BOOL_RET, IsDebuggerAttached);
26     static FCDECL3(void, Log, INT32 Level, StringObject* strModule, StringObject* strMessage);
27
28     // receives a custom notification object from the target and sends it to the RS via 
29     // code:Debugger::SendCustomDebuggerNotification
30     static FCDECL1(void, CustomNotification, Object * dataUNSAFE);
31
32     static FCDECL0(FC_BOOL_RET, IsLogging);
33
34 protected:
35     static BOOL IsLoggingHelper();
36 };
37
38
39 class StackFrameHelper : public Object
40 {
41     // READ ME:
42     // Modifying the order or fields of this object may require other changes to the
43     // classlib defintion of the StackFrameHelper class.
44 public:
45     THREADBASEREF targetThread;
46     I4ARRAYREF rgiOffset;
47     I4ARRAYREF rgiILOffset;
48     PTRARRAYREF dynamicMethods;
49     BASEARRAYREF rgMethodHandle;
50     PTRARRAYREF rgAssemblyPath;
51     PTRARRAYREF rgAssembly;
52     BASEARRAYREF rgLoadedPeAddress;
53     I4ARRAYREF rgiLoadedPeSize;
54     BASEARRAYREF rgInMemoryPdbAddress;
55     I4ARRAYREF rgiInMemoryPdbSize;
56     // if rgiMethodToken[i] == 0, then don't attempt to get the portable PDB source/info
57     I4ARRAYREF rgiMethodToken;
58     PTRARRAYREF rgFilename;
59     I4ARRAYREF rgiLineNumber;
60     I4ARRAYREF rgiColumnNumber;
61
62     BOOLARRAYREF rgiLastFrameFromForeignExceptionStackTrace;
63
64     int iFrameCount;
65
66 protected:
67     StackFrameHelper() {}
68     ~StackFrameHelper() {}
69
70 public:
71     void SetFrameCount(int iCount)
72     {
73         iFrameCount = iCount;
74     }
75
76     int  GetFrameCount(void)
77     {
78         return iFrameCount;
79     }
80
81 };
82
83 #ifdef USE_CHECKED_OBJECTREFS
84 typedef REF <StackFrameHelper> STACKFRAMEHELPERREF;
85 #else
86 typedef StackFrameHelper* STACKFRAMEHELPERREF;
87 #endif
88
89
90 class DebugStackTrace
91 {
92 public:
93
94 #ifndef DACCESS_COMPILE
95 // the DAC directly uses the GetStackFramesData and DebugStackTraceElement types
96 private:
97 #endif // DACCESS_COMPILE
98     struct DebugStackTraceElement {
99         DWORD dwOffset;  // native offset
100         DWORD dwILOffset;
101         MethodDesc *pFunc;
102         PCODE ip;
103         // TRUE if this element represents the last frame of the foreign
104         // exception stack trace.
105         BOOL                    fIsLastFrameFromForeignStackTrace;
106
107         // Initialization done under TSL.
108         // This is used when first collecting the stack frame data.
109         void InitPass1(
110             DWORD dwNativeOffset,
111             MethodDesc *pFunc,
112             PCODE ip
113             , BOOL                      fIsLastFrameFromForeignStackTrace = FALSE
114                         );
115
116         // Initialization done outside the TSL.
117         // This will init the dwILOffset field (and potentially anything else
118         // that can't be done under the TSL).
119         void InitPass2();
120     };
121
122 public:
123
124     struct GetStackFramesData {
125
126         // Used for the integer-skip version
127         INT32   skip;
128         INT32   NumFramesRequested;
129         INT32   cElementsAllocated;
130         INT32   cElements;
131         DebugStackTraceElement* pElements;
132         THREADBASEREF   TargetThread;
133         AppDomain *pDomain;
134         BOOL    fDoWeHaveAnyFramesFromForeignStackTrace;
135
136
137         GetStackFramesData() :  skip(0), 
138                                 NumFramesRequested (0),
139                                 cElementsAllocated(0), 
140                                 cElements(0), 
141                                 pElements(NULL),
142                                 TargetThread((THREADBASEREF)(TADDR)NULL)
143         { 
144             LIMITED_METHOD_CONTRACT;
145             fDoWeHaveAnyFramesFromForeignStackTrace = FALSE;
146
147         }
148
149         ~GetStackFramesData()
150         {
151             delete [] pElements;
152         }
153     };
154
155     static FCDECL4(void, 
156                    GetStackFramesInternal, 
157                    StackFrameHelper* pStackFrameHelper, 
158                    INT32 iSkip, 
159                    CLR_BOOL fNeedFileInfo,
160                    Object* pException
161                   );
162
163     static void GetStackFramesFromException(OBJECTREF * e, GetStackFramesData *pData, PTRARRAYREF * pDynamicMethodArray = NULL);
164
165 #ifndef DACCESS_COMPILE
166 // the DAC directly calls GetStackFramesFromException
167 private:
168 #endif
169     
170     static void GetStackFramesHelper(Frame *pStartFrame, void* pStopStack, GetStackFramesData *pData);
171
172     static void GetStackFrames(Frame *pStartFrame, void* pStopStack, GetStackFramesData *pData);    
173
174     static StackWalkAction GetStackFramesCallback(CrawlFrame* pCf, VOID* data);
175
176 };
177
178 #endif  // __DEBUG_DEBUGGER_h__