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 /*============================================================
7 ** Header: DebugDebugger.h
9 ** Purpose: Native methods on System.Debug.Debugger
13 ===========================================================*/
15 #ifndef __DEBUG_DEBUGGER_h__
16 #define __DEBUG_DEBUGGER_h__
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);
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);
32 static FCDECL0(FC_BOOL_RET, IsLogging);
35 static BOOL IsLoggingHelper();
39 class StackFrameHelper : public Object
42 // Modifying the order or fields of this object may require other changes to the
43 // classlib defintion of the StackFrameHelper class.
45 THREADBASEREF targetThread;
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;
62 BOOLARRAYREF rgiLastFrameFromForeignExceptionStackTrace;
68 ~StackFrameHelper() {}
71 void SetFrameCount(int iCount)
76 int GetFrameCount(void)
83 #ifdef USE_CHECKED_OBJECTREFS
84 typedef REF <StackFrameHelper> STACKFRAMEHELPERREF;
86 typedef StackFrameHelper* STACKFRAMEHELPERREF;
94 #ifndef DACCESS_COMPILE
95 // the DAC directly uses the GetStackFramesData and DebugStackTraceElement types
97 #endif // DACCESS_COMPILE
98 struct DebugStackTraceElement {
99 DWORD dwOffset; // native offset
103 // TRUE if this element represents the last frame of the foreign
104 // exception stack trace.
105 BOOL fIsLastFrameFromForeignStackTrace;
107 // Initialization done under TSL.
108 // This is used when first collecting the stack frame data.
110 DWORD dwNativeOffset,
113 , BOOL fIsLastFrameFromForeignStackTrace = FALSE
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).
124 struct GetStackFramesData {
126 // Used for the integer-skip version
128 INT32 NumFramesRequested;
129 INT32 cElementsAllocated;
131 DebugStackTraceElement* pElements;
132 THREADBASEREF TargetThread;
134 BOOL fDoWeHaveAnyFramesFromForeignStackTrace;
137 GetStackFramesData() : skip(0),
138 NumFramesRequested (0),
139 cElementsAllocated(0),
142 TargetThread((THREADBASEREF)(TADDR)NULL)
144 LIMITED_METHOD_CONTRACT;
145 fDoWeHaveAnyFramesFromForeignStackTrace = FALSE;
149 ~GetStackFramesData()
156 GetStackFramesInternal,
157 StackFrameHelper* pStackFrameHelper,
159 CLR_BOOL fNeedFileInfo,
163 static void GetStackFramesFromException(OBJECTREF * e, GetStackFramesData *pData, PTRARRAYREF * pDynamicMethodArray = NULL);
165 #ifndef DACCESS_COMPILE
166 // the DAC directly calls GetStackFramesFromException
170 static void GetStackFramesHelper(Frame *pStartFrame, void* pStopStack, GetStackFramesData *pData);
172 static void GetStackFrames(Frame *pStartFrame, void* pStopStack, GetStackFramesData *pData);
174 static StackWalkAction GetStackFramesCallback(CrawlFrame* pCf, VOID* data);
178 #endif // __DEBUG_DEBUGGER_h__