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,
33 MONO_UNWIND_NONE = 0x0,
34 MONO_UNWIND_LOOKUP_IL_OFFSET = 0x1,
36 MONO_UNWIND_LOOKUP_ACTUAL_METHOD = 0x2,
38 * Store the locations where caller-saved registers are saved on the stack in
39 * frame->reg_locations. The pointer is only valid during the call to the unwind
42 MONO_UNWIND_REG_LOCATIONS = 0x4,
43 MONO_UNWIND_DEFAULT = MONO_UNWIND_LOOKUP_ACTUAL_METHOD,
44 MONO_UNWIND_SIGNAL_SAFE = MONO_UNWIND_NONE,
45 MONO_UNWIND_LOOKUP_ALL = MONO_UNWIND_LOOKUP_IL_OFFSET | MONO_UNWIND_LOOKUP_ACTUAL_METHOD,
49 MonoStackFrameType type;
51 * For FRAME_TYPE_MANAGED, otherwise NULL.
56 * Not valid if ASYNC_CONTEXT is true.
60 * If ji->method is a gshared method, this is the actual method instance.
61 * This is only filled if lookup for actual method was requested (MONO_UNWIND_LOOKUP_ACTUAL_METHOD)
62 * Not valid if ASYNC_CONTEXT is true.
64 MonoMethod *actual_method;
65 /* The domain containing the code executed by this frame */
67 /* Whenever method is a user level method */
70 * Whenever this frame was loaded in async context.
72 gboolean async_context;
75 * IL offset of this frame.
76 * Only available if the runtime have debugging enabled (--debug switch) and
77 * il offset resultion was requested (MONO_UNWIND_LOOKUP_IL_OFFSET)
81 /* For FRAME_TYPE_INTERP_EXIT */
82 gpointer interp_exit_data;
84 /* For FRAME_TYPE_INTERP */
85 gpointer interp_frame;
87 /* The next fields are only useful for the jit */
89 guint32 unwind_info_len;
92 mgreg_t **reg_locations;
95 /*Index into MonoThreadState::unwind_data. */
97 MONO_UNWIND_DATA_DOMAIN,
99 MONO_UNWIND_DATA_JIT_TLS,
103 * This structs holds all information needed to unwind the stack
108 gpointer unwind_data [3]; /*right now: domain, lmf and jit_tls*/
111 int gc_stackdata_size;
112 } MonoThreadUnwindState;