blob: 2ac1c3772d4146892ab4d3e1fea3334e762b2414 [file] [log] [blame]
sewardjaf44c822007-11-25 14:01:38 +00001/*
2 This file is part of drd, a data race detector.
3
sewardj85642922008-01-14 11:54:56 +00004 Copyright (C) 2006-2008 Bart Van Assche
sewardjaf44c822007-11-25 14:01:38 +00005 bart.vanassche@gmail.com
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307, USA.
21
22 The GNU General Public License is contained in the file COPYING.
23*/
24
25
26// A bitmap is a data structure that contains information about which
27// addresses have been accessed for reading or writing within a given
28// segment.
29
30
31#ifndef __DRD_BITMAP_H
32#define __DRD_BITMAP_H
33
34
35#include "pub_tool_basics.h" /* Addr, SizeT */
36
37
38// Constant definitions.
39
40#define LHS_R (1<<0)
41#define LHS_W (1<<1)
42#define RHS_R (1<<2)
43#define RHS_W (1<<3)
44#define HAS_RACE(a) ((((a) & RHS_W) && ((a) & (LHS_R | LHS_W))) \
45 || (((a) & LHS_W) && ((a) & (RHS_R | RHS_W))))
46
47
48// Forward declarations.
49struct bitmap;
50
51
52// Datatype definitions.
53typedef enum { eLoad, eStore } BmAccessTypeT;
54
55
56// Function declarations.
57struct bitmap* bm_new(void);
58void bm_delete(struct bitmap* const bm);
59void bm_access_range(struct bitmap* const bm,
bart9036dea2008-03-13 19:10:06 +000060 const Addr a1, const Addr a2,
bart0268dfa2008-03-11 20:10:21 +000061 const BmAccessTypeT access_type);
sewardjaf44c822007-11-25 14:01:38 +000062void bm_access_4(struct bitmap* const bm,
63 const Addr address,
64 const BmAccessTypeT access_type);
65Bool bm_has(const struct bitmap* const bm,
66 const Addr a1,
67 const Addr a2,
68 const BmAccessTypeT access_type);
69Bool bm_has_any(const struct bitmap* const bm,
70 const Addr a1,
71 const Addr a2,
72 const BmAccessTypeT access_type);
73UWord bm_has_any_access(const struct bitmap* const bm,
74 const Addr a1,
75 const Addr a2);
76UWord bm_has_1(const struct bitmap* const bm,
77 const Addr address,
78 const BmAccessTypeT access_type);
79void bm_clear_all(const struct bitmap* const bm);
80void bm_clear(const struct bitmap* const bm,
81 const Addr a1,
82 const Addr a2);
83Bool bm_has_conflict_with(const struct bitmap* const bm,
84 const Addr a1,
85 const Addr a2,
86 const BmAccessTypeT access_type);
87void bm_swap(struct bitmap* const bm1, struct bitmap* const bm2);
88void bm_merge2(struct bitmap* const lhs,
89 const struct bitmap* const rhs);
90int bm_has_races(const struct bitmap* const bm1,
91 const struct bitmap* const bm2);
92void bm_report_races(ThreadId const tid1, ThreadId const tid2,
93 const struct bitmap* const bm1,
94 const struct bitmap* const bm2);
95void bm_print(const struct bitmap* bm);
96ULong bm_get_bitmap_creation_count(void);
97ULong bm_get_bitmap2_creation_count(void);
sewardjaf44c822007-11-25 14:01:38 +000098
99
100#endif /* __DRD_BITMAP_H */