Merge pull request #1222 from LogosBible/uri-trycreate
[mono.git] / mono / metadata / seq-points-data.h
1 /*
2  * Copyright 2015 Xamarin Inc
3  */
4  
5 #ifndef __MONO_SEQ_POINTS_DATA_H__
6 #define __MONO_SEQ_POINTS_DATA_H__
7
8 #include <glib.h>
9
10 #define MONO_SEQ_POINT_FLAG_NONEMPTY_STACK 1
11 #define MONO_SEQ_POINT_FLAG_EXIT_IL 2
12
13 /* IL offsets used to mark the sequence points belonging to method entry/exit events */
14 #define METHOD_ENTRY_IL_OFFSET -1
15 #define METHOD_EXIT_IL_OFFSET 0xffffff
16
17 #define SEQ_POINT_AOT_EXT ".msym"
18
19 /* Native offset used to mark seq points in dead code */
20 #define SEQ_POINT_NATIVE_OFFSET_DEAD_CODE -1 
21
22 typedef struct {
23         int il_offset, native_offset, flags;
24         /* Offset of indexes of successor sequence points on the compressed buffer */
25         int next_offset;
26         /* Number of entries in next */
27         int next_len;
28 } SeqPoint;
29
30 typedef struct MonoSeqPointInfo {
31         int dummy[0];
32 } MonoSeqPointInfo;
33
34 typedef struct {
35         SeqPoint seq_point;
36         guint8* ptr;
37         guint8* begin;
38         guint8* end;
39         gboolean has_debug_data;
40 } SeqPointIterator;
41
42 void
43 seq_point_info_free (gpointer info);
44
45 gboolean
46 seq_point_iterator_next (SeqPointIterator* it);
47
48 void
49 seq_point_iterator_init (SeqPointIterator* it, MonoSeqPointInfo* info);
50
51 void
52 seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next);
53
54 int
55 seq_point_info_write (MonoSeqPointInfo* info, guint8* buffer);
56
57 int
58 seq_point_info_read (MonoSeqPointInfo** info, guint8* buffer, gboolean copy);
59
60 int
61 seq_point_info_get_write_size (MonoSeqPointInfo* info);
62
63 gboolean
64 seq_point_info_add_seq_point (GByteArray* array, SeqPoint *sp, SeqPoint *last_seq_point, GSList *next, gboolean has_debug_data);
65
66 MonoSeqPointInfo*
67 seq_point_info_new (int len, gboolean alloc_data, guint8 *data, gboolean has_debug_data, int *out_size);
68
69 gboolean
70 seq_point_find_prev_by_native_offset (MonoSeqPointInfo* info, int native_offset, SeqPoint* seq_point);
71
72 gboolean
73 seq_point_find_next_by_native_offset (MonoSeqPointInfo* info, int native_offset, SeqPoint* seq_point);
74
75 gboolean
76 seq_point_find_by_il_offset (MonoSeqPointInfo* info, int il_offset, SeqPoint* seq_point);
77
78 /*
79  * SeqPointData struct and functions
80  * This is used to store/load/use sequence point from a file
81  */
82
83 typedef struct {
84         guint32 method_token;
85         guint32 method_index;
86         MonoSeqPointInfo* seq_points;
87         gboolean free_seq_points;
88 } SeqPointDataEntry;
89
90 typedef struct {
91         SeqPointDataEntry* entries;
92         int entry_count;
93         int entry_capacity;
94 } SeqPointData;
95
96 void
97 seq_point_data_init (SeqPointData *data, int entry_capacity);
98
99 void
100 seq_point_data_free (SeqPointData *data);
101
102 gboolean
103 seq_point_data_read (SeqPointData *data, char *path);
104
105 gboolean
106 seq_point_data_write (SeqPointData *data, char *path);
107
108 void
109 seq_point_data_add (SeqPointData *data, guint32 methodToken, guint32 methodIndex, MonoSeqPointInfo* info);
110
111 gboolean
112 seq_point_data_get (SeqPointData *data, guint32 methodToken, guint32 methodIndex, MonoSeqPointInfo** info);
113
114 gboolean
115 seq_point_data_get_il_offset (char *path, guint32 methodToken, guint32 methodIndex, guint32 native_offset, guint32 *il_offset);
116
117 #endif /* __MONO_SEQ_POINTS_DATA_H__ */