Merge pull request #225 from mistoll/master
[mono.git] / mono / metadata / debug-mono-symfile.h
1 /*
2  * This header is only installed for use by the debugger:
3  * the structures and the API declared here are not supported.
4  */
5
6 #ifndef __MONO_DEBUG_MONO_SYMFILE_H__
7 #define __MONO_DEBUG_MONO_SYMFILE_H__
8
9 #include <glib.h>
10 #include <mono/metadata/class.h>
11 #include <mono/metadata/reflection.h>
12 #include <mono/metadata/mono-debug.h>
13
14 typedef struct MonoSymbolFileOffsetTable        MonoSymbolFileOffsetTable;
15 typedef struct MonoSymbolFileLineNumberEntry    MonoSymbolFileLineNumberEntry;
16 typedef struct MonoSymbolFileMethodAddress      MonoSymbolFileMethodAddress;
17 typedef struct MonoSymbolFileDynamicTable       MonoSymbolFileDynamicTable;
18 typedef struct MonoSymbolFileSourceEntry        MonoSymbolFileSourceEntry;
19 typedef struct MonoSymbolFileMethodEntry        MonoSymbolFileMethodEntry;
20
21 /* Keep in sync with OffsetTable in mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs */
22 struct MonoSymbolFileOffsetTable {
23         uint32_t _total_file_size;
24         uint32_t _data_section_offset;
25         uint32_t _data_section_size;
26         uint32_t _compile_unit_count;
27         uint32_t _compile_unit_table_offset;
28         uint32_t _compile_unit_table_size;
29         uint32_t _source_count;
30         uint32_t _source_table_offset;
31         uint32_t _source_table_size;
32         uint32_t _method_count;
33         uint32_t _method_table_offset;
34         uint32_t _method_table_size;
35         uint32_t _type_count;
36         uint32_t _anonymous_scope_count;
37         uint32_t _anonymous_scope_table_offset;
38         uint32_t _anonymous_scope_table_size;
39         uint32_t _line_number_table_line_base;
40         uint32_t _line_number_table_line_range;
41         uint32_t _line_number_table_opcode_base;
42         uint32_t _is_aspx_source;
43 };
44
45 struct MonoSymbolFileSourceEntry {
46         uint32_t _index;
47         uint32_t _data_offset;
48 };
49
50 struct MonoSymbolFileMethodEntry {
51         uint32_t _token;
52         uint32_t _data_offset;
53         uint32_t _line_number_table;
54 };
55
56 struct MonoSymbolFileMethodAddress {
57         uint32_t size;
58         const uint8_t *start_address;
59         const uint8_t *end_address;
60         const uint8_t *method_start_address;
61         const uint8_t *method_end_address;
62         const uint8_t *wrapper_address;
63         uint32_t has_this;
64         uint32_t num_params;
65         uint32_t variable_table_offset;
66         uint32_t type_table_offset;
67         uint32_t num_line_numbers;
68         uint32_t line_number_offset;
69         uint8_t data [MONO_ZERO_LEN_ARRAY];
70 };
71
72 struct _MonoDebugMethodInfo {
73         MonoMethod *method;
74         MonoDebugHandle *handle;
75         uint32_t index;
76         uint32_t data_offset;
77         uint32_t lnt_offset;
78 };
79
80 typedef struct {
81         int parent;
82         int type;
83         /* IL offsets */
84         int start_offset, end_offset;
85 } MonoDebugCodeBlock;
86
87 typedef struct {
88         char *name;
89         int index;
90         /* Might be null for the main scope */
91         MonoDebugCodeBlock *block;
92 } MonoDebugLocalVar;
93
94 /*
95  * Information about local variables retrieved from a symbol file.
96  */
97 struct _MonoDebugLocalsInfo {
98         int num_locals;
99         MonoDebugLocalVar *locals;
100         int num_blocks;
101         MonoDebugCodeBlock *code_blocks;
102 };
103
104 struct _MonoDebugLineNumberEntry {
105         uint32_t il_offset;
106         uint32_t native_offset;
107 };
108
109 /*
110  * Information about a source file retrieved from a symbol file.
111  */
112 typedef struct {
113         char *source_file;
114         /* 16 byte long */
115         guint8 *guid, *hash;
116 } MonoDebugSourceInfo;
117
118 #define MONO_SYMBOL_FILE_MAJOR_VERSION          50
119 #define MONO_SYMBOL_FILE_MINOR_VERSION          0
120 #define MONO_SYMBOL_FILE_MAGIC                  0x45e82623fd7fa614ULL
121
122 MONO_BEGIN_DECLS
123
124 MonoSymbolFile *
125 mono_debug_open_mono_symbols       (MonoDebugHandle          *handle,
126                                     const uint8_t            *raw_contents,
127                                     int                       size,
128                                     mono_bool                 in_the_debugger);
129
130 void
131 mono_debug_close_mono_symbol_file  (MonoSymbolFile           *symfile);
132
133 mono_bool
134 mono_debug_symfile_is_loaded       (MonoSymbolFile           *symfile);
135
136 MonoDebugSourceLocation *
137 mono_debug_symfile_lookup_location (MonoDebugMethodInfo      *minfo,
138                                     uint32_t                  offset);
139
140 void
141 mono_debug_symfile_free_location   (MonoDebugSourceLocation  *location);
142
143 int32_t
144 _mono_debug_address_from_il_offset (MonoDebugMethodJitInfo   *jit,
145                                     uint32_t                  il_offset);
146
147 MonoDebugMethodInfo *
148 mono_debug_symfile_lookup_method   (MonoDebugHandle          *handle,
149                                     MonoMethod               *method);
150
151 MonoDebugLocalsInfo*
152 mono_debug_symfile_lookup_locals (MonoDebugMethodInfo *minfo);
153
154 void
155 mono_debug_symfile_free_locals (MonoDebugLocalsInfo *info);
156
157 void
158 mono_debug_symfile_get_line_numbers (MonoDebugMethodInfo *minfo, char **source_file, int *n_il_offsets, int **il_offsets, int **line_numbers);
159
160 void
161 mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int *n_il_offsets, int **il_offsets, int **line_numbers, int **source_files);
162
163 MONO_END_DECLS
164
165 #endif /* __MONO_SYMFILE_H__ */
166