First set of licensing changes
[mono.git] / mono / metadata / seq-points-data.h
1 /*
2  * Copyright 2015 Xamarin Inc
3  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
4  */
5  
6 #ifndef __MONO_SEQ_POINTS_DATA_H__
7 #define __MONO_SEQ_POINTS_DATA_H__
8
9 #include <glib.h>
10
11 #define MONO_SEQ_POINT_FLAG_NONEMPTY_STACK 1
12 #define MONO_SEQ_POINT_FLAG_EXIT_IL 2
13
14 /* IL offsets used to mark the sequence points belonging to method entry/exit events */
15 #define METHOD_ENTRY_IL_OFFSET -1
16 #define METHOD_EXIT_IL_OFFSET 0xffffff
17
18 #define SEQ_POINT_AOT_EXT ".msym"
19
20 /* Native offset used to mark seq points in dead code */
21 #define SEQ_POINT_NATIVE_OFFSET_DEAD_CODE -1 
22
23 typedef struct {
24         int il_offset, native_offset, flags;
25         /* Offset of indexes of successor sequence points on the compressed buffer */
26         int next_offset;
27         /* Number of entries in next */
28         int next_len;
29 } SeqPoint;
30
31 typedef struct MonoSeqPointInfo {
32         int dummy [1];
33 } MonoSeqPointInfo;
34
35 typedef struct {
36         SeqPoint seq_point;
37         guint8* ptr;
38         guint8* begin;
39         guint8* end;
40         gboolean has_debug_data;
41 } SeqPointIterator;
42
43 void
44 mono_seq_point_info_free (gpointer info);
45
46 gboolean
47 mono_seq_point_iterator_next (SeqPointIterator* it);
48
49 void
50 mono_seq_point_iterator_init (SeqPointIterator* it, MonoSeqPointInfo* info);
51
52 void
53 mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next);
54
55 int
56 mono_seq_point_info_write (MonoSeqPointInfo* info, guint8* buffer);
57
58 int
59 mono_seq_point_info_read (MonoSeqPointInfo** info, guint8* buffer, gboolean copy);
60
61 int
62 mono_seq_point_info_get_write_size (MonoSeqPointInfo* info);
63
64 gboolean
65 mono_seq_point_info_add_seq_point (GByteArray* array, SeqPoint *sp, SeqPoint *last_seq_point, GSList *next, gboolean has_debug_data);
66
67 MonoSeqPointInfo*
68 mono_seq_point_info_new (int len, gboolean alloc_data, guint8 *data, gboolean has_debug_data, int *out_size);
69
70 gboolean
71 mono_seq_point_find_prev_by_native_offset (MonoSeqPointInfo* info, int native_offset, SeqPoint* seq_point);
72
73 gboolean
74 mono_seq_point_find_next_by_native_offset (MonoSeqPointInfo* info, int native_offset, SeqPoint* seq_point);
75
76 gboolean
77 mono_seq_point_find_by_il_offset (MonoSeqPointInfo* info, int il_offset, SeqPoint* seq_point);
78
79 /*
80  * SeqPointData struct and functions
81  * This is used to store/load/use sequence point from a file
82  */
83
84 typedef struct {
85         guint32 method_token;
86         guint32 method_index;
87         MonoSeqPointInfo* seq_points;
88         gboolean free_seq_points;
89 } SeqPointDataEntry;
90
91 typedef struct {
92         SeqPointDataEntry* entries;
93         int entry_count;
94         int entry_capacity;
95 } SeqPointData;
96
97 void
98 mono_seq_point_data_init (SeqPointData *data, int entry_capacity);
99
100 void
101 mono_seq_point_data_free (SeqPointData *data);
102
103 gboolean
104 mono_seq_point_data_read (SeqPointData *data, char *path);
105
106 gboolean
107 mono_seq_point_data_write (SeqPointData *data, char *path);
108
109 void
110 mono_seq_point_data_add (SeqPointData *data, guint32 methodToken, guint32 methodIndex, MonoSeqPointInfo* info);
111
112 gboolean
113 mono_seq_point_data_get (SeqPointData *data, guint32 methodToken, guint32 methodIndex, MonoSeqPointInfo** info);
114
115 gboolean
116 mono_seq_point_data_get_il_offset (char *path, guint32 methodToken, guint32 methodIndex, guint32 native_offset, guint32 *il_offset);
117
118 #endif /* __MONO_SEQ_POINTS_DATA_H__ */