blob: 012cca60e9fede0f73aee56e23371fae790351d3 [file] [log] [blame]
sewardjaf44c822007-11-25 14:01:38 +00001/*
bart86562bd2009-02-16 19:43:56 +00002 This file is part of drd, a thread error detector.
sewardjaf44c822007-11-25 14:01:38 +00003
bart86562bd2009-02-16 19:43:56 +00004 Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>.
sewardjaf44c822007-11-25 14:01:38 +00005
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.
10
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.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307, USA.
20
21 The GNU General Public License is contained in the file COPYING.
22*/
23
24
25#ifndef __SEGMENT_H
26#define __SEGMENT_H
27
28
bart62ada3f2009-02-14 17:19:58 +000029/*
30 * Segments and segment lists. A segment represents information about
31 * a contiguous group of statements of a specific thread. There is a vector
32 * clock associated with each segment.
33 */
sewardjaf44c822007-11-25 14:01:38 +000034
35
36#include "drd_vc.h"
37#include "pub_drd_bitmap.h"
38#include "pub_tool_execontext.h" // ExeContext
39#include "pub_tool_stacktrace.h" // StackTrace
40
41
42typedef struct segment
43{
bart62ada3f2009-02-14 17:19:58 +000044 /** Pointers to next and previous segments executed by the same thread. */
sewardjaf44c822007-11-25 14:01:38 +000045 struct segment* next;
46 struct segment* prev;
bart62ada3f2009-02-14 17:19:58 +000047 /** Reference count: number of pointers that point to this segment. */
barta2b6e1b2008-03-17 18:32:39 +000048 int refcnt;
bart62ada3f2009-02-14 17:19:58 +000049 /** Stack trace of the first instruction of the segment. */
sewardjaf44c822007-11-25 14:01:38 +000050 ExeContext* stacktrace;
bart62ada3f2009-02-14 17:19:58 +000051 /** Vector clock associated with the segment. */
sewardjaf44c822007-11-25 14:01:38 +000052 VectorClock vc;
bart62ada3f2009-02-14 17:19:58 +000053 /**
54 * Bitmap representing the memory accesses by the instructions associated
55 * with the segment.
56 */
sewardjaf44c822007-11-25 14:01:38 +000057 struct bitmap* bm;
58} Segment;
59
barta2b6e1b2008-03-17 18:32:39 +000060
bart2adfc2a2009-03-12 18:38:00 +000061Segment* DRD_(sg_new)(const DrdThreadId creator, const DrdThreadId created);
bart62ada3f2009-02-14 17:19:58 +000062int DRD_(sg_get_refcnt)(const Segment* const sg);
63Segment* DRD_(sg_get)(Segment* const sg);
64void DRD_(sg_put)(Segment* const sg);
65void DRD_(sg_merge)(const Segment* const sg1, Segment* const sg2);
66void DRD_(sg_print)(const Segment* const sg);
67Bool DRD_(sg_get_trace)(void);
68void DRD_(sg_set_trace)(const Bool trace_segment);
69ULong DRD_(sg_get_segments_created_count)(void);
70ULong DRD_(sg_get_segments_alive_count)(void);
71ULong DRD_(sg_get_max_segments_alive_count)(void);
sewardjaf44c822007-11-25 14:01:38 +000072
73
74#endif // __SEGMENT_H