[2020-02] Fix leak in assembly-specific dllmap lookups (#21053)
[mono-project.git] / mono / metadata / seq-points-data.h
blob8d07f442203412e903f3f95d784871c6b3873141
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 */
7 #ifndef __MONO_SEQ_POINTS_DATA_H__
8 #define __MONO_SEQ_POINTS_DATA_H__
10 #include <glib.h>
12 #define MONO_SEQ_POINT_FLAG_NONEMPTY_STACK 1
13 #define MONO_SEQ_POINT_FLAG_EXIT_IL 2
14 #define MONO_SEQ_POINT_FLAG_NESTED_CALL 4
16 /* IL offsets used to mark the sequence points belonging to method entry/exit events */
17 #define METHOD_ENTRY_IL_OFFSET -1
18 #define METHOD_EXIT_IL_OFFSET 0xffffff
20 #define SEQ_POINT_AOT_EXT ".msym"
22 /* Native offset used to mark seq points in dead code */
23 #define SEQ_POINT_NATIVE_OFFSET_DEAD_CODE -1
25 typedef struct {
26 int il_offset, native_offset, flags;
27 /* Offset of indexes of successor sequence points on the compressed buffer */
28 int next_offset;
29 /* Number of entries in next */
30 int next_len;
31 } SeqPoint;
33 typedef struct MonoSeqPointInfo {
34 int dummy [1];
35 } MonoSeqPointInfo;
37 typedef struct {
38 SeqPoint seq_point;
39 guint8* ptr;
40 guint8* begin;
41 guint8* end;
42 gboolean has_debug_data;
43 } SeqPointIterator;
45 void
46 mono_seq_point_info_free (gpointer info);
48 gboolean
49 mono_seq_point_iterator_next (SeqPointIterator* it);
51 void
52 mono_seq_point_iterator_init (SeqPointIterator* it, MonoSeqPointInfo* info);
54 void
55 mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next);
57 int
58 mono_seq_point_info_write (MonoSeqPointInfo* info, guint8* buffer);
60 int
61 mono_seq_point_info_read (MonoSeqPointInfo** info, guint8* buffer, gboolean copy);
63 int
64 mono_seq_point_info_get_write_size (MonoSeqPointInfo* info);
66 gboolean
67 mono_seq_point_info_add_seq_point (GByteArray* array, SeqPoint *sp, SeqPoint *last_seq_point, GSList *next, gboolean has_debug_data);
69 MonoSeqPointInfo*
70 mono_seq_point_info_new (int len, gboolean alloc_data, guint8 *data, gboolean has_debug_data, int *out_size);
72 gboolean
73 mono_seq_point_find_prev_by_native_offset (MonoSeqPointInfo* info, int native_offset, SeqPoint* seq_point);
75 gboolean
76 mono_seq_point_find_next_by_native_offset (MonoSeqPointInfo* info, int native_offset, SeqPoint* seq_point);
78 gboolean
79 mono_seq_point_find_by_il_offset (MonoSeqPointInfo* info, int il_offset, SeqPoint* seq_point);
82 * SeqPointData struct and functions
83 * This is used to store/load/use sequence point from a file
86 typedef struct {
87 guint32 method_token;
88 guint32 method_index;
89 MonoSeqPointInfo* seq_points;
90 gboolean free_seq_points;
91 } SeqPointDataEntry;
93 typedef struct {
94 SeqPointDataEntry* entries;
95 int entry_count;
96 int entry_capacity;
97 } SeqPointData;
99 void
100 mono_seq_point_data_init (SeqPointData *data, int entry_capacity);
102 void
103 mono_seq_point_data_free (SeqPointData *data);
105 gboolean
106 mono_seq_point_data_read (SeqPointData *data, char *path);
108 gboolean
109 mono_seq_point_data_write (SeqPointData *data, char *path);
111 void
112 mono_seq_point_data_add (SeqPointData *data, guint32 methodToken, guint32 methodIndex, MonoSeqPointInfo* info);
114 gboolean
115 mono_seq_point_data_get (SeqPointData *data, guint32 methodToken, guint32 methodIndex, MonoSeqPointInfo** info);
117 gboolean
118 mono_seq_point_data_get_il_offset (char *path, guint32 methodToken, guint32 methodIndex, guint32 native_offset, guint32 *il_offset);
120 #endif /* __MONO_SEQ_POINTS_DATA_H__ */