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;
14 typedef struct _MonoDebugDataTable MonoDebugDataTable;
16 typedef struct _MonoSymbolFile MonoSymbolFile;
17 typedef struct _MonoSymbolFilePriv MonoSymbolFilePriv;
19 typedef struct _MonoDebugHandle MonoDebugHandle;
20 typedef struct _MonoDebugHandlePriv MonoDebugHandlePriv;
22 typedef struct _MonoDebugLineNumberEntry MonoDebugLineNumberEntry;
23 typedef struct _MonoDebugLexicalBlockEntry MonoDebugLexicalBlockEntry;
25 typedef struct _MonoDebugVarInfo MonoDebugVarInfo;
26 typedef struct _MonoDebugMethodJitInfo MonoDebugMethodJitInfo;
27 typedef struct _MonoDebugMethodAddress MonoDebugMethodAddress;
28 typedef struct _MonoDebugMethodAddressList MonoDebugMethodAddressList;
29 typedef struct _MonoDebugClassEntry MonoDebugClassEntry;
31 typedef struct _MonoDebugMethodInfo MonoDebugMethodInfo;
32 typedef struct _MonoDebugSourceLocation MonoDebugSourceLocation;
35 MONO_DEBUG_FORMAT_NONE,
36 MONO_DEBUG_FORMAT_MONO,
37 MONO_DEBUG_FORMAT_DEBUGGER
41 MONO_DEBUGGER_TYPE_KIND_UNKNOWN = 1,
42 MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL,
43 MONO_DEBUGGER_TYPE_KIND_STRING,
44 MONO_DEBUGGER_TYPE_KIND_SZARRAY,
45 MONO_DEBUGGER_TYPE_KIND_ARRAY,
46 MONO_DEBUGGER_TYPE_KIND_POINTER,
47 MONO_DEBUGGER_TYPE_KIND_ENUM,
48 MONO_DEBUGGER_TYPE_KIND_OBJECT,
49 MONO_DEBUGGER_TYPE_KIND_STRUCT,
50 MONO_DEBUGGER_TYPE_KIND_CLASS,
51 MONO_DEBUGGER_TYPE_KIND_CLASS_INFO,
52 MONO_DEBUGGER_TYPE_KIND_REFERENCE
53 } MonoDebuggerTypeKind;
55 struct _MonoSymbolTable {
61 * Corlib and metadata info.
63 MonoDebugHandle *corlib;
68 MonoDebugHandle **symbol_files;
69 guint32 num_symbol_files;
73 * This is intentionally not a GPtrArray to make it more easy to
74 * read for the debugger. The `data_tables' field contains
75 * `num_data_tables' pointers to continuous memory areas.
77 * The data table is basically a big continuous blob, but we need
78 * to split it up into pieces because we don't know the total size
79 * in advance and using g_realloc() doesn't work because that may
80 * reallocate the block to a different address.
82 guint32 num_data_tables;
83 gpointer *data_tables;
86 struct _MonoDebugHandle {
90 MonoSymbolFile *symfile;
91 MonoDebugHandlePriv *_priv;
94 struct _MonoDebugMethodJitInfo {
95 const guint8 *code_start;
98 guint32 epilogue_begin;
99 const guint8 *wrapper_addr;
100 guint32 num_line_numbers;
101 MonoDebugLineNumberEntry *line_numbers;
102 guint32 num_lexical_blocks;
103 MonoDebugLexicalBlockEntry *lexical_blocks;
105 MonoDebugVarInfo *this_var;
106 MonoDebugVarInfo *params;
108 MonoDebugVarInfo *locals;
111 struct _MonoDebugMethodAddressList {
114 guint8 data [MONO_ZERO_LEN_ARRAY];
117 struct _MonoDebugClassEntry {
120 guint8 data [MONO_ZERO_LEN_ARRAY];
123 struct _MonoDebugSourceLocation {
130 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
131 * where the variable is actually stored.
133 * See relocate_variable() in debug-symfile.c for more info.
135 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
137 /* The variable is in register "index". */
138 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0
140 /* The variable is at offset "offset" from register "index". */
141 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000
143 /* The variable is in the two registers "offset" and "index". */
144 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
146 struct _MonoDebugVarInfo {
154 #define MONO_DEBUGGER_VERSION 59
155 #define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
157 extern MonoSymbolTable *mono_symbol_table;
158 extern MonoDebugDataTable *mono_debug_data_table;
159 extern MonoDebugFormat mono_debug_format;
160 extern GHashTable *mono_debug_handles;
161 extern gint32 mono_debug_debugger_version;
163 void mono_debug_init (MonoDebugFormat format);
164 void mono_debug_init_1 (MonoDomain *domain);
165 void mono_debug_init_2 (MonoAssembly *assembly);
166 void mono_debug_init_2_memory (MonoImage *image, const guint8 *raw_contents, int size);
167 void mono_debug_cleanup (void);
169 gboolean mono_debug_using_mono_debugger (void);
171 MonoDebugMethodAddress *
172 mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
174 MonoDebugMethodInfo *
175 mono_debug_lookup_method (MonoMethod *method);
177 MonoDebugMethodAddressList *
178 mono_debug_lookup_method_addresses (MonoMethod *method);
180 MonoDebugMethodJitInfo*
181 mono_debug_find_method (MonoMethod *method, MonoDomain *domain);
184 * Line number support.
187 MonoDebugSourceLocation *
188 mono_debug_lookup_source_location (MonoMethod *method, guint32 address, MonoDomain *domain);
191 mono_debug_free_source_location (MonoDebugSourceLocation *location);
194 mono_debug_print_stack_frame (MonoMethod *method, guint32 native_offset, MonoDomain *domain);
197 * Mono Debugger support functions
199 * These methods are used by the JIT while running inside the Mono Debugger.
202 int mono_debugger_method_has_breakpoint (MonoMethod *method);
203 int mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
204 gboolean mono_debugger_unhandled_exception (gpointer addr, gpointer stack, MonoObject *exc);
205 void mono_debugger_handle_exception (gpointer addr, gpointer stack, MonoObject *exc);
206 gboolean mono_debugger_throw_exception (gpointer addr, gpointer stack, MonoObject *exc);
208 #endif /* __MONO_DEBUG_H__ */