2 * This header is only installed for use by the debugger:
3 * the structures and the API declared here are not supported.
6 #ifndef __MONO_DEBUG_DEBUGGER_H__
7 #define __MONO_DEBUG_DEBUGGER_H__
10 #include <mono/metadata/debug-helpers.h>
11 #include <mono/metadata/debug-mono-symfile.h>
12 #include <mono/io-layer/io-layer.h>
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;
25 MONO_DEBUGGER_EVENT_BREAKPOINT,
26 MONO_DEBUGGER_EVENT_RELOAD_SYMTABS,
27 MONO_DEBUGGER_EVENT_UNHANDLED_EXCEPTION
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;
44 struct _MonoDebuggerBreakpointInfo {
49 struct _MonoDebuggerBuiltinTypeInfo
52 MonoDebuggerClassInfo *cinfo;
58 struct _MonoDebuggerBuiltinTypes {
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;
83 struct _MonoDebuggerSymbolTable {
89 * Corlib and builtin types.
92 MonoDebuggerSymbolFile *corlib;
93 MonoDebuggerBuiltinTypes *builtin_types;
98 guint32 num_symbol_files;
99 MonoDebuggerSymbolFile **symbol_files;
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.
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.
113 guint32 num_type_tables;
114 guint32 type_table_chunk_size;
115 gpointer *type_tables;
117 * Current type table.
118 * The `current_type_table' points to a blob of `type_table_chunk_size'
121 gpointer current_type_table;
123 * This is the total size of the type table, including all the tables
124 * in the `type_tables' vector.
126 guint32 type_table_size;
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'.
132 guint32 type_table_offset;
133 guint32 type_table_start;
138 guint32 num_misc_tables;
139 guint32 misc_table_chunk_size;
140 gpointer *misc_tables;
141 gpointer current_misc_table;
142 guint32 misc_table_size;
143 guint32 misc_table_offset;
144 guint32 misc_table_start;
147 struct _MonoDebuggerSymbolFile {
149 MonoSymbolFile *symfile;
151 const char *image_file;
152 guint32 class_entry_size;
153 /* Pointer to the malloced range table. */
156 MonoDebuggerRangeInfo *range_table;
157 guint32 range_entry_size;
158 guint32 num_range_entries;
159 /* Pointer to the malloced class table. */
160 MonoDebuggerClassInfo *class_table;
161 guint32 num_class_entries;
163 MonoDebuggerSymbolFilePriv *_priv;
166 struct _MonoDebuggerRangeInfo {
167 const guint8 *start_address;
168 const guint8 *end_address;
170 gpointer dynamic_data;
171 guint32 dynamic_size;
174 struct _MonoDebuggerClassInfo {
182 MONO_DEBUGGER_MISC_ENTRY_TYPE_UNKNOWN = 0,
183 MONO_DEBUGGER_MISC_ENTRY_TYPE_WRAPPER
186 extern MonoDebuggerSymbolTable *mono_debugger_symbol_table;
189 * Address of the x86 trampoline code. This is used by the debugger to check
190 * whether a method is a trampoline.
192 extern guint8 *mono_generic_trampoline_code;
194 #ifndef PLATFORM_WIN32
197 * Functions we export to the debugger.
199 struct _MonoDebuggerIOLayer
201 void (*InitializeCriticalSection) (WapiCriticalSection *section);
202 void (*DeleteCriticalSection) (WapiCriticalSection *section);
203 gboolean (*TryEnterCriticalSection) (WapiCriticalSection *section);
204 void (*EnterCriticalSection) (WapiCriticalSection *section);
205 void (*LeaveCriticalSection) (WapiCriticalSection *section);
207 guint32 (*WaitForSingleObject) (gpointer handle, guint32 timeout);
208 guint32 (*SignalObjectAndWait) (gpointer signal_handle, gpointer wait,
209 guint32 timeout, gboolean alertable);
210 guint32 (*WaitForMultipleObjects) (guint32 numobjects, gpointer *handles,
211 gboolean waitall, guint32 timeout);
213 gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
214 gint32 initial, gint32 max,
216 gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
218 gpointer (*CreateThread) (WapiSecurityAttributes *security,
219 guint32 stacksize, WapiThreadStart start,
220 gpointer param, guint32 create, guint32 *tid);
221 guint32 (*GetCurrentThreadId) (void);
224 extern MonoDebuggerIOLayer mono_debugger_io_layer;
228 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, guint32 arg);
230 void mono_debugger_initialize (MonoDomain *domain);
231 void mono_debugger_cleanup (void);
233 void mono_debugger_lock (void);
234 void mono_debugger_unlock (void);
235 void mono_debugger_event (MonoDebuggerEvent event, gpointer data, guint32 arg);
237 MonoDebuggerSymbolFile *mono_debugger_add_symbol_file (MonoDebugHandle *handle);
238 void mono_debugger_add_type (MonoDebuggerSymbolFile *symfile, MonoClass *klass);
239 MonoDebuggerBuiltinTypes *mono_debugger_add_builtin_types (MonoDebuggerSymbolFile *symfile);
241 void mono_debugger_add_method (MonoDebuggerSymbolFile *symfile,
242 MonoDebugMethodInfo *minfo,
243 MonoDebugMethodJitInfo *jit);
245 void mono_debugger_add_wrapper (MonoMethod *wrapper,
246 MonoDebugMethodJitInfo *jit,
250 int mono_debugger_insert_breakpoint_full (MonoMethodDesc *desc);
251 int mono_debugger_remove_breakpoint (int breakpoint_id);
252 int mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
253 int mono_debugger_method_has_breakpoint (MonoMethod *method);
254 void mono_debugger_breakpoint_callback (MonoMethod *method, guint32 idx);
256 gpointer mono_debugger_create_notification_function (gpointer *notification_address);
258 MonoObject *mono_debugger_runtime_invoke (MonoMethod *method, void *obj,
259 void **params, MonoObject **exc);
261 guint32 mono_debugger_lookup_type (const gchar *type_name);
262 gint32 mono_debugger_lookup_assembly (const gchar *name);
263 gboolean mono_debugger_unhandled_exception (gpointer addr, MonoObject *exc);
267 mono_vtable_get_static_field_data (MonoVTable *vt);
270 MonoReflectionMethod *
271 ves_icall_MonoDebugger_GetMethod (MonoReflectionAssembly *assembly, guint32 token);
274 ves_icall_MonoDebugger_GetMethodToken (MonoReflectionAssembly *assembly, MonoReflectionMethod *method);
277 ves_icall_MonoDebugger_GetLocalTypeFromSignature (MonoReflectionAssembly *assembly, MonoArray *signature);
280 ves_icall_MonoDebugger_GetType (MonoReflectionAssembly *assembly, guint32 token);
282 #endif /* __MONO_DEBUG_DEBUGGER_H__ */