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