1 #ifndef __MONO_DEBUG_MONO_SYMFILE_H__
2 #define __MONO_DEBUG_MONO_SYMFILE_H__
5 #include <mono/metadata/class.h>
6 #include <mono/metadata/reflection.h>
8 typedef struct MonoSymbolFile MonoSymbolFile;
9 typedef struct MonoGlobalSymbolFile MonoGlobalSymbolFile;
10 typedef struct MonoSymbolFilePriv MonoSymbolFilePriv;
11 typedef struct MonoSymbolFileOffsetTable MonoSymbolFileOffsetTable;
12 typedef struct MonoSymbolFileLineNumberEntry MonoSymbolFileLineNumberEntry;
13 typedef struct MonoSymbolFileMethodEntry MonoSymbolFileMethodEntry;
14 typedef struct MonoSymbolFileMethodAddress MonoSymbolFileMethodAddress;
15 typedef struct MonoSymbolFileDynamicTable MonoSymbolFileDynamicTable;
17 typedef struct MonoDebugMethodInfo MonoDebugMethodInfo;
18 typedef struct MonoDebugMethodJitInfo MonoDebugMethodJitInfo;
19 typedef struct MonoDebugVarInfo MonoDebugVarInfo;
20 typedef struct MonoDebugLineNumberEntry MonoDebugLineNumberEntry;
21 typedef struct MonoDebugRangeInfo MonoDebugRangeInfo;
22 typedef struct MonoDebugClassInfo MonoDebugClassInfo;
24 /* Keep in sync with OffsetTable in mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs */
25 struct MonoSymbolFileOffsetTable {
26 guint32 total_file_size;
27 guint32 source_table_offset;
28 guint32 source_table_size;
30 guint32 method_table_offset;
31 guint32 method_table_size;
32 guint32 line_number_table_offset;
33 guint32 line_number_table_size;
34 guint32 local_variable_table_offset;
35 guint32 local_variable_table_size;
36 guint32 source_file_table_offset;
37 guint32 source_file_table_size;
38 guint32 source_file_count;
40 guint32 type_index_table_offset;
41 guint32 type_index_table_size;
44 struct MonoSymbolFileMethodEntry {
48 guint32 this_type_index;
49 guint32 num_parameters;
51 guint32 num_line_numbers;
52 guint32 type_index_table_offset;
53 guint32 local_variable_table_offset;
54 guint32 source_file_offset;
55 guint32 line_number_table_offset;
58 struct MonoSymbolFileMethodAddress {
60 const guint8 *start_address;
61 const guint8 *end_address;
62 const guint8 *method_start_address;
63 const guint8 *method_end_address;
64 const guint8 *wrapper_address;
65 guint32 variable_table_offset;
66 guint32 type_table_offset;
67 guint32 num_line_numbers;
68 guint32 line_number_offset;
69 guint8 data [MONO_ZERO_LEN_ARRAY];
72 struct MonoSymbolFileLineNumberEntry {
77 struct MonoDebugMethodInfo {
79 MonoSymbolFile *symfile;
81 guint32 num_il_offsets;
84 MonoSymbolFileLineNumberEntry *il_offsets;
85 MonoDebugMethodJitInfo *jit;
89 struct MonoDebugLineNumberEntry {
95 struct MonoDebugMethodJitInfo {
96 const guint8 *code_start;
99 guint32 epilogue_begin;
100 const guint8 *wrapper_addr;
101 // Array of MonoDebugLineNumberEntry
102 GArray *line_numbers;
104 MonoDebugVarInfo *this_var;
105 MonoDebugVarInfo *params;
107 MonoDebugVarInfo *locals;
111 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
112 * where the variable is actually stored.
114 * See relocate_variable() in debug-symfile.c for more info.
116 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
118 /* If "index" is zero, the variable is at stack offset "offset". */
119 #define MONO_DEBUG_VAR_ADDRESS_MODE_STACK 0
121 /* The variable is in the register whose number is contained in bits 0..4 of the
122 * "index" field plus an offset of "offset" (which can be zero).
124 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0x10000000
126 /* The variables in in the two registers whose numbers are contained in bits 0..4
127 * and 5..9 of the "index" field plus an offset of "offset" (which can be zero).
129 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
131 struct MonoDebugVarInfo {
139 struct MonoDebugRangeInfo {
140 const guint8 *start_address;
141 const guint8 *end_address;
143 gpointer dynamic_data;
144 guint32 dynamic_size;
147 struct MonoDebugClassInfo {
155 * This is shared between all symbol files.
157 struct MonoGlobalSymbolFile {
160 * This is intentionally not a GPtrArray to make it more easy to
161 * read for the debugger. The `type_tables' field contains
162 * `num_type_tables' pointers to continuous memory areas of
163 * `type_table_chunk_size' bytes each.
165 * The type table is basically a big continuous blob, but we need
166 * to split it up into pieces because we don't know the total size
167 * in advance and using g_realloc() doesn't work because that may
168 * reallocate the block to a different address.
170 guint32 num_type_tables;
171 guint32 type_table_chunk_size;
172 gpointer *type_tables;
174 * Current type table.
175 * The `current_type_table' points to a blob of `type_table_chunk_size'
178 gpointer current_type_table;
180 * This is the total size of the type table, including all the tables
181 * in the `type_tables' vector.
183 guint32 type_table_size;
185 * These are global offsets - the `current_type_table' starts at global
186 * offset `type_table_start' and we've already allocated stuff in it
187 * until offset `type_table_offset'.
189 guint32 type_table_offset;
190 guint32 type_table_start;
193 struct MonoSymbolFile {
196 guint64 dynamic_magic;
197 guint32 dynamic_version;
201 MonoGlobalSymbolFile *global;
202 /* Pointer to the mmap()ed contents of the file. */
203 guint8 *raw_contents;
204 guint32 raw_contents_size;
205 /* Pointer to the malloced string table. */
206 guint8 *string_table;
207 guint32 string_table_size;
208 /* Pointer to the malloced range table. */
211 MonoDebugRangeInfo *range_table;
212 guint32 range_entry_size;
213 guint32 num_range_entries;
214 /* Pointer to the malloced class table. */
215 MonoDebugClassInfo *class_table;
216 guint32 class_entry_size;
217 guint32 num_class_entries;
219 MonoSymbolFilePriv *_priv;
222 #define MONO_SYMBOL_FILE_VERSION 28
223 #define MONO_SYMBOL_FILE_MAGIC 0x45e82623fd7fa614
225 #define MONO_SYMBOL_FILE_DYNAMIC_VERSION 21
226 #define MONO_SYMBOL_FILE_DYNAMIC_MAGIC 0x7aff65af4253d427
228 extern MonoGlobalSymbolFile *mono_debugger_global_symbol_file;
231 mono_debug_open_mono_symbol_file (MonoImage *image,
232 const char *filename,
233 gboolean emit_warnings);
236 mono_debug_symfile_add_method (MonoSymbolFile *symfile,
240 mono_debug_symfile_add_type (MonoSymbolFile *symfile,
244 mono_debug_close_mono_symbol_file (MonoSymbolFile *symfile);
247 mono_debug_create_mono_symbol_file (MonoImage *image);
250 mono_debug_find_source_location (MonoSymbolFile *symfile,
253 guint32 *line_number);
255 MonoDebugMethodInfo *
256 mono_debug_find_method (MonoSymbolFile *symfile,
259 MonoReflectionMethod *
260 ves_icall_MonoDebugger_GetMethod (MonoReflectionAssembly *assembly,
264 ves_icall_MonoDebugger_GetLocalTypeFromSignature (MonoReflectionAssembly *assembly,
265 MonoArray *signature);
268 ves_icall_MonoDebugger_GetType (MonoReflectionAssembly *assembly,
271 #endif /* __MONO_SYMFILE_H__ */