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