[interp] Remove unreachable code (#12411)
[mono-project.git] / mono / utils / mono-stack-unwinding.h
blobcb1d6322d83b4042157e20d190a3a53939be2ef9
1 /**
2 * \file
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.
6 */
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.
17 typedef enum {
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,
31 FRAME_TYPE_NUM = 7
32 } MonoStackFrameType;
34 typedef enum {
35 MONO_UNWIND_NONE = 0x0,
36 MONO_UNWIND_LOOKUP_IL_OFFSET = 0x1,
37 /* NOT signal safe */
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
42 * callback.
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,
48 } MonoUnwindOptions;
50 typedef struct {
51 MonoStackFrameType type;
52 /*
53 * For FRAME_TYPE_MANAGED, otherwise NULL.
55 MonoJitInfo *ji;
57 * Same as ji->method.
58 * Not valid if ASYNC_CONTEXT is true.
60 MonoMethod *method;
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 */
68 MonoDomain *domain;
69 /* Whenever method is a user level method */
70 gboolean managed;
72 * Whenever this frame was loaded in async context.
74 gboolean async_context;
75 int native_offset;
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)
81 int 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
91 * to compare frames.
92 * This is needed because ctx is not changed when unwinding through
93 * interpreter frames, it still refers to the last native interpreter
94 * frame.
96 gpointer frame_addr;
98 /* The next fields are only useful for the jit */
99 gpointer lmf;
100 guint32 unwind_info_len;
101 guint8 *unwind_info;
103 host_mgreg_t **reg_locations;
104 } MonoStackFrameInfo;
106 /*Index into MonoThreadState::unwind_data. */
107 enum {
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
115 * of a thread.
117 typedef struct {
118 MonoContext ctx;
119 gpointer unwind_data [3]; /*right now: domain, lmf and jit_tls*/
120 gboolean valid;
121 void *gc_stackdata;
122 int gc_stackdata_size;
123 } MonoThreadUnwindState;
126 #endif