1 #ifndef __MONO_DEBUG_DEBUGGER_H__
2 #define __MONO_DEBUG_DEBUGGER_H__
5 #include <mono/metadata/debug-helpers.h>
6 #include <mono/metadata/debug-mono-symfile.h>
7 #include <mono/io-layer/io-layer.h>
9 typedef struct _MonoDebuggerBreakpointInfo MonoDebuggerBreakpointInfo;
10 typedef struct _MonoDebuggerBuiltinTypeInfo MonoDebuggerBuiltinTypeInfo;
11 typedef struct _MonoDebuggerBuiltinTypes MonoDebuggerBuiltinTypes;
12 typedef struct _MonoDebuggerSymbolTable MonoDebuggerSymbolTable;
13 typedef struct _MonoDebuggerSymbolFile MonoDebuggerSymbolFile;
14 typedef struct _MonoDebuggerSymbolFilePriv MonoDebuggerSymbolFilePriv;
15 typedef struct _MonoDebuggerRangeInfo MonoDebuggerRangeInfo;
16 typedef struct _MonoDebuggerClassInfo MonoDebuggerClassInfo;
17 typedef struct _MonoDebuggerIOLayer MonoDebuggerIOLayer;
20 MONO_DEBUGGER_EVENT_BREAKPOINT,
21 MONO_DEBUGGER_EVENT_RELOAD_SYMTABS
25 MONO_DEBUGGER_TYPE_KIND_UNKNOWN = 1,
26 MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL,
27 MONO_DEBUGGER_TYPE_KIND_STRING,
28 MONO_DEBUGGER_TYPE_KIND_SZARRAY,
29 MONO_DEBUGGER_TYPE_KIND_ARRAY,
30 MONO_DEBUGGER_TYPE_KIND_POINTER,
31 MONO_DEBUGGER_TYPE_KIND_ENUM,
32 MONO_DEBUGGER_TYPE_KIND_OBJECT,
33 MONO_DEBUGGER_TYPE_KIND_STRUCT,
34 MONO_DEBUGGER_TYPE_KIND_CLASS,
35 MONO_DEBUGGER_TYPE_KIND_CLASS_INFO
36 } MonoDebuggerTypeKind;
38 struct _MonoDebuggerBreakpointInfo {
43 struct _MonoDebuggerBuiltinTypeInfo
46 MonoDebuggerClassInfo *cinfo;
52 struct _MonoDebuggerBuiltinTypes {
54 guint32 type_info_size;
55 MonoDebuggerBuiltinTypeInfo *object_type;
56 MonoDebuggerBuiltinTypeInfo *byte_type;
57 MonoDebuggerBuiltinTypeInfo *void_type;
58 MonoDebuggerBuiltinTypeInfo *boolean_type;
59 MonoDebuggerBuiltinTypeInfo *sbyte_type;
60 MonoDebuggerBuiltinTypeInfo *int16_type;
61 MonoDebuggerBuiltinTypeInfo *uint16_type;
62 MonoDebuggerBuiltinTypeInfo *int32_type;
63 MonoDebuggerBuiltinTypeInfo *uint32_type;
64 MonoDebuggerBuiltinTypeInfo *int_type;
65 MonoDebuggerBuiltinTypeInfo *uint_type;
66 MonoDebuggerBuiltinTypeInfo *int64_type;
67 MonoDebuggerBuiltinTypeInfo *uint64_type;
68 MonoDebuggerBuiltinTypeInfo *single_type;
69 MonoDebuggerBuiltinTypeInfo *double_type;
70 MonoDebuggerBuiltinTypeInfo *char_type;
71 MonoDebuggerBuiltinTypeInfo *string_type;
72 MonoDebuggerBuiltinTypeInfo *enum_type;
73 MonoDebuggerBuiltinTypeInfo *array_type;
74 MonoDebuggerBuiltinTypeInfo *exception_type;
77 struct _MonoDebuggerSymbolTable {
83 * Corlib and builtin types.
86 MonoDebuggerSymbolFile *corlib;
87 MonoDebuggerBuiltinTypes *builtin_types;
92 guint32 num_symbol_files;
93 MonoDebuggerSymbolFile **symbol_files;
97 * This is intentionally not a GPtrArray to make it more easy to
98 * read for the debugger. The `type_tables' field contains
99 * `num_type_tables' pointers to continuous memory areas of
100 * `type_table_chunk_size' bytes each.
102 * The type table is basically a big continuous blob, but we need
103 * to split it up into pieces because we don't know the total size
104 * in advance and using g_realloc() doesn't work because that may
105 * reallocate the block to a different address.
107 guint32 num_type_tables;
108 guint32 type_table_chunk_size;
109 gpointer *type_tables;
111 * Current type table.
112 * The `current_type_table' points to a blob of `type_table_chunk_size'
115 gpointer current_type_table;
117 * This is the total size of the type table, including all the tables
118 * in the `type_tables' vector.
120 guint32 type_table_size;
122 * These are global offsets - the `current_type_table' starts at global
123 * offset `type_table_start' and we've already allocated stuff in it
124 * until offset `type_table_offset'.
126 guint32 type_table_offset;
127 guint32 type_table_start;
130 struct _MonoDebuggerSymbolFile {
132 MonoSymbolFile *symfile;
134 const char *image_file;
135 guint32 class_entry_size;
136 /* Pointer to the malloced range table. */
139 MonoDebuggerRangeInfo *range_table;
140 guint32 range_entry_size;
141 guint32 num_range_entries;
142 /* Pointer to the malloced class table. */
143 MonoDebuggerClassInfo *class_table;
144 guint32 num_class_entries;
146 MonoDebuggerSymbolFilePriv *_priv;
149 struct _MonoDebuggerRangeInfo {
150 const guint8 *start_address;
151 const guint8 *end_address;
153 gpointer dynamic_data;
154 guint32 dynamic_size;
157 struct _MonoDebuggerClassInfo {
164 extern MonoDebuggerSymbolTable *mono_debugger_symbol_table;
167 * Address of the x86 trampoline code. This is used by the debugger to check
168 * whether a method is a trampoline.
170 extern guint8 *mono_generic_trampoline_code;
172 #ifndef PLATFORM_WIN32
175 * Functions we export to the debugger.
177 struct _MonoDebuggerIOLayer
179 void (*InitializeCriticalSection) (WapiCriticalSection *section);
180 void (*DeleteCriticalSection) (WapiCriticalSection *section);
181 gboolean (*TryEnterCriticalSection) (WapiCriticalSection *section);
182 void (*EnterCriticalSection) (WapiCriticalSection *section);
183 void (*LeaveCriticalSection) (WapiCriticalSection *section);
185 guint32 (*WaitForSingleObject) (gpointer handle, guint32 timeout);
186 guint32 (*SignalObjectAndWait) (gpointer signal_handle, gpointer wait,
187 guint32 timeout, gboolean alertable);
188 guint32 (*WaitForMultipleObjects) (guint32 numobjects, gpointer *handles,
189 gboolean waitall, guint32 timeout);
191 gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
192 gint32 initial, gint32 max,
194 gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
196 gpointer (*CreateThread) (WapiSecurityAttributes *security,
197 guint32 stacksize, WapiThreadStart start,
198 gpointer param, guint32 create, guint32 *tid);
199 guint32 (*GetCurrentThreadId) (void);
202 extern MonoDebuggerIOLayer mono_debugger_io_layer;
206 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, guint32 arg);
208 void mono_debugger_initialize (MonoDomain *domain);
209 void mono_debugger_cleanup (void);
211 void mono_debugger_lock (void);
212 void mono_debugger_unlock (void);
213 void mono_debugger_event (MonoDebuggerEvent event, gpointer data, guint32 arg);
215 MonoDebuggerSymbolFile *mono_debugger_add_symbol_file (MonoDebugHandle *handle);
216 void mono_debugger_add_type (MonoDebuggerSymbolFile *symfile, MonoClass *klass);
217 MonoDebuggerBuiltinTypes *mono_debugger_add_builtin_types (MonoDebuggerSymbolFile *symfile);
219 void mono_debugger_add_method (MonoDebuggerSymbolFile *symfile,
220 MonoDebugMethodInfo *minfo,
221 MonoDebugMethodJitInfo *jit);
223 int mono_debugger_insert_breakpoint_full (MonoMethodDesc *desc);
224 int mono_debugger_remove_breakpoint (int breakpoint_id);
225 int mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
226 int mono_debugger_method_has_breakpoint (MonoMethod *method);
227 void mono_debugger_breakpoint_callback (MonoMethod *method, guint32 idx);
229 gpointer mono_debugger_create_notification_function (gpointer *notification_address);
231 MonoObject *mono_debugger_runtime_invoke (MonoMethod *method, void *obj,
232 void **params, MonoObject **exc);
234 guint32 mono_debugger_lookup_type (const gchar *type_name);
235 gint32 mono_debugger_lookup_assembly (const gchar *name);
239 MonoReflectionMethod *
240 ves_icall_MonoDebugger_GetMethod (MonoReflectionAssembly *assembly, guint32 token);
243 ves_icall_MonoDebugger_GetMethodToken (MonoReflectionAssembly *assembly, MonoReflectionMethod *method);
246 ves_icall_MonoDebugger_GetLocalTypeFromSignature (MonoReflectionAssembly *assembly, MonoArray *signature);
249 ves_icall_MonoDebugger_GetType (MonoReflectionAssembly *assembly, guint32 token);
251 #endif /* __MONO_DEBUG_DEBUGGER_H__ */