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