2 This file is part of drd, a thread error detector.
4 Copyright (C) 2006-2020 Bart Van Assche <bvanassche@acm.org>.
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
19 The GNU General Public License is contained in the file COPYING.
28 * Segments and segment lists. A segment represents information about
29 * a contiguous group of statements of a specific thread. There is a vector
30 * clock associated with each segment.
35 #include "pub_drd_bitmap.h"
36 #include "pub_tool_execontext.h" // ExeContext
37 #include "pub_tool_stacktrace.h" // StackTrace
40 typedef struct segment
42 struct segment
* g_next
;
43 struct segment
* g_prev
;
44 /** Pointers to next and previous segments executed by the same thread. */
45 struct segment
* thr_next
;
46 struct segment
* thr_prev
;
48 /** Reference count: number of pointers that point to this segment. */
50 /** Stack trace of the first instruction of the segment. */
51 ExeContext
* stacktrace
;
52 /** Vector clock associated with the segment. */
55 * Bitmap representing the memory accesses by the instructions associated
61 extern Segment
* DRD_(g_sg_list
);
63 Segment
* DRD_(sg_new
)(const DrdThreadId creator
, const DrdThreadId created
);
64 static int DRD_(sg_get_refcnt
)(const Segment
* const sg
);
65 Segment
* DRD_(sg_get
)(Segment
* const sg
);
66 void DRD_(sg_put
)(Segment
* const sg
);
67 static struct bitmap
* DRD_(sg_bm
)(Segment
* const sg
);
68 void DRD_(sg_merge
)(Segment
* const sg1
, Segment
* const sg2
);
69 void DRD_(sg_print
)(Segment
* const sg
);
70 Bool
DRD_(sg_get_trace
)(void);
71 void DRD_(sg_set_trace
)(const Bool trace_segment
);
72 ULong
DRD_(sg_get_segments_created_count
)(void);
73 ULong
DRD_(sg_get_segments_alive_count
)(void);
74 ULong
DRD_(sg_get_max_segments_alive_count
)(void);
75 ULong
DRD_(sg_get_segment_merge_count
)(void);
78 /** Query the reference count of the specified segment. */
79 static __inline__
int DRD_(sg_get_refcnt
)(const Segment
* const sg
)
81 #ifdef ENABLE_DRD_CONSISTENCY_CHECKS
88 /** Return the pointer to the bitmap of the segment. */
89 static __inline__
struct bitmap
* DRD_(sg_bm
)(Segment
* const sg
)
91 #ifdef ENABLE_DRD_CONSISTENCY_CHECKS
100 #endif // __SEGMENT_H