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_H__
7 #define __MONO_DEBUG_H__
10 #include <mono/metadata/image.h>
11 #include <mono/metadata/appdomain.h>
13 typedef struct _MonoSymbolTable MonoSymbolTable;
15 typedef struct _MonoSymbolFile MonoSymbolFile;
16 typedef struct _MonoSymbolFilePriv MonoSymbolFilePriv;
18 typedef struct _MonoDebugHandle MonoDebugHandle;
19 typedef struct _MonoDebugHandlePriv MonoDebugHandlePriv;
21 typedef struct _MonoDebugLineNumberEntry MonoDebugLineNumberEntry;
22 typedef struct _MonoDebugLexicalBlockEntry MonoDebugLexicalBlockEntry;
24 typedef struct _MonoDebugVarInfo MonoDebugVarInfo;
25 typedef struct _MonoDebugMethodJitInfo MonoDebugMethodJitInfo;
26 typedef struct _MonoDebugMethodAddress MonoDebugMethodAddress;
27 typedef struct _MonoDebugWrapperData MonoDebugWrapperData;
28 typedef struct _MonoDebugClassEntry MonoDebugClassEntry;
30 typedef struct _MonoDebuggerMetadataInfo MonoDebuggerMetadataInfo;
33 MONO_DEBUG_FORMAT_NONE,
34 MONO_DEBUG_FORMAT_MONO,
35 MONO_DEBUG_FORMAT_DEBUGGER
39 MONO_DEBUGGER_TYPE_KIND_UNKNOWN = 1,
40 MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL,
41 MONO_DEBUGGER_TYPE_KIND_STRING,
42 MONO_DEBUGGER_TYPE_KIND_SZARRAY,
43 MONO_DEBUGGER_TYPE_KIND_ARRAY,
44 MONO_DEBUGGER_TYPE_KIND_POINTER,
45 MONO_DEBUGGER_TYPE_KIND_ENUM,
46 MONO_DEBUGGER_TYPE_KIND_OBJECT,
47 MONO_DEBUGGER_TYPE_KIND_STRUCT,
48 MONO_DEBUGGER_TYPE_KIND_CLASS,
49 MONO_DEBUGGER_TYPE_KIND_CLASS_INFO,
50 MONO_DEBUGGER_TYPE_KIND_REFERENCE
51 } MonoDebuggerTypeKind;
53 struct _MonoSymbolTable {
59 * Corlib and metadata info.
61 MonoDebugHandle *corlib;
62 MonoDebuggerMetadataInfo *metadata_info;
67 MonoDebugHandle **symbol_files;
68 guint32 num_symbol_files;
72 * This is intentionally not a GPtrArray to make it more easy to
73 * read for the debugger. The `data_tables' field contains
74 * `num_data_tables' pointers to continuous memory areas.
76 * The data table is basically a big continuous blob, but we need
77 * to split it up into pieces because we don't know the total size
78 * in advance and using g_realloc() doesn't work because that may
79 * reallocate the block to a different address.
81 guint32 num_data_tables;
82 gpointer *data_tables;
85 * The `current_data_table' points to a blob of `current_data_table_size'
88 gpointer current_data_table;
89 guint32 current_data_table_size;
91 * The offset in the `current_data_table'.
93 guint32 current_data_table_offset;
97 MONO_DEBUG_DATA_ITEM_UNKNOWN = 0,
98 MONO_DEBUG_DATA_ITEM_METHOD,
99 MONO_DEBUG_DATA_ITEM_CLASS,
100 MONO_DEBUG_DATA_ITEM_WRAPPER
101 } MonoDebugDataItemType;
103 struct _MonoDebugHandle {
105 const char *image_file;
107 MonoSymbolFile *symfile;
108 MonoDebugHandlePriv *_priv;
111 struct _MonoDebugMethodJitInfo {
112 MonoDebugMethodAddress *address;
113 const guint8 *code_start;
115 guint32 prologue_end;
116 guint32 epilogue_begin;
117 const guint8 *wrapper_addr;
118 guint32 num_line_numbers;
119 MonoDebugLineNumberEntry *line_numbers;
120 guint32 num_lexical_blocks;
121 MonoDebugLexicalBlockEntry *lexical_blocks;
123 MonoDebugVarInfo *this_var;
124 MonoDebugVarInfo *params;
126 MonoDebugVarInfo *locals;
129 struct _MonoDebugMethodAddress {
136 const guint8 *code_start;
137 const guint8 *wrapper_addr;
138 MonoDebugMethodJitInfo *jit;
139 guint8 data [MONO_ZERO_LEN_ARRAY];
142 struct _MonoDebugWrapperData {
146 const guint8 *code_start;
148 const gchar *cil_code;
149 guint8 data [MONO_ZERO_LEN_ARRAY];
152 struct _MonoDebugClassEntry {
155 guint8 data [MONO_ZERO_LEN_ARRAY];
159 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
160 * where the variable is actually stored.
162 * See relocate_variable() in debug-symfile.c for more info.
164 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
166 /* The variable is in register "index". */
167 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0
169 /* The variable is at offset "offset" from register "index". */
170 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000
172 /* The variable is in the two registers "offset" and "index". */
173 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
175 struct _MonoDebugVarInfo {
183 #define MONO_DEBUGGER_VERSION 53
184 #define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
186 extern MonoSymbolTable *mono_symbol_table;
187 extern MonoDebugFormat mono_debug_format;
188 extern GHashTable *mono_debug_handles;
190 void mono_debug_init (MonoDebugFormat format);
191 void mono_debug_init_1 (MonoDomain *domain);
192 void mono_debug_init_2 (MonoAssembly *assembly);
193 void mono_debug_cleanup (void);
195 gboolean mono_debug_using_mono_debugger (void);
197 MonoDebugMethodAddress *mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit,
199 MonoDebugMethodJitInfo *mono_debug_read_method (MonoDebugMethodAddress *address);
200 void mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
201 gchar *mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
202 guint32 *line_number, MonoDomain *domain);
203 gchar *mono_debug_source_location_from_il_offset (MonoMethod *method, guint32 offset,
204 guint32 *line_number);
205 gint32 mono_debug_il_offset_from_address (MonoMethod *method, gint32 address, MonoDomain *domain);
206 gint32 mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset, MonoDomain *domain);
209 * Mono Debugger support functions
211 * These methods are used by the JIT while running inside the Mono Debugger.
214 int mono_debugger_method_has_breakpoint (MonoMethod *method);
215 int mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
216 gboolean mono_debugger_unhandled_exception (gpointer addr, gpointer stack, MonoObject *exc);
217 void mono_debugger_handle_exception (gpointer addr, gpointer stack, MonoObject *exc);
218 gboolean mono_debugger_throw_exception (gpointer addr, gpointer stack, MonoObject *exc);
220 #endif /* __MONO_DEBUG_H__ */