update the man page too match last changes
[mono.git] / mono / metadata / mono-debug.h
bloba63914e1e3c068e39c9515b3f7bf5e673fb332fd
1 /*
2 * This header is only installed for use by the debugger:
3 * the structures and the API declared here are not supported.
4 */
6 #ifndef __MONO_DEBUG_H__
7 #define __MONO_DEBUG_H__
9 #include <glib.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 _MonoDebugMethodInfo MonoDebugMethodInfo;
31 typedef struct _MonoDebugSourceLocation MonoDebugSourceLocation;
33 typedef enum {
34 MONO_DEBUG_FORMAT_NONE,
35 MONO_DEBUG_FORMAT_MONO,
36 MONO_DEBUG_FORMAT_DEBUGGER
37 } MonoDebugFormat;
39 typedef enum {
40 MONO_DEBUGGER_TYPE_KIND_UNKNOWN = 1,
41 MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL,
42 MONO_DEBUGGER_TYPE_KIND_STRING,
43 MONO_DEBUGGER_TYPE_KIND_SZARRAY,
44 MONO_DEBUGGER_TYPE_KIND_ARRAY,
45 MONO_DEBUGGER_TYPE_KIND_POINTER,
46 MONO_DEBUGGER_TYPE_KIND_ENUM,
47 MONO_DEBUGGER_TYPE_KIND_OBJECT,
48 MONO_DEBUGGER_TYPE_KIND_STRUCT,
49 MONO_DEBUGGER_TYPE_KIND_CLASS,
50 MONO_DEBUGGER_TYPE_KIND_CLASS_INFO,
51 MONO_DEBUGGER_TYPE_KIND_REFERENCE
52 } MonoDebuggerTypeKind;
54 struct _MonoSymbolTable {
55 guint64 magic;
56 guint32 version;
57 guint32 total_size;
60 * Corlib and metadata info.
62 MonoDebugHandle *corlib;
65 * The symbol files.
67 MonoDebugHandle **symbol_files;
68 guint32 num_symbol_files;
71 * Data table.
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;
84 * Current data table.
85 * The `current_data_table' points to a blob of `current_data_table_size'
86 * bytes.
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;
96 typedef enum {
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 {
104 guint32 index;
105 char *image_file;
106 MonoImage *image;
107 MonoSymbolFile *symfile;
108 MonoDebugHandlePriv *_priv;
111 struct _MonoDebugMethodJitInfo {
112 MonoDebugMethodAddress *address;
113 const guint8 *code_start;
114 guint32 code_size;
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;
122 guint32 num_params;
123 MonoDebugVarInfo *this_var;
124 MonoDebugVarInfo *params;
125 guint32 num_locals;
126 MonoDebugVarInfo *locals;
129 struct _MonoDebugMethodAddress {
130 guint32 size;
131 guint32 symfile_id;
132 guint32 domain_id;
133 guint32 method_id;
134 guint32 code_size;
135 guint32 dummy;
136 const guint8 *code_start;
137 const guint8 *wrapper_addr;
138 MonoDebugMethodJitInfo *jit;
139 guint8 data [MONO_ZERO_LEN_ARRAY];
142 struct _MonoDebugWrapperData {
143 guint32 size;
144 guint32 code_size;
145 MonoMethod *method;
146 const guint8 *code_start;
147 const gchar *name;
148 const gchar *cil_code;
149 guint8 data [MONO_ZERO_LEN_ARRAY];
152 struct _MonoDebugClassEntry {
153 guint32 size;
154 guint32 symfile_id;
155 guint8 data [MONO_ZERO_LEN_ARRAY];
158 struct _MonoDebugSourceLocation {
159 gchar *source_file;
160 guint32 row, column;
161 guint32 il_offset;
165 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
166 * where the variable is actually stored.
168 * See relocate_variable() in debug-symfile.c for more info.
170 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
172 /* The variable is in register "index". */
173 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0
175 /* The variable is at offset "offset" from register "index". */
176 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000
178 /* The variable is in the two registers "offset" and "index". */
179 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
181 struct _MonoDebugVarInfo {
182 guint32 index;
183 guint32 offset;
184 guint32 size;
185 guint32 begin_scope;
186 guint32 end_scope;
189 #define MONO_DEBUGGER_VERSION 58
190 #define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
192 extern MonoSymbolTable *mono_symbol_table;
193 extern MonoDebugFormat mono_debug_format;
194 extern GHashTable *mono_debug_handles;
196 void mono_debug_init (MonoDebugFormat format);
197 void mono_debug_init_1 (MonoDomain *domain);
198 void mono_debug_init_2 (MonoAssembly *assembly);
199 void mono_debug_init_2_memory (MonoImage *image, const guint8 *raw_contents, int size);
200 void mono_debug_cleanup (void);
202 gboolean mono_debug_using_mono_debugger (void);
204 MonoDebugMethodAddress *mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit,
205 MonoDomain *domain);
206 MonoDebugMethodJitInfo *mono_debug_read_method (MonoDebugMethodAddress *address);
207 void mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
209 MonoDebugMethodInfo *mono_debug_lookup_method (MonoMethod *method);
211 MonoDebugMethodJitInfo*
212 mono_debug_find_method (MonoDebugMethodInfo *minfo, MonoDomain *domain);
215 * Line number support.
218 MonoDebugSourceLocation *
219 mono_debug_lookup_source_location (MonoMethod *method, guint32 address, MonoDomain *domain);
221 void
222 mono_debug_free_source_location (MonoDebugSourceLocation *location);
224 gchar *
225 mono_debug_print_stack_frame (MonoMethod *method, guint32 native_offset, MonoDomain *domain);
228 * Mono Debugger support functions
230 * These methods are used by the JIT while running inside the Mono Debugger.
233 int mono_debugger_method_has_breakpoint (MonoMethod *method);
234 int mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
235 gboolean mono_debugger_unhandled_exception (gpointer addr, gpointer stack, MonoObject *exc);
236 void mono_debugger_handle_exception (gpointer addr, gpointer stack, MonoObject *exc);
237 gboolean mono_debugger_throw_exception (gpointer addr, gpointer stack, MonoObject *exc);
239 #endif /* __MONO_DEBUG_H__ */