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;
16 typedef struct MonoSymbolFileSourceEntry MonoSymbolFileSourceEntry;
17 typedef struct MonoSymbolFileMethodIndexEntry MonoSymbolFileMethodIndexEntry;
19 typedef struct MonoDebugMethodInfo MonoDebugMethodInfo;
20 typedef struct MonoDebugMethodJitInfo MonoDebugMethodJitInfo;
21 typedef struct MonoDebugVarInfo MonoDebugVarInfo;
22 typedef struct MonoDebugLineNumberEntry MonoDebugLineNumberEntry;
23 typedef struct MonoDebugRangeInfo MonoDebugRangeInfo;
24 typedef struct MonoDebugClassInfo MonoDebugClassInfo;
26 /* Keep in sync with OffsetTable in mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs */
27 struct MonoSymbolFileOffsetTable {
28 guint32 total_file_size;
29 guint32 data_section_offset;
30 guint32 data_section_size;
32 guint32 source_table_offset;
33 guint32 source_table_size;
35 guint32 method_table_offset;
36 guint32 method_table_size;
40 struct MonoSymbolFileMethodEntry {
45 guint32 class_type_index;
46 guint32 num_parameters;
48 guint32 num_line_numbers;
50 guint32 full_name_offset;
51 guint32 type_index_table_offset;
52 guint32 local_variable_table_offset;
53 guint32 line_number_table_offset;
54 guint32 namespace_idx;
57 struct MonoSymbolFileSourceEntry {
60 guint32 num_namespaces;
62 guint32 method_offset;
63 guint32 nstable_offset;
66 struct MonoSymbolFileMethodIndexEntry {
68 guint32 full_name_offset;
72 struct MonoSymbolFileMethodAddress {
74 const guint8 *start_address;
75 const guint8 *end_address;
76 const guint8 *method_start_address;
77 const guint8 *method_end_address;
78 const guint8 *wrapper_address;
80 guint32 variable_table_offset;
81 guint32 type_table_offset;
82 guint32 num_line_numbers;
83 guint32 line_number_offset;
84 guint8 data [MONO_ZERO_LEN_ARRAY];
87 struct MonoSymbolFileLineNumberEntry {
92 struct MonoDebugMethodInfo {
94 MonoSymbolFile *symfile;
96 guint32 num_il_offsets;
99 MonoSymbolFileLineNumberEntry *il_offsets;
100 MonoDebugMethodJitInfo *jit;
104 struct MonoDebugLineNumberEntry {
110 struct MonoDebugMethodJitInfo {
111 const guint8 *code_start;
113 guint32 prologue_end;
114 guint32 epilogue_begin;
115 const guint8 *wrapper_addr;
116 // Array of MonoDebugLineNumberEntry
117 GArray *line_numbers;
119 MonoDebugVarInfo *this_var;
120 MonoDebugVarInfo *params;
122 MonoDebugVarInfo *locals;
126 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
127 * where the variable is actually stored.
129 * See relocate_variable() in debug-symfile.c for more info.
131 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
133 /* If "index" is zero, the variable is at stack offset "offset". */
134 #define MONO_DEBUG_VAR_ADDRESS_MODE_STACK 0
136 /* The variable is in the register whose number is contained in bits 0..4 of the
137 * "index" field plus an offset of "offset" (which can be zero).
139 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0x10000000
141 /* The variables in in the two registers whose numbers are contained in bits 0..4
142 * and 5..9 of the "index" field plus an offset of "offset" (which can be zero).
144 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
146 struct MonoDebugVarInfo {
154 struct MonoDebugRangeInfo {
155 const guint8 *start_address;
156 const guint8 *end_address;
158 gpointer dynamic_data;
159 guint32 dynamic_size;
162 struct MonoDebugClassInfo {
170 * This is shared between all symbol files.
172 struct MonoGlobalSymbolFile {
175 * This is intentionally not a GPtrArray to make it more easy to
176 * read for the debugger. The `type_tables' field contains
177 * `num_type_tables' pointers to continuous memory areas of
178 * `type_table_chunk_size' bytes each.
180 * The type table is basically a big continuous blob, but we need
181 * to split it up into pieces because we don't know the total size
182 * in advance and using g_realloc() doesn't work because that may
183 * reallocate the block to a different address.
185 guint32 num_type_tables;
186 guint32 type_table_chunk_size;
187 gpointer *type_tables;
189 * Current type table.
190 * The `current_type_table' points to a blob of `type_table_chunk_size'
193 gpointer current_type_table;
195 * This is the total size of the type table, including all the tables
196 * in the `type_tables' vector.
198 guint32 type_table_size;
200 * These are global offsets - the `current_type_table' starts at global
201 * offset `type_table_start' and we've already allocated stuff in it
202 * until offset `type_table_offset'.
204 guint32 type_table_offset;
205 guint32 type_table_start;
208 struct MonoSymbolFile {
209 guint64 dynamic_magic;
210 guint32 dynamic_version;
211 const char *image_file;
212 MonoGlobalSymbolFile *global;
213 /* Pointer to the malloced range table. */
216 MonoDebugRangeInfo *range_table;
217 guint32 range_entry_size;
218 guint32 num_range_entries;
219 /* Pointer to the malloced class table. */
220 MonoDebugClassInfo *class_table;
221 guint32 class_entry_size;
222 guint32 num_class_entries;
224 MonoSymbolFilePriv *_priv;
227 #define MONO_SYMBOL_FILE_VERSION 32
228 #define MONO_SYMBOL_FILE_MAGIC 0x45e82623fd7fa614
230 #define MONO_SYMBOL_FILE_DYNAMIC_VERSION 25
231 #define MONO_SYMBOL_FILE_DYNAMIC_MAGIC 0x7aff65af4253d427
233 extern MonoGlobalSymbolFile *mono_debugger_global_symbol_file;
236 mono_debug_open_mono_symbol_file (MonoImage *image,
237 gboolean create_symfile);
240 mono_debug_symfile_add_method (MonoSymbolFile *symfile,
244 mono_debug_symfile_add_type (MonoSymbolFile *symfile,
248 mono_debug_close_mono_symbol_file (MonoSymbolFile *symfile);
251 mono_debug_find_source_location (MonoSymbolFile *symfile,
254 guint32 *line_number);
256 MonoDebugMethodInfo *
257 mono_debug_find_method (MonoSymbolFile *symfile,
260 MonoReflectionMethod *
261 ves_icall_MonoDebugger_GetMethod (MonoReflectionAssembly *assembly,
265 ves_icall_MonoDebugger_GetMethodToken (MonoReflectionAssembly *assembly,
266 MonoReflectionMethod *method);
269 ves_icall_MonoDebugger_GetLocalTypeFromSignature (MonoReflectionAssembly *assembly,
270 MonoArray *signature);
273 ves_icall_MonoDebugger_GetType (MonoReflectionAssembly *assembly,
276 #endif /* __MONO_SYMFILE_H__ */