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