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,
29 MONO_UNWIND_NONE = 0x0,
30 MONO_UNWIND_LOOKUP_IL_OFFSET = 0x1,
32 MONO_UNWIND_LOOKUP_ACTUAL_METHOD = 0x2,
34 * Store the locations where caller-saved registers are saved on the stack in
35 * frame->reg_locations. The pointer is only valid during the call to the unwind
38 MONO_UNWIND_REG_LOCATIONS = 0x4,
39 MONO_UNWIND_DEFAULT = MONO_UNWIND_LOOKUP_ACTUAL_METHOD,
40 MONO_UNWIND_SIGNAL_SAFE = MONO_UNWIND_NONE,
41 MONO_UNWIND_LOOKUP_ALL = MONO_UNWIND_LOOKUP_IL_OFFSET | MONO_UNWIND_LOOKUP_ACTUAL_METHOD,
45 MonoStackFrameType type;
47 * For FRAME_TYPE_MANAGED, otherwise NULL.
52 * Not valid if ASYNC_CONTEXT is true.
56 * If ji->method is a gshared method, this is the actual method instance.
57 * This is only filled if lookup for actual method was requested (MONO_UNWIND_LOOKUP_ACTUAL_METHOD)
58 * Not valid if ASYNC_CONTEXT is true.
60 MonoMethod *actual_method;
61 /* The domain containing the code executed by this frame */
63 /* Whenever method is a user level method */
66 * Whenever this frame was loaded in async context.
68 gboolean async_context;
71 * IL offset of this frame.
72 * Only available if the runtime have debugging enabled (--debug switch) and
73 * il offset resultion was requested (MONO_UNWIND_LOOKUP_IL_OFFSET)
77 /* The next fields are only useful for the jit */
79 guint32 unwind_info_len;
82 mgreg_t **reg_locations;
85 /*Index into MonoThreadState::unwind_data. */
87 MONO_UNWIND_DATA_DOMAIN,
89 MONO_UNWIND_DATA_JIT_TLS,
93 * This structs holds all information needed to unwind the stack
98 gpointer unwind_data [3]; /*right now: domain, lmf and jit_tls*/
101 int gc_stackdata_size;
102 } MonoThreadUnwindState;