New tests.
[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 <glib.h>
10 #include <mono/metadata/image.h>
11 #include <mono/metadata/appdomain.h>
12
13 typedef struct _MonoSymbolTable                 MonoSymbolTable;
14 typedef struct _MonoDebugDataTable              MonoDebugDataTable;
15
16 typedef struct _MonoSymbolFile                  MonoSymbolFile;
17
18 typedef struct _MonoDebugHandle                 MonoDebugHandle;
19
20 typedef struct _MonoDebugLineNumberEntry        MonoDebugLineNumberEntry;
21
22 typedef struct _MonoDebugVarInfo                MonoDebugVarInfo;
23 typedef struct _MonoDebugMethodJitInfo          MonoDebugMethodJitInfo;
24 typedef struct _MonoDebugMethodAddress          MonoDebugMethodAddress;
25 typedef struct _MonoDebugMethodAddressList      MonoDebugMethodAddressList;
26 typedef struct _MonoDebugClassEntry             MonoDebugClassEntry;
27
28 typedef struct _MonoDebugMethodInfo             MonoDebugMethodInfo;
29 typedef struct _MonoDebugSourceLocation         MonoDebugSourceLocation;
30
31 typedef struct _MonoDebugList                   MonoDebugList;
32
33 typedef enum {
34         MONO_DEBUG_FORMAT_NONE,
35         MONO_DEBUG_FORMAT_MONO,
36         MONO_DEBUG_FORMAT_DEBUGGER
37 } MonoDebugFormat;
38
39 /*
40  * NOTE:
41  * We intentionally do not use GList here since the debugger needs to know about
42  * the layout of the fields.
43 */
44 struct _MonoDebugList {
45         MonoDebugList *next;
46         gconstpointer data;
47 };
48
49 struct _MonoSymbolTable {
50         guint64 magic;
51         guint32 version;
52         guint32 total_size;
53
54         /*
55          * Corlib and metadata info.
56          */
57         MonoDebugHandle *corlib;
58         MonoDebugDataTable *global_data_table;
59         MonoDebugList *data_tables;
60
61         /*
62          * The symbol files.
63          */
64         MonoDebugList *symbol_files;
65 };
66
67 struct _MonoDebugHandle {
68         guint32 index;
69         char *image_file;
70         MonoImage *image;
71         MonoDebugDataTable *type_table;
72         MonoSymbolFile *symfile;
73 };
74
75 struct _MonoDebugMethodJitInfo {
76         const guint8 *code_start;
77         guint32 code_size;
78         guint32 prologue_end;
79         guint32 epilogue_begin;
80         const guint8 *wrapper_addr;
81         guint32 num_line_numbers;
82         MonoDebugLineNumberEntry *line_numbers;
83         guint32 num_params;
84         MonoDebugVarInfo *this_var;
85         MonoDebugVarInfo *params;
86         guint32 num_locals;
87         MonoDebugVarInfo *locals;
88 };
89
90 struct _MonoDebugMethodAddressList {
91         guint32 size;
92         guint32 count;
93         guint8 data [MONO_ZERO_LEN_ARRAY];
94 };
95
96 struct _MonoDebugSourceLocation {
97         gchar *source_file;
98         guint32 row, column;
99         guint32 il_offset;
100 };
101
102 /*
103  * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
104  * where the variable is actually stored.
105  *
106  * See relocate_variable() in debug-symfile.c for more info.
107  */
108 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS               0xf0000000
109
110 /* The variable is in register "index". */
111 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER            0
112
113 /* The variable is at offset "offset" from register "index". */
114 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET           0x10000000
115
116 /* The variable is in the two registers "offset" and "index". */
117 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS       0x20000000
118
119 /* The variable is dead. */
120 #define MONO_DEBUG_VAR_ADDRESS_MODE_DEAD                0x30000000
121
122 struct _MonoDebugVarInfo {
123         guint32 index;
124         guint32 offset;
125         guint32 size;
126         guint32 begin_scope;
127         guint32 end_scope;
128         MonoType *type;
129 };
130
131 #define MONO_DEBUGGER_MAJOR_VERSION                     81
132 #define MONO_DEBUGGER_MINOR_VERSION                     3
133 #define MONO_DEBUGGER_MAGIC                             0x7aff65af4253d427ULL
134
135 extern MonoSymbolTable *mono_symbol_table;
136 extern MonoDebugFormat mono_debug_format;
137 extern GHashTable *mono_debug_handles;
138 extern gint32 mono_debug_debugger_version;
139 extern gint32 _mono_debug_using_mono_debugger;
140
141 void mono_debug_list_add (MonoDebugList **list, gconstpointer data);
142 void mono_debug_list_remove (MonoDebugList **list, gconstpointer data);
143
144 void mono_debug_init (MonoDebugFormat format);
145 void mono_debug_open_image_from_memory (MonoImage *image, const guint8 *raw_contents, int size);
146 void mono_debug_cleanup (void);
147
148 void mono_debug_close_image (MonoImage *image);
149
150 void mono_debug_domain_unload (MonoDomain *domain);
151 void mono_debug_domain_create (MonoDomain *domain);
152
153 gboolean mono_debug_using_mono_debugger (void);
154
155 MonoDebugMethodAddress *
156 mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
157
158 MonoDebugMethodInfo *
159 mono_debug_lookup_method (MonoMethod *method);
160
161 MonoDebugMethodAddressList *
162 mono_debug_lookup_method_addresses (MonoMethod *method);
163
164 MonoDebugMethodJitInfo*
165 mono_debug_find_method (MonoMethod *method, MonoDomain *domain);
166
167 void
168 mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
169
170
171 void
172 mono_debug_add_delegate_trampoline (gpointer code, int size);
173
174 int
175 mono_debug_lookup_locals (MonoMethod *method, char ***names, int **indexes);
176
177 /*
178  * Line number support.
179  */
180
181 MonoDebugSourceLocation *
182 mono_debug_lookup_source_location (MonoMethod *method, guint32 address, MonoDomain *domain);
183
184 void
185 mono_debug_free_source_location (MonoDebugSourceLocation *location);
186
187 gchar *
188 mono_debug_print_stack_frame (MonoMethod *method, guint32 native_offset, MonoDomain *domain);
189
190 /*
191  * Mono Debugger support functions
192  *
193  * These methods are used by the JIT while running inside the Mono Debugger.
194  */
195
196 int             mono_debugger_method_has_breakpoint       (MonoMethod *method);
197 int             mono_debugger_insert_breakpoint           (const gchar *method_name, gboolean include_namespace);
198
199 #endif /* __MONO_DEBUG_H__ */