3 * Copyright 2008-2010 Novell, Inc.
4 * Copyright 2011 Xamarin Inc.
5 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
7 #ifndef __MONO_MONO_STACK_UNWINDING_H__
8 #define __MONO_MONO_STACK_UNWINDING_H__
10 #include <mono/metadata/appdomain.h>
11 #include <mono/metadata/metadata.h>
12 #include <mono/utils/mono-context.h>
15 * Possible frame types returned by the stack walker.
18 /* Normal managed frames */
19 FRAME_TYPE_MANAGED
= 0,
20 /* Pseudo frame marking the start of a method invocation done by the soft debugger */
21 FRAME_TYPE_DEBUGGER_INVOKE
= 1,
22 /* Frame for transitioning to native code */
23 FRAME_TYPE_MANAGED_TO_NATIVE
= 2,
24 FRAME_TYPE_TRAMPOLINE
= 3,
25 /* Interpreter frame */
26 FRAME_TYPE_INTERP
= 4,
27 /* Frame for transitioning from interpreter to managed code */
28 FRAME_TYPE_INTERP_TO_MANAGED
= 5,
29 /* same, but with MonoContext */
30 FRAME_TYPE_INTERP_TO_MANAGED_WITH_CTX
= 6,
35 MONO_UNWIND_NONE
= 0x0,
36 MONO_UNWIND_LOOKUP_IL_OFFSET
= 0x1,
38 MONO_UNWIND_LOOKUP_ACTUAL_METHOD
= 0x2,
40 * Store the locations where caller-saved registers are saved on the stack in
41 * frame->reg_locations. The pointer is only valid during the call to the unwind
44 MONO_UNWIND_REG_LOCATIONS
= 0x4,
45 MONO_UNWIND_DEFAULT
= MONO_UNWIND_LOOKUP_ACTUAL_METHOD
,
46 MONO_UNWIND_SIGNAL_SAFE
= MONO_UNWIND_NONE
,
47 MONO_UNWIND_LOOKUP_ALL
= MONO_UNWIND_LOOKUP_IL_OFFSET
| MONO_UNWIND_LOOKUP_ACTUAL_METHOD
,
51 MonoStackFrameType type
;
53 * For FRAME_TYPE_MANAGED, otherwise NULL.
58 * Not valid if ASYNC_CONTEXT is true.
62 * If ji->method is a gshared method, this is the actual method instance.
63 * This is only filled if lookup for actual method was requested (MONO_UNWIND_LOOKUP_ACTUAL_METHOD)
64 * Not valid if ASYNC_CONTEXT is true.
66 MonoMethod
*actual_method
;
67 /* The domain containing the code executed by this frame */
69 /* Whenever method is a user level method */
72 * Whenever this frame was loaded in async context.
74 gboolean async_context
;
77 * IL offset of this frame.
78 * Only available if the runtime have debugging enabled (--debug switch) and
79 * il offset resultion was requested (MONO_UNWIND_LOOKUP_IL_OFFSET)
83 /* For FRAME_TYPE_INTERP_EXIT */
84 gpointer interp_exit_data
;
86 /* For FRAME_TYPE_INTERP */
87 gpointer interp_frame
;
90 * A stack address associated with the frame which can be used
92 * This is needed because ctx is not changed when unwinding through
93 * interpreter frames, it still refers to the last native interpreter
98 /* The next fields are only useful for the jit */
100 guint32 unwind_info_len
;
103 host_mgreg_t
**reg_locations
;
104 } MonoStackFrameInfo
;
106 /*Index into MonoThreadState::unwind_data. */
108 MONO_UNWIND_DATA_DOMAIN
,
109 MONO_UNWIND_DATA_LMF
,
110 MONO_UNWIND_DATA_JIT_TLS
,
114 * This structs holds all information needed to unwind the stack
119 gpointer unwind_data
[3]; /*right now: domain, lmf and jit_tls*/
122 int gc_stackdata_size
;
123 } MonoThreadUnwindState
;