2005-05-11 Chris Toshok <toshok@ximian.com>
[mono.git] / mono / metadata / mono-debug.h
blob44c7e86d93ad8b6ca55de27ff1dc4de6d6126aae
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 _MonoDebugClassEntry MonoDebugClassEntry;
29 typedef struct _MonoDebuggerMetadataInfo MonoDebuggerMetadataInfo;
31 typedef enum {
32 MONO_DEBUG_FORMAT_NONE,
33 MONO_DEBUG_FORMAT_MONO,
34 MONO_DEBUG_FORMAT_DEBUGGER
35 } MonoDebugFormat;
37 typedef enum {
38 MONO_DEBUGGER_TYPE_KIND_UNKNOWN = 1,
39 MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL,
40 MONO_DEBUGGER_TYPE_KIND_STRING,
41 MONO_DEBUGGER_TYPE_KIND_SZARRAY,
42 MONO_DEBUGGER_TYPE_KIND_ARRAY,
43 MONO_DEBUGGER_TYPE_KIND_POINTER,
44 MONO_DEBUGGER_TYPE_KIND_ENUM,
45 MONO_DEBUGGER_TYPE_KIND_OBJECT,
46 MONO_DEBUGGER_TYPE_KIND_STRUCT,
47 MONO_DEBUGGER_TYPE_KIND_CLASS,
48 MONO_DEBUGGER_TYPE_KIND_CLASS_INFO,
49 MONO_DEBUGGER_TYPE_KIND_REFERENCE
50 } MonoDebuggerTypeKind;
52 struct _MonoSymbolTable {
53 guint64 magic;
54 guint32 version;
55 guint32 total_size;
58 * Corlib and metadata info.
60 MonoDebugHandle *corlib;
61 MonoDebuggerMetadataInfo *metadata_info;
64 * The symbol files.
66 MonoDebugHandle **symbol_files;
67 guint32 num_symbol_files;
70 * Data table.
71 * This is intentionally not a GPtrArray to make it more easy to
72 * read for the debugger. The `data_tables' field contains
73 * `num_data_tables' pointers to continuous memory areas.
75 * The data table is basically a big continuous blob, but we need
76 * to split it up into pieces because we don't know the total size
77 * in advance and using g_realloc() doesn't work because that may
78 * reallocate the block to a different address.
80 guint32 num_data_tables;
81 gpointer *data_tables;
83 * Current data table.
84 * The `current_data_table' points to a blob of `current_data_table_size'
85 * bytes.
87 gpointer current_data_table;
88 guint32 current_data_table_size;
90 * The offset in the `current_data_table'.
92 guint32 current_data_table_offset;
95 typedef enum {
96 MONO_DEBUG_DATA_ITEM_UNKNOWN = 0,
97 MONO_DEBUG_DATA_ITEM_METHOD,
98 MONO_DEBUG_DATA_ITEM_CLASS
99 } MonoDebugDataItemType;
101 struct _MonoDebugHandle {
102 guint32 index;
103 const char *image_file;
104 MonoImage *image;
105 MonoSymbolFile *symfile;
106 MonoDebugHandlePriv *_priv;
109 struct _MonoDebugMethodJitInfo {
110 MonoDebugMethodAddress *address;
111 const guint8 *code_start;
112 guint32 code_size;
113 guint32 prologue_end;
114 guint32 epilogue_begin;
115 const guint8 *wrapper_addr;
116 guint32 num_line_numbers;
117 MonoDebugLineNumberEntry *line_numbers;
118 guint32 num_lexical_blocks;
119 MonoDebugLexicalBlockEntry *lexical_blocks;
120 guint32 num_params;
121 MonoDebugVarInfo *this_var;
122 MonoDebugVarInfo *params;
123 guint32 num_locals;
124 MonoDebugVarInfo *locals;
127 struct _MonoDebugMethodAddress {
128 guint32 size;
129 guint32 symfile_id;
130 guint32 domain_id;
131 guint32 method_id;
132 const guint8 *code_start;
133 guint32 code_size;
134 const guint8 *wrapper_addr;
135 MonoDebugMethodJitInfo *jit;
136 guint8 data [MONO_ZERO_LEN_ARRAY];
139 struct _MonoDebugClassEntry {
140 guint32 size;
141 guint32 symfile_id;
142 guint8 data [MONO_ZERO_LEN_ARRAY];
146 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
147 * where the variable is actually stored.
149 * See relocate_variable() in debug-symfile.c for more info.
151 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
153 /* The variable is in register "index". */
154 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0
156 /* The variable is at offset "offset" from register "index". */
157 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000
159 /* The variable is in the two registers "offset" and "index". */
160 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
162 struct _MonoDebugVarInfo {
163 guint32 index;
164 guint32 offset;
165 guint32 size;
166 guint32 begin_scope;
167 guint32 end_scope;
170 #define MONO_DEBUGGER_VERSION 50
171 #define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
173 extern MonoSymbolTable *mono_symbol_table;
174 extern MonoDebugFormat mono_debug_format;
175 extern GHashTable *mono_debug_handles;
177 void mono_debug_init (MonoDebugFormat format);
178 void mono_debug_init_1 (MonoDomain *domain);
179 void mono_debug_init_2 (MonoAssembly *assembly);
180 void mono_debug_cleanup (void);
182 MonoDebugMethodAddress *mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit,
183 MonoDomain *domain);
184 MonoDebugMethodJitInfo *mono_debug_read_method (MonoDebugMethodAddress *address);
185 void mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
186 gchar *mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
187 guint32 *line_number, MonoDomain *domain);
188 gchar *mono_debug_source_location_from_il_offset (MonoMethod *method, guint32 offset,
189 guint32 *line_number);
190 gint32 mono_debug_il_offset_from_address (MonoMethod *method, gint32 address, MonoDomain *domain);
191 gint32 mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset, MonoDomain *domain);
193 #endif /* __MONO_DEBUG_H__ */