[msvc] Update csproj files (#4336)
[mono.git] / mono / metadata / mono-debug.h
1 /*
2  * This header is only installed for use by the debugger:
3  * the structures and the API declared here are not supported.
4  */
5
6 #ifndef __MONO_DEBUG_H__
7 #define __MONO_DEBUG_H__
8
9 #include <mono/utils/mono-publib.h>
10 #include <mono/metadata/image.h>
11 #include <mono/metadata/appdomain.h>
12
13 MONO_BEGIN_DECLS
14
15 typedef struct _MonoSymbolTable                 MonoSymbolTable;
16 typedef struct _MonoDebugDataTable              MonoDebugDataTable;
17
18 typedef struct _MonoSymbolFile                  MonoSymbolFile;
19 typedef struct _MonoPPDBFile                    MonoPPDBFile;
20
21 typedef struct _MonoDebugHandle                 MonoDebugHandle;
22
23 typedef struct _MonoDebugLineNumberEntry        MonoDebugLineNumberEntry;
24
25 typedef struct _MonoDebugVarInfo                MonoDebugVarInfo;
26 typedef struct _MonoDebugMethodJitInfo          MonoDebugMethodJitInfo;
27 typedef struct _MonoDebugMethodAddress          MonoDebugMethodAddress;
28 typedef struct _MonoDebugMethodAddressList      MonoDebugMethodAddressList;
29 typedef struct _MonoDebugClassEntry             MonoDebugClassEntry;
30
31 typedef struct _MonoDebugMethodInfo             MonoDebugMethodInfo;
32 typedef struct _MonoDebugLocalsInfo             MonoDebugLocalsInfo;
33 typedef struct _MonoDebugMethodAsyncInfo        MonoDebugMethodAsyncInfo;
34 typedef struct _MonoDebugSourceLocation         MonoDebugSourceLocation;
35
36 typedef struct _MonoDebugList                   MonoDebugList;
37
38 typedef enum {
39         MONO_DEBUG_FORMAT_NONE,
40         MONO_DEBUG_FORMAT_MONO,
41         /* Deprecated, the mdb debugger is not longer supported. */
42         MONO_DEBUG_FORMAT_DEBUGGER
43 } MonoDebugFormat;
44
45 /*
46  * NOTE:
47  * We intentionally do not use GList here since the debugger needs to know about
48  * the layout of the fields.
49 */
50 struct _MonoDebugList {
51         MonoDebugList *next;
52         const void* data;
53 };
54
55 struct _MonoSymbolTable {
56         uint64_t magic;
57         uint32_t version;
58         uint32_t total_size;
59
60         /*
61          * Corlib and metadata info.
62          */
63         MonoDebugHandle *corlib;
64         MonoDebugDataTable *global_data_table;
65         MonoDebugList *data_tables;
66
67         /*
68          * The symbol files.
69          */
70         MonoDebugList *symbol_files;
71 };
72
73 struct _MonoDebugHandle {
74         uint32_t index;
75         char *image_file;
76         MonoImage *image;
77         MonoDebugDataTable *type_table;
78         MonoSymbolFile *symfile;
79         MonoPPDBFile *ppdb;
80 };
81
82 struct _MonoDebugMethodJitInfo {
83         const mono_byte *code_start;
84         uint32_t code_size;
85         uint32_t prologue_end;
86         uint32_t epilogue_begin;
87         const mono_byte *wrapper_addr;
88         uint32_t num_line_numbers;
89         MonoDebugLineNumberEntry *line_numbers;
90         uint32_t has_var_info;
91         uint32_t num_params;
92         MonoDebugVarInfo *this_var;
93         MonoDebugVarInfo *params;
94         uint32_t num_locals;
95         MonoDebugVarInfo *locals;
96         MonoDebugVarInfo *gsharedvt_info_var;
97         MonoDebugVarInfo *gsharedvt_locals_var;
98 };
99
100 struct _MonoDebugMethodAddressList {
101         uint32_t size;
102         uint32_t count;
103         mono_byte data [MONO_ZERO_LEN_ARRAY];
104 };
105
106 struct _MonoDebugSourceLocation {
107         char *source_file;
108         uint32_t row, column;
109         uint32_t il_offset;
110 };
111
112 MONO_API mono_bool mono_debug_enabled (void);
113
114 /*
115  * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
116  * where the variable is actually stored.
117  *
118  * See relocate_variable() in debug-symfile.c for more info.
119  */
120 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS               0xf0000000
121
122 /* The variable is in register "index". */
123 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER            0
124
125 /* The variable is at offset "offset" from register "index". */
126 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET           0x10000000
127
128 /* The variable is in the two registers "offset" and "index". */
129 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS       0x20000000
130
131 /* The variable is dead. */
132 #define MONO_DEBUG_VAR_ADDRESS_MODE_DEAD                0x30000000
133
134 /* Same as REGOFFSET, but do an indirection */
135 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET_INDIR             0x40000000
136
137 /* gsharedvt local */
138 #define MONO_DEBUG_VAR_ADDRESS_MODE_GSHAREDVT_LOCAL             0x50000000
139
140 /* variable is a vt address */
141 #define MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR              0x60000000
142
143 struct _MonoDebugVarInfo {
144         uint32_t index;
145         uint32_t offset;
146         uint32_t size;
147         uint32_t begin_scope;
148         uint32_t end_scope;
149         MonoType *type;
150 };
151
152 #define MONO_DEBUGGER_MAJOR_VERSION                     81
153 #define MONO_DEBUGGER_MINOR_VERSION                     6
154 #define MONO_DEBUGGER_MAGIC                             0x7aff65af4253d427ULL
155
156 MONO_API void mono_debug_init (MonoDebugFormat format);
157 MONO_API void mono_debug_open_image_from_memory (MonoImage *image, const mono_byte *raw_contents, int size);
158 MONO_API void mono_debug_cleanup (void);
159
160 MONO_API void mono_debug_close_image (MonoImage *image);
161
162 MONO_API void mono_debug_domain_unload (MonoDomain *domain);
163 MONO_API void mono_debug_domain_create (MonoDomain *domain);
164
165 MONO_API MonoDebugMethodAddress *
166 mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
167
168 MONO_API void
169 mono_debug_remove_method (MonoMethod *method, MonoDomain *domain);
170
171 MONO_API MonoDebugMethodInfo *
172 mono_debug_lookup_method (MonoMethod *method);
173
174 MONO_API MonoDebugMethodAddressList *
175 mono_debug_lookup_method_addresses (MonoMethod *method);
176
177 MONO_API MonoDebugMethodJitInfo*
178 mono_debug_find_method (MonoMethod *method, MonoDomain *domain);
179
180 MONO_API void
181 mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
182
183
184 MONO_API void
185 mono_debug_add_delegate_trampoline (void* code, int size);
186
187 MONO_API MonoDebugLocalsInfo*
188 mono_debug_lookup_locals (MonoMethod *method);
189
190 MonoDebugMethodAsyncInfo*
191 mono_debug_lookup_method_async_debug_info (MonoMethod *method);
192
193 MonoDebugSourceLocation *
194 mono_debug_method_lookup_location (MonoDebugMethodInfo *minfo, int il_offset);
195
196 /*
197  * Line number support.
198  */
199
200 MONO_API MonoDebugSourceLocation *
201 mono_debug_lookup_source_location (MonoMethod *method, uint32_t address, MonoDomain *domain);
202
203 MONO_API int32_t
204 mono_debug_il_offset_from_address (MonoMethod *method, MonoDomain *domain, uint32_t native_offset);
205
206 MONO_API void
207 mono_debug_free_source_location (MonoDebugSourceLocation *location);
208
209 MONO_API char *
210 mono_debug_print_stack_frame (MonoMethod *method, uint32_t native_offset, MonoDomain *domain);
211
212 /*
213  * Mono Debugger support functions
214  *
215  * These methods are used by the JIT while running inside the Mono Debugger.
216  */
217
218 MONO_API int             mono_debugger_method_has_breakpoint       (MonoMethod *method);
219 MONO_API int             mono_debugger_insert_breakpoint           (const char *method_name, mono_bool include_namespace);
220
221 MONO_API void mono_set_is_debugger_attached (mono_bool attached);
222 MONO_API mono_bool mono_is_debugger_attached (void);
223
224 MONO_END_DECLS
225
226 #endif /* __MONO_DEBUG_H__ */