[corlib] Fixed StringBuilder construction bugs in marshalling caused by changes to...
[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 token;
85         MonoSeqPointInfo* seq_points;
86         gboolean free_seq_points;
87 } SeqPointDataEntry;
88
89 typedef struct {
90         SeqPointDataEntry* entries;
91         int entry_count;
92         int entry_capacity;
93 } SeqPointData;
94
95 void
96 seq_point_data_init (SeqPointData *data, int entry_capacity);
97
98 void
99 seq_point_data_free (SeqPointData *data);
100
101 gboolean
102 seq_point_data_read (SeqPointData *data, char *path);
103
104 gboolean
105 seq_point_data_write (SeqPointData *data, char *path);
106
107 void
108 seq_point_data_add (SeqPointData *data, guint32 token, MonoSeqPointInfo* info);
109
110 gboolean
111 seq_point_data_get (SeqPointData *data, guint32 token, MonoSeqPointInfo** info);
112
113 gboolean
114 seq_point_data_get_il_offset (char *path, guint32 token, guint32 native_offset, guint32 *il_offset);
115
116 #endif /* __MONO_SEQ_POINTS_DATA_H__ */