This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mono / metadata / mono-debug-debugger.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_DEBUGGER_H__
7 #define __MONO_DEBUG_DEBUGGER_H__
8
9 #include <glib.h>
10 #include <mono/metadata/debug-helpers.h>
11 #include <mono/metadata/debug-mono-symfile.h>
12 #include <mono/io-layer/io-layer.h>
13
14 typedef struct _MonoDebuggerBreakpointInfo      MonoDebuggerBreakpointInfo;
15 typedef struct _MonoDebuggerBuiltinTypeInfo     MonoDebuggerBuiltinTypeInfo;
16 typedef struct _MonoDebuggerBuiltinTypes        MonoDebuggerBuiltinTypes;
17 typedef struct _MonoDebuggerSymbolTable         MonoDebuggerSymbolTable;
18 typedef struct _MonoDebuggerSymbolFile          MonoDebuggerSymbolFile;
19 typedef struct _MonoDebuggerSymbolFilePriv      MonoDebuggerSymbolFilePriv;
20 typedef struct _MonoDebuggerRangeInfo           MonoDebuggerRangeInfo;
21 typedef struct _MonoDebuggerClassInfo           MonoDebuggerClassInfo;
22 typedef struct _MonoDebuggerIOLayer             MonoDebuggerIOLayer;
23
24 typedef enum {
25         MONO_DEBUGGER_EVENT_BREAKPOINT,
26         MONO_DEBUGGER_EVENT_RELOAD_SYMTABS,
27         MONO_DEBUGGER_EVENT_UNHANDLED_EXCEPTION
28 } MonoDebuggerEvent;
29
30 typedef enum {
31         MONO_DEBUGGER_TYPE_KIND_UNKNOWN = 1,
32         MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL,
33         MONO_DEBUGGER_TYPE_KIND_STRING,
34         MONO_DEBUGGER_TYPE_KIND_SZARRAY,
35         MONO_DEBUGGER_TYPE_KIND_ARRAY,
36         MONO_DEBUGGER_TYPE_KIND_POINTER,
37         MONO_DEBUGGER_TYPE_KIND_ENUM,
38         MONO_DEBUGGER_TYPE_KIND_OBJECT,
39         MONO_DEBUGGER_TYPE_KIND_STRUCT,
40         MONO_DEBUGGER_TYPE_KIND_CLASS,
41         MONO_DEBUGGER_TYPE_KIND_CLASS_INFO
42 } MonoDebuggerTypeKind;
43
44 struct _MonoDebuggerBreakpointInfo {
45         guint32 index;
46         MonoMethodDesc *desc;
47 };
48
49 struct _MonoDebuggerBuiltinTypeInfo
50 {
51         MonoClass *klass;
52         MonoDebuggerClassInfo *cinfo;
53         guint32 type_info;
54         guint32 class_info;
55         guint8 *type_data;
56 };
57
58 struct _MonoDebuggerBuiltinTypes {
59         guint32 total_size;
60         guint32 type_info_size;
61         MonoDebuggerBuiltinTypeInfo *object_type;
62         MonoDebuggerBuiltinTypeInfo *byte_type;
63         MonoDebuggerBuiltinTypeInfo *void_type;
64         MonoDebuggerBuiltinTypeInfo *boolean_type;
65         MonoDebuggerBuiltinTypeInfo *sbyte_type;
66         MonoDebuggerBuiltinTypeInfo *int16_type;
67         MonoDebuggerBuiltinTypeInfo *uint16_type;
68         MonoDebuggerBuiltinTypeInfo *int32_type;
69         MonoDebuggerBuiltinTypeInfo *uint32_type;
70         MonoDebuggerBuiltinTypeInfo *int_type;
71         MonoDebuggerBuiltinTypeInfo *uint_type;
72         MonoDebuggerBuiltinTypeInfo *int64_type;
73         MonoDebuggerBuiltinTypeInfo *uint64_type;
74         MonoDebuggerBuiltinTypeInfo *single_type;
75         MonoDebuggerBuiltinTypeInfo *double_type;
76         MonoDebuggerBuiltinTypeInfo *char_type;
77         MonoDebuggerBuiltinTypeInfo *string_type;
78         MonoDebuggerBuiltinTypeInfo *enum_type;
79         MonoDebuggerBuiltinTypeInfo *array_type;
80         MonoDebuggerBuiltinTypeInfo *exception_type;
81 };
82
83 struct _MonoDebuggerSymbolTable {
84         guint64 magic;
85         guint32 version;
86         guint32 total_size;
87
88         /*
89          * Corlib and builtin types.
90          */
91         MonoDomain *domain;
92         MonoDebuggerSymbolFile *corlib;
93         MonoDebuggerBuiltinTypes *builtin_types;
94
95         /*
96          * The symbol files.
97          */
98         guint32 num_symbol_files;
99         MonoDebuggerSymbolFile **symbol_files;
100
101         /*
102          * Type table.
103          * This is intentionally not a GPtrArray to make it more easy to
104          * read for the debugger.  The `type_tables' field contains
105          * `num_type_tables' pointers to continuous memory areas of
106          * `type_table_chunk_size' bytes each.
107          *
108          * The type table is basically a big continuous blob, but we need
109          * to split it up into pieces because we don't know the total size
110          * in advance and using g_realloc() doesn't work because that may
111          * reallocate the block to a different address.
112          */
113         guint32 num_type_tables;
114         guint32 type_table_chunk_size;
115         gpointer *type_tables;
116         /*
117          * Current type table.
118          * The `current_type_table' points to a blob of `type_table_chunk_size'
119          * bytes.
120          */
121         gpointer current_type_table;
122         /*
123          * This is the total size of the type table, including all the tables
124          * in the `type_tables' vector.
125          */
126         guint32 type_table_size;
127         /*
128          * These are global offsets - the `current_type_table' starts at global
129          * offset `type_table_start' and we've already allocated stuff in it
130          * until offset `type_table_offset'.
131          */
132         guint32 type_table_offset;
133         guint32 type_table_start;
134 };
135
136 struct _MonoDebuggerSymbolFile {
137         guint32 index;
138         MonoSymbolFile *symfile;
139         MonoImage *image;
140         const char *image_file;
141         guint32 class_entry_size;
142         /* Pointer to the malloced range table. */
143         guint32 locked;
144         guint32 generation;
145         MonoDebuggerRangeInfo *range_table;
146         guint32 range_entry_size;
147         guint32 num_range_entries;
148         /* Pointer to the malloced class table. */
149         MonoDebuggerClassInfo *class_table;
150         guint32 num_class_entries;
151         /* Private. */
152         MonoDebuggerSymbolFilePriv *_priv;
153 };
154
155 struct _MonoDebuggerRangeInfo {
156         const guint8 *start_address;
157         const guint8 *end_address;
158         guint32 index;
159         gpointer dynamic_data;
160         guint32 dynamic_size;
161 };
162
163 struct _MonoDebuggerClassInfo {
164         MonoClass *klass;
165         guint32 rank;
166         guint32 token;
167         guint32 type_info;
168 };
169
170 extern MonoDebuggerSymbolTable *mono_debugger_symbol_table;
171
172 /*
173  * Address of the x86 trampoline code.  This is used by the debugger to check
174  * whether a method is a trampoline.
175  */
176 extern guint8 *mono_generic_trampoline_code;
177
178 #ifndef PLATFORM_WIN32
179
180 /*
181  * Functions we export to the debugger.
182  */
183 struct _MonoDebuggerIOLayer
184 {
185         void (*InitializeCriticalSection) (WapiCriticalSection *section);
186         void (*DeleteCriticalSection) (WapiCriticalSection *section);
187         gboolean (*TryEnterCriticalSection) (WapiCriticalSection *section);
188         void (*EnterCriticalSection) (WapiCriticalSection *section);
189         void (*LeaveCriticalSection) (WapiCriticalSection *section);
190
191         guint32 (*WaitForSingleObject) (gpointer handle, guint32 timeout);
192         guint32 (*SignalObjectAndWait) (gpointer signal_handle, gpointer wait,
193                                         guint32 timeout, gboolean alertable);
194         guint32 (*WaitForMultipleObjects) (guint32 numobjects, gpointer *handles,
195                                            gboolean waitall, guint32 timeout);
196
197         gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
198                                      gint32 initial, gint32 max,
199                                      const guchar *name);
200         gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
201
202         gpointer (*CreateThread) (WapiSecurityAttributes *security,
203                                   guint32 stacksize, WapiThreadStart start,
204                                   gpointer param, guint32 create, guint32 *tid);
205         guint32 (*GetCurrentThreadId) (void);
206 };
207
208 extern MonoDebuggerIOLayer mono_debugger_io_layer;
209
210 #endif
211
212 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, guint32 arg);
213
214 void            mono_debugger_initialize                  (MonoDomain *domain);
215 void            mono_debugger_cleanup                     (void);
216
217 void            mono_debugger_lock                        (void);
218 void            mono_debugger_unlock                      (void);
219 void            mono_debugger_event                       (MonoDebuggerEvent event, gpointer data, guint32 arg);
220
221 MonoDebuggerSymbolFile   *mono_debugger_add_symbol_file   (MonoDebugHandle *handle);
222 void                      mono_debugger_add_type          (MonoDebuggerSymbolFile *symfile, MonoClass *klass);
223 MonoDebuggerBuiltinTypes *mono_debugger_add_builtin_types (MonoDebuggerSymbolFile *symfile);
224
225 void            mono_debugger_add_method                  (MonoDebuggerSymbolFile *symfile,
226                                                            MonoDebugMethodInfo *minfo,
227                                                            MonoDebugMethodJitInfo *jit);
228
229 int             mono_debugger_insert_breakpoint_full      (MonoMethodDesc *desc);
230 int             mono_debugger_remove_breakpoint           (int breakpoint_id);
231 int             mono_debugger_insert_breakpoint           (const gchar *method_name, gboolean include_namespace);
232 int             mono_debugger_method_has_breakpoint       (MonoMethod *method);
233 void            mono_debugger_breakpoint_callback         (MonoMethod *method, guint32 idx);
234
235 gpointer        mono_debugger_create_notification_function (gpointer *notification_address);
236
237 MonoObject     *mono_debugger_runtime_invoke              (MonoMethod *method, void *obj,
238                                                            void **params, MonoObject **exc);
239
240 guint32         mono_debugger_lookup_type                 (const gchar *type_name);
241 gint32          mono_debugger_lookup_assembly             (const gchar *name);
242 gboolean        mono_debugger_unhandled_exception         (gpointer addr, MonoObject *exc);
243
244
245 void *
246 mono_vtable_get_static_field_data (MonoVTable *vt);
247
248
249 MonoReflectionMethod *
250 ves_icall_MonoDebugger_GetMethod (MonoReflectionAssembly *assembly, guint32 token);
251
252 int
253 ves_icall_MonoDebugger_GetMethodToken (MonoReflectionAssembly *assembly, MonoReflectionMethod *method);
254
255 MonoReflectionType *
256 ves_icall_MonoDebugger_GetLocalTypeFromSignature (MonoReflectionAssembly *assembly, MonoArray *signature);
257
258 MonoReflectionType *
259 ves_icall_MonoDebugger_GetType (MonoReflectionAssembly *assembly, guint32 token);
260
261 #endif /* __MONO_DEBUG_DEBUGGER_H__ */