blob: 03ed89bc6085a68d952e215b1d8fe1159e928d91 [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#include "pub_tool_basics.h" // Addr, SizeT
27#include "pub_tool_debuginfo.h" // VG_(get_objname)()
28#include "pub_tool_libcassert.h" // tl_assert()
29#include "pub_tool_libcbase.h" // VG_(memset)
30#include "pub_tool_libcprint.h" // VG_(printf)
31#include "pub_tool_machine.h" // VG_(get_IP)()
32#include "pub_tool_mallocfree.h" // VG_(malloc), VG_(free)
33#include "pub_drd_bitmap.h"
34#include "drd_bitmap.h"
35#include "drd_error.h"
36#include "drd_suppression.h"
37
38
bartf647d342008-03-24 19:12:12 +000039/* Forward declarations. */
sewardjaf44c822007-11-25 14:01:38 +000040
bartf647d342008-03-24 19:12:12 +000041struct bitmap2;
sewardjaf44c822007-11-25 14:01:38 +000042
43
bartf647d342008-03-24 19:12:12 +000044/* Local function declarations. */
sewardjaf44c822007-11-25 14:01:38 +000045
46static void bm2_merge(struct bitmap2* const bm2l,
47 const struct bitmap2* const bm2r);
48
49
bartf647d342008-03-24 19:12:12 +000050/* Local constants. */
51
52static ULong s_bitmap_creation_count;
53
54
55/* Function definitions. */
sewardjaf44c822007-11-25 14:01:38 +000056
57struct bitmap* bm_new()
58{
bart33e56c92008-03-24 06:41:30 +000059 unsigned i;
bart3772a982008-03-15 08:11:03 +000060 struct bitmap* bm;
sewardjaf44c822007-11-25 14:01:38 +000061
bartf29205e2008-03-25 18:51:06 +000062 /* If this assert fails, fix the definition of BITS_PER_BITS_PER_UWORD */
63 /* in drd_bitmap.h. */
bart3772a982008-03-15 08:11:03 +000064 tl_assert((1 << BITS_PER_BITS_PER_UWORD) == BITS_PER_UWORD);
sewardjaf44c822007-11-25 14:01:38 +000065
bart3772a982008-03-15 08:11:03 +000066 bm = VG_(malloc)(sizeof(*bm));
67 tl_assert(bm);
bartf29205e2008-03-25 18:51:06 +000068 /* Cache initialization. a1 is initialized with a value that never can */
69 /* match any valid address: the upper ADDR0_BITS bits of a1 are always */
70 /* zero for a valid cache entry. */
bart33e56c92008-03-24 06:41:30 +000071 for (i = 0; i < N_CACHE_ELEM; i++)
72 {
bartf29205e2008-03-25 18:51:06 +000073 bm->cache[i].a1 = ~(UWord)1;
bart33e56c92008-03-24 06:41:30 +000074 bm->cache[i].bm2 = 0;
75 }
bartf647d342008-03-24 19:12:12 +000076 bm->oset = VG_(OSetGen_Create)(0, 0, VG_(malloc), VG_(free));
sewardjaf44c822007-11-25 14:01:38 +000077
bart3772a982008-03-15 08:11:03 +000078 s_bitmap_creation_count++;
sewardjaf44c822007-11-25 14:01:38 +000079
bart3772a982008-03-15 08:11:03 +000080 return bm;
sewardjaf44c822007-11-25 14:01:38 +000081}
82
83void bm_delete(struct bitmap* const bm)
84{
bartf647d342008-03-24 19:12:12 +000085 struct bitmap2* bm2;
86 struct bitmap2ref* bm2ref;
87
bart3772a982008-03-15 08:11:03 +000088 tl_assert(bm);
bartf647d342008-03-24 19:12:12 +000089
90 VG_(OSetGen_ResetIter)(bm->oset);
91 for ( ; (bm2ref = VG_(OSetGen_Next)(bm->oset)) != 0; )
92 {
93 bm2 = bm2ref->bm2;
94 tl_assert(bm2->refcnt >= 1);
95 if (--bm2->refcnt == 0)
96 {
97 VG_(free)(bm2);
98 }
99 }
100
bart3772a982008-03-15 08:11:03 +0000101 VG_(OSetGen_Destroy)(bm->oset);
102 VG_(free)(bm);
sewardjaf44c822007-11-25 14:01:38 +0000103}
104
105/**
bart36556122008-03-13 19:24:30 +0000106 * Record an access of type access_type at addresses a .. a + size - 1 in
sewardjaf44c822007-11-25 14:01:38 +0000107 * bitmap bm.
108 */
barta79df6e2008-03-14 17:07:51 +0000109static
sewardjaf44c822007-11-25 14:01:38 +0000110void bm_access_range(struct bitmap* const bm,
bart9036dea2008-03-13 19:10:06 +0000111 const Addr a1, const Addr a2,
bart0268dfa2008-03-11 20:10:21 +0000112 const BmAccessTypeT access_type)
sewardjaf44c822007-11-25 14:01:38 +0000113{
bart3772a982008-03-15 08:11:03 +0000114 Addr b, b_next;
bart36556122008-03-13 19:24:30 +0000115
bart3772a982008-03-15 08:11:03 +0000116 tl_assert(bm);
117 tl_assert(a1 < a2);
sewardjaf44c822007-11-25 14:01:38 +0000118
bart3772a982008-03-15 08:11:03 +0000119 for (b = a1; b < a2; b = b_next)
120 {
121 Addr b_start;
122 Addr b_end;
123 struct bitmap2* bm2;
124 SPLIT_ADDRESS(b);
bart36556122008-03-13 19:24:30 +0000125
bart3772a982008-03-15 08:11:03 +0000126 b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
127 if (b_next > a2)
128 {
129 b_next = a2;
130 }
bart36556122008-03-13 19:24:30 +0000131
bartf647d342008-03-24 19:12:12 +0000132 bm2 = bm2_lookup_or_insert_exclusive(bm, b1);
bart3772a982008-03-15 08:11:03 +0000133 tl_assert(bm2);
bart36556122008-03-13 19:24:30 +0000134
bart3772a982008-03-15 08:11:03 +0000135 if ((bm2->addr << ADDR0_BITS) < a1)
136 b_start = a1;
137 else
138 if ((bm2->addr << ADDR0_BITS) < a2)
139 b_start = (bm2->addr << ADDR0_BITS);
bart36556122008-03-13 19:24:30 +0000140 else
bart3772a982008-03-15 08:11:03 +0000141 break;
142 tl_assert(a1 <= b_start && b_start <= a2);
bart36556122008-03-13 19:24:30 +0000143
bart3772a982008-03-15 08:11:03 +0000144 if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
145 b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
146 else
147 b_end = a2;
148 tl_assert(a1 <= b_end && b_end <= a2);
149 tl_assert(b_start < b_end);
150 tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
bart36556122008-03-13 19:24:30 +0000151
bart0008f5b2008-03-22 17:07:39 +0000152 if (access_type == eLoad)
bart3772a982008-03-15 08:11:03 +0000153 {
bart0008f5b2008-03-22 17:07:39 +0000154 for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end - 1) & ADDR0_MASK); b0++)
bart36556122008-03-13 19:24:30 +0000155 {
bart3772a982008-03-15 08:11:03 +0000156 bm0_set(bm2->bm1.bm0_r, b0);
sewardjaf44c822007-11-25 14:01:38 +0000157 }
bart0008f5b2008-03-22 17:07:39 +0000158 }
159 else
160 {
161 for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end - 1) & ADDR0_MASK); b0++)
bart3772a982008-03-15 08:11:03 +0000162 {
163 bm0_set(bm2->bm1.bm0_w, b0);
164 }
165 }
166 }
sewardjaf44c822007-11-25 14:01:38 +0000167}
168
barta79df6e2008-03-14 17:07:51 +0000169static inline
170void bm_access_aligned_load(struct bitmap* const bm,
bartf8bc71d2008-03-15 11:42:34 +0000171 const Addr a1, const SizeT size)
barta79df6e2008-03-14 17:07:51 +0000172{
bart3772a982008-03-15 08:11:03 +0000173 struct bitmap2* bm2;
barta79df6e2008-03-14 17:07:51 +0000174
bartf647d342008-03-24 19:12:12 +0000175 bm2 = bm2_lookup_or_insert_exclusive(bm, a1 >> ADDR0_BITS);
bartf8bc71d2008-03-15 11:42:34 +0000176 bm0_set_range(bm2->bm1.bm0_r, a1 & ADDR0_MASK, size);
barta79df6e2008-03-14 17:07:51 +0000177}
178
179static inline
180void bm_access_aligned_store(struct bitmap* const bm,
bartf8bc71d2008-03-15 11:42:34 +0000181 const Addr a1, const SizeT size)
barta79df6e2008-03-14 17:07:51 +0000182{
bart3772a982008-03-15 08:11:03 +0000183 struct bitmap2* bm2;
barta79df6e2008-03-14 17:07:51 +0000184
bartf647d342008-03-24 19:12:12 +0000185 bm2 = bm2_lookup_or_insert_exclusive(bm, a1 >> ADDR0_BITS);
bartf8bc71d2008-03-15 11:42:34 +0000186 bm0_set_range(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size);
barta79df6e2008-03-14 17:07:51 +0000187}
188
bart36556122008-03-13 19:24:30 +0000189void bm_access_range_load(struct bitmap* const bm,
190 const Addr a1, const Addr a2)
191{
bart3772a982008-03-15 08:11:03 +0000192 bm_access_range(bm, a1, a2, eLoad);
bart36556122008-03-13 19:24:30 +0000193}
194
barta79df6e2008-03-14 17:07:51 +0000195void bm_access_load_1(struct bitmap* const bm, const Addr a1)
196{
bartf8bc71d2008-03-15 11:42:34 +0000197 bm_access_aligned_load(bm, a1, 1);
barta79df6e2008-03-14 17:07:51 +0000198}
199
200void bm_access_load_2(struct bitmap* const bm, const Addr a1)
201{
bart3772a982008-03-15 08:11:03 +0000202 if ((a1 & 1) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000203 bm_access_aligned_load(bm, a1, 2);
bart3772a982008-03-15 08:11:03 +0000204 else
205 bm_access_range(bm, a1, a1 + 2, eLoad);
barta79df6e2008-03-14 17:07:51 +0000206}
207
208void bm_access_load_4(struct bitmap* const bm, const Addr a1)
209{
bart3772a982008-03-15 08:11:03 +0000210 if ((a1 & 3) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000211 bm_access_aligned_load(bm, a1, 4);
bart3772a982008-03-15 08:11:03 +0000212 else
213 bm_access_range(bm, a1, a1 + 4, eLoad);
barta79df6e2008-03-14 17:07:51 +0000214}
215
216void bm_access_load_8(struct bitmap* const bm, const Addr a1)
217{
bart3772a982008-03-15 08:11:03 +0000218 if ((a1 & 7) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000219 bm_access_aligned_load(bm, a1, 8);
bart3772a982008-03-15 08:11:03 +0000220 else if ((a1 & 3) == 0)
221 {
bartf8bc71d2008-03-15 11:42:34 +0000222 bm_access_aligned_load(bm, a1 + 0, 4);
223 bm_access_aligned_load(bm, a1 + 4, 4);
bart3772a982008-03-15 08:11:03 +0000224 }
225 else
226 bm_access_range(bm, a1, a1 + 8, eLoad);
barta79df6e2008-03-14 17:07:51 +0000227}
228
229void bm_access_store_1(struct bitmap* const bm, const Addr a1)
230{
bartf8bc71d2008-03-15 11:42:34 +0000231 bm_access_aligned_store(bm, a1, 1);
barta79df6e2008-03-14 17:07:51 +0000232}
233
234void bm_access_store_2(struct bitmap* const bm, const Addr a1)
235{
bart3772a982008-03-15 08:11:03 +0000236 if ((a1 & 1) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000237 bm_access_aligned_store(bm, a1, 2);
bart3772a982008-03-15 08:11:03 +0000238 else
239 bm_access_range(bm, a1, a1 + 2, eStore);
barta79df6e2008-03-14 17:07:51 +0000240}
241
242void bm_access_store_4(struct bitmap* const bm, const Addr a1)
243{
bart3772a982008-03-15 08:11:03 +0000244 if ((a1 & 3) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000245 bm_access_aligned_store(bm, a1, 4);
bart3772a982008-03-15 08:11:03 +0000246 else
247 bm_access_range(bm, a1, a1 + 4, eStore);
barta79df6e2008-03-14 17:07:51 +0000248}
249
250void bm_access_store_8(struct bitmap* const bm, const Addr a1)
251{
bart3772a982008-03-15 08:11:03 +0000252 if ((a1 & 7) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000253 bm_access_aligned_store(bm, a1, 8);
bart3772a982008-03-15 08:11:03 +0000254 else if ((a1 & 3) == 0)
255 {
bartf8bc71d2008-03-15 11:42:34 +0000256 bm_access_aligned_store(bm, a1 + 0, 4);
257 bm_access_aligned_store(bm, a1 + 4, 4);
bart3772a982008-03-15 08:11:03 +0000258 }
259 else
260 bm_access_range(bm, a1, a1 + 8, eStore);
barta79df6e2008-03-14 17:07:51 +0000261}
262
bart36556122008-03-13 19:24:30 +0000263void bm_access_range_store(struct bitmap* const bm,
264 const Addr a1, const Addr a2)
265{
bart3772a982008-03-15 08:11:03 +0000266 bm_access_range(bm, a1, a2, eStore);
bart36556122008-03-13 19:24:30 +0000267}
268
269Bool bm_has(const struct bitmap* const bm, const Addr a1, const Addr a2,
sewardjaf44c822007-11-25 14:01:38 +0000270 const BmAccessTypeT access_type)
271{
bart3772a982008-03-15 08:11:03 +0000272 Addr b;
273 for (b = a1; b < a2; b++)
274 {
275 if (! bm_has_1(bm, b, access_type))
276 {
277 return False;
278 }
279 }
280 return True;
sewardjaf44c822007-11-25 14:01:38 +0000281}
282
283Bool bm_has_any(const struct bitmap* const bm,
bart36556122008-03-13 19:24:30 +0000284 const Addr a1, const Addr a2,
sewardjaf44c822007-11-25 14:01:38 +0000285 const BmAccessTypeT access_type)
286{
bart3772a982008-03-15 08:11:03 +0000287 Addr b;
sewardjaf44c822007-11-25 14:01:38 +0000288
bart3772a982008-03-15 08:11:03 +0000289 tl_assert(bm);
sewardjaf44c822007-11-25 14:01:38 +0000290
bart3772a982008-03-15 08:11:03 +0000291 for (b = a1; b < a2; b++)
292 {
293 if (bm_has_1(bm, b, access_type))
294 {
295 return True;
296 }
297 }
298 return False;
sewardjaf44c822007-11-25 14:01:38 +0000299}
300
301/* Return a non-zero value if there is a read access, write access or both */
302/* to any of the addresses in the range [ a1, a2 [ in bitmap bm. */
303UWord bm_has_any_access(const struct bitmap* const bm,
304 const Addr a1,
305 const Addr a2)
306{
bart3772a982008-03-15 08:11:03 +0000307 Addr b, b_next;
sewardjaf44c822007-11-25 14:01:38 +0000308
bart3772a982008-03-15 08:11:03 +0000309 tl_assert(bm);
sewardjaf44c822007-11-25 14:01:38 +0000310
bart3772a982008-03-15 08:11:03 +0000311 for (b = a1; b < a2; b = b_next)
312 {
bartf647d342008-03-24 19:12:12 +0000313 const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
sewardjaf44c822007-11-25 14:01:38 +0000314
bart3772a982008-03-15 08:11:03 +0000315 b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
316 if (b_next > a2)
317 {
318 b_next = a2;
319 }
sewardjaf44c822007-11-25 14:01:38 +0000320
bart3772a982008-03-15 08:11:03 +0000321 if (bm2)
322 {
323 Addr b_start;
324 Addr b_end;
325 UWord b0;
326 const struct bitmap1* const p1 = &bm2->bm1;
sewardjaf44c822007-11-25 14:01:38 +0000327
bart3772a982008-03-15 08:11:03 +0000328 if ((bm2->addr << ADDR0_BITS) < a1)
329 b_start = a1;
330 else
331 if ((bm2->addr << ADDR0_BITS) < a2)
332 b_start = (bm2->addr << ADDR0_BITS);
333 else
334 break;
335 tl_assert(a1 <= b_start && b_start <= a2);
sewardjaf44c822007-11-25 14:01:38 +0000336
bart3772a982008-03-15 08:11:03 +0000337 if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
338 b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
339 else
340 b_end = a2;
341 tl_assert(a1 <= b_end && b_end <= a2);
342 tl_assert(b_start < b_end);
343 tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
sewardjaf44c822007-11-25 14:01:38 +0000344
bart3772a982008-03-15 08:11:03 +0000345 for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
346 {
347 const UWord mask
348 = bm0_is_set(p1->bm0_r, b0) | bm0_is_set(p1->bm0_w, b0);
349 if (mask)
350 {
351 return mask;
352 }
sewardjaf44c822007-11-25 14:01:38 +0000353 }
bart3772a982008-03-15 08:11:03 +0000354 }
355 }
356 return 0;
sewardjaf44c822007-11-25 14:01:38 +0000357}
358
359/**
360 * Report whether an access of type access_type at address a is recorded in
361 * bitmap bm.
362 * @return != 0 means true, and == 0 means false
363 */
364UWord bm_has_1(const struct bitmap* const bm,
365 const Addr a,
366 const BmAccessTypeT access_type)
367{
bartf647d342008-03-24 19:12:12 +0000368 const struct bitmap2* p2;
369 const struct bitmap1* p1;
370 const UWord* p0;
bart3772a982008-03-15 08:11:03 +0000371 const UWord a0 = a & ADDR0_MASK;
sewardjaf44c822007-11-25 14:01:38 +0000372
bart3772a982008-03-15 08:11:03 +0000373 tl_assert(bm);
sewardjaf44c822007-11-25 14:01:38 +0000374
bart11d0b502008-03-22 16:44:03 +0000375 p2 = bm2_lookup(bm, a >> ADDR0_BITS);
bart3772a982008-03-15 08:11:03 +0000376 if (p2)
377 {
378 p1 = &p2->bm1;
379 p0 = (access_type == eLoad) ? p1->bm0_r : p1->bm0_w;
380 return bm0_is_set(p0, a0);
381 }
382 return 0;
sewardjaf44c822007-11-25 14:01:38 +0000383}
384
sewardjaf44c822007-11-25 14:01:38 +0000385void bm_clear(const struct bitmap* const bm,
386 const Addr a1,
387 const Addr a2)
388{
bart3772a982008-03-15 08:11:03 +0000389 Addr b, b_next;
sewardjaf44c822007-11-25 14:01:38 +0000390
bart3772a982008-03-15 08:11:03 +0000391 tl_assert(bm);
392 tl_assert(a1);
393 tl_assert(a1 <= a2);
sewardjaf44c822007-11-25 14:01:38 +0000394
bart3772a982008-03-15 08:11:03 +0000395 for (b = a1; b < a2; b = b_next)
396 {
bartf647d342008-03-24 19:12:12 +0000397 struct bitmap2* const p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
sewardjaf44c822007-11-25 14:01:38 +0000398
bart3772a982008-03-15 08:11:03 +0000399 b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
400 if (b_next > a2)
401 {
402 b_next = a2;
403 }
404
405 if (p2)
406 {
407 Addr c = b;
bartf647d342008-03-24 19:12:12 +0000408 /* If the first address in the bitmap that must be cleared does not */
bart5955f332008-03-25 17:19:20 +0000409 /* start on an UWord boundary, start clearing the first addresses. */
bart3772a982008-03-15 08:11:03 +0000410 if (UWORD_LSB(c))
sewardjaf44c822007-11-25 14:01:38 +0000411 {
bart3772a982008-03-15 08:11:03 +0000412 Addr c_next = UWORD_MSB(c) + BITS_PER_UWORD;
413 if (c_next > b_next)
414 c_next = b_next;
bart5955f332008-03-25 17:19:20 +0000415 bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, c_next - c);
416 bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, c_next - c);
bart3772a982008-03-15 08:11:03 +0000417 c = c_next;
sewardjaf44c822007-11-25 14:01:38 +0000418 }
bartf647d342008-03-24 19:12:12 +0000419 /* If some UWords have to be cleared entirely, do this now. */
bart3772a982008-03-15 08:11:03 +0000420 if (UWORD_LSB(c) == 0)
sewardjaf44c822007-11-25 14:01:38 +0000421 {
bart3772a982008-03-15 08:11:03 +0000422 const Addr c_next = UWORD_MSB(b_next);
423 tl_assert(UWORD_LSB(c) == 0);
424 tl_assert(UWORD_LSB(c_next) == 0);
425 tl_assert(c_next <= b_next);
426 tl_assert(c <= c_next);
427 if (c_next > c)
428 {
429 UWord idx = (c & ADDR0_MASK) >> BITS_PER_BITS_PER_UWORD;
430 VG_(memset)(&p2->bm1.bm0_r[idx], 0, (c_next - c) / 8);
431 VG_(memset)(&p2->bm1.bm0_w[idx], 0, (c_next - c) / 8);
432 c = c_next;
433 }
sewardjaf44c822007-11-25 14:01:38 +0000434 }
bartf647d342008-03-24 19:12:12 +0000435 /* If the last address in the bitmap that must be cleared does not */
bart5955f332008-03-25 17:19:20 +0000436 /* fall on an UWord boundary, clear the last addresses. */
437 /* tl_assert(c <= b_next); */
438 bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, b_next - c);
439 bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, b_next - c);
bart3772a982008-03-15 08:11:03 +0000440 }
441 }
sewardjaf44c822007-11-25 14:01:38 +0000442}
sewardjaf44c822007-11-25 14:01:38 +0000443
bart9c4224c2008-03-29 14:40:08 +0000444/** Clear all references to loads in bitmap bm starting at address a1 and
445 * up to but not including address a2.
446 */
447void bm_clear_load(const struct bitmap* const bm,
448 const Addr a1, const Addr a2)
449{
450 Addr a;
451
452 for (a = a1; a < a2; a++)
453 {
454 struct bitmap2* const p2 = bm2_lookup_exclusive(bm, a >> ADDR0_BITS);
455 if (p2)
456 {
457 bm0_clear(p2->bm1.bm0_r, a & ADDR0_MASK);
458 }
459 }
460}
461
462/** Clear all references to stores in bitmap bm starting at address a1 and
463 * up to but not including address a2.
464 */
465void bm_clear_store(const struct bitmap* const bm,
466 const Addr a1, const Addr a2)
467{
468 Addr a;
469
470 for (a = a1; a < a2; a++)
471 {
472 struct bitmap2* const p2 = bm2_lookup_exclusive(bm, a >> ADDR0_BITS);
473 if (p2)
474 {
475 bm0_clear(p2->bm1.bm0_w, a & ADDR0_MASK);
476 }
477 }
478}
479
bart8bf2f8b2008-03-30 17:56:43 +0000480/** Clear bitmap bm starting at address a1 and up to but not including address
481 * a2. Return True if and only if any of the addresses was set before
482 * clearing.
483 */
484Bool bm_test_and_clear(const struct bitmap* const bm,
485 const Addr a1, const Addr a2)
486{
487 Bool result;
488
489 result = bm_has_any_access(bm, a1, a2) != 0;
490 bm_clear(bm, a1, a2);
491 return result;
492}
493
bart36556122008-03-13 19:24:30 +0000494Bool bm_has_conflict_with(const struct bitmap* const bm,
495 const Addr a1, const Addr a2,
496 const BmAccessTypeT access_type)
sewardjaf44c822007-11-25 14:01:38 +0000497{
bart3772a982008-03-15 08:11:03 +0000498 Addr b, b_next;
sewardjaf44c822007-11-25 14:01:38 +0000499
bart3772a982008-03-15 08:11:03 +0000500 tl_assert(bm);
sewardjaf44c822007-11-25 14:01:38 +0000501
bart3772a982008-03-15 08:11:03 +0000502 for (b = a1; b < a2; b = b_next)
503 {
bartf647d342008-03-24 19:12:12 +0000504 const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
bart36556122008-03-13 19:24:30 +0000505
bart3772a982008-03-15 08:11:03 +0000506 b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
507 if (b_next > a2)
508 {
509 b_next = a2;
510 }
bart36556122008-03-13 19:24:30 +0000511
bart3772a982008-03-15 08:11:03 +0000512 if (bm2)
513 {
514 Addr b_start;
515 Addr b_end;
516 UWord b0;
517 const struct bitmap1* const p1 = &bm2->bm1;
bart36556122008-03-13 19:24:30 +0000518
bart3772a982008-03-15 08:11:03 +0000519 if ((bm2->addr << ADDR0_BITS) < a1)
520 b_start = a1;
521 else
522 if ((bm2->addr << ADDR0_BITS) < a2)
523 b_start = (bm2->addr << ADDR0_BITS);
524 else
525 break;
526 tl_assert(a1 <= b_start && b_start <= a2);
bart36556122008-03-13 19:24:30 +0000527
bart3772a982008-03-15 08:11:03 +0000528 if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
529 b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
530 else
531 b_end = a2;
532 tl_assert(a1 <= b_end && b_end <= a2);
533 tl_assert(b_start < b_end);
534 tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
bart36556122008-03-13 19:24:30 +0000535
bart3772a982008-03-15 08:11:03 +0000536 for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
537 {
538 if (access_type == eLoad)
539 {
540 if (bm0_is_set(p1->bm0_w, b0))
541 {
542 return True;
543 }
544 }
545 else
546 {
547 tl_assert(access_type == eStore);
548 if (bm0_is_set(p1->bm0_r, b0)
549 | bm0_is_set(p1->bm0_w, b0))
550 {
551 return True;
552 }
553 }
sewardjaf44c822007-11-25 14:01:38 +0000554 }
bart3772a982008-03-15 08:11:03 +0000555 }
556 }
557 return False;
sewardjaf44c822007-11-25 14:01:38 +0000558}
559
barta79df6e2008-03-14 17:07:51 +0000560static inline
561Bool bm_aligned_load_has_conflict_with(const struct bitmap* const bm,
bartf8bc71d2008-03-15 11:42:34 +0000562 const Addr a1, const SizeT size)
barta79df6e2008-03-14 17:07:51 +0000563{
bartf647d342008-03-24 19:12:12 +0000564 const struct bitmap2* bm2;
barta79df6e2008-03-14 17:07:51 +0000565
bart11d0b502008-03-22 16:44:03 +0000566 bm2 = bm2_lookup(bm, a1 >> ADDR0_BITS);
barta79df6e2008-03-14 17:07:51 +0000567
bartf8bc71d2008-03-15 11:42:34 +0000568 return (bm2 && bm0_is_any_set(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size));
barta79df6e2008-03-14 17:07:51 +0000569}
570
571static inline
572Bool bm_aligned_store_has_conflict_with(const struct bitmap* const bm,
bartf8bc71d2008-03-15 11:42:34 +0000573 const Addr a1, const SizeT size)
barta79df6e2008-03-14 17:07:51 +0000574{
bartf647d342008-03-24 19:12:12 +0000575 const struct bitmap2* bm2;
barta79df6e2008-03-14 17:07:51 +0000576
bart11d0b502008-03-22 16:44:03 +0000577 bm2 = bm2_lookup(bm, a1 >> ADDR0_BITS);
barta79df6e2008-03-14 17:07:51 +0000578
bart3772a982008-03-15 08:11:03 +0000579 if (bm2)
580 {
bartf8bc71d2008-03-15 11:42:34 +0000581 if (bm0_is_any_set(bm2->bm1.bm0_r, a1 & ADDR0_MASK, size)
582 | bm0_is_any_set(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size))
bart3772a982008-03-15 08:11:03 +0000583 {
584 return True;
585 }
586 }
587 return False;
barta79df6e2008-03-14 17:07:51 +0000588}
589
bart36556122008-03-13 19:24:30 +0000590Bool bm_load_has_conflict_with(const struct bitmap* const bm,
591 const Addr a1, const Addr a2)
sewardjaf44c822007-11-25 14:01:38 +0000592{
bart3772a982008-03-15 08:11:03 +0000593 return bm_has_conflict_with(bm, a1, a2, eLoad);
bart36556122008-03-13 19:24:30 +0000594}
595
barta79df6e2008-03-14 17:07:51 +0000596Bool bm_load_1_has_conflict_with(const struct bitmap* const bm, const Addr a1)
597{
bartf8bc71d2008-03-15 11:42:34 +0000598 return bm_aligned_load_has_conflict_with(bm, a1, 1);
barta79df6e2008-03-14 17:07:51 +0000599}
600
601Bool bm_load_2_has_conflict_with(const struct bitmap* const bm, const Addr a1)
602{
bart3772a982008-03-15 08:11:03 +0000603 if ((a1 & 1) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000604 return bm_aligned_load_has_conflict_with(bm, a1, 2);
bart3772a982008-03-15 08:11:03 +0000605 else
606 return bm_has_conflict_with(bm, a1, a1 + 2, eLoad);
barta79df6e2008-03-14 17:07:51 +0000607}
608
609Bool bm_load_4_has_conflict_with(const struct bitmap* const bm, const Addr a1)
610{
bart3772a982008-03-15 08:11:03 +0000611 if ((a1 & 3) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000612 return bm_aligned_load_has_conflict_with(bm, a1, 4);
bart3772a982008-03-15 08:11:03 +0000613 else
614 return bm_has_conflict_with(bm, a1, a1 + 4, eLoad);
barta79df6e2008-03-14 17:07:51 +0000615}
616
617Bool bm_load_8_has_conflict_with(const struct bitmap* const bm, const Addr a1)
618{
bart3772a982008-03-15 08:11:03 +0000619 if ((a1 & 7) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000620 return bm_aligned_load_has_conflict_with(bm, a1, 8);
bart3772a982008-03-15 08:11:03 +0000621 else
622 return bm_has_conflict_with(bm, a1, a1 + 8, eLoad);
barta79df6e2008-03-14 17:07:51 +0000623}
624
625Bool bm_store_1_has_conflict_with(const struct bitmap* const bm, const Addr a1)
626{
bartf8bc71d2008-03-15 11:42:34 +0000627 return bm_aligned_store_has_conflict_with(bm, a1, 1);
barta79df6e2008-03-14 17:07:51 +0000628}
629
630Bool bm_store_2_has_conflict_with(const struct bitmap* const bm, const Addr a1)
631{
bart3772a982008-03-15 08:11:03 +0000632 if ((a1 & 1) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000633 return bm_aligned_store_has_conflict_with(bm, a1, 2);
bart3772a982008-03-15 08:11:03 +0000634 else
635 return bm_has_conflict_with(bm, a1, a1 + 2, eStore);
barta79df6e2008-03-14 17:07:51 +0000636}
637
638Bool bm_store_4_has_conflict_with(const struct bitmap* const bm, const Addr a1)
639{
bart3772a982008-03-15 08:11:03 +0000640 if ((a1 & 3) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000641 return bm_aligned_store_has_conflict_with(bm, a1, 4);
bart3772a982008-03-15 08:11:03 +0000642 else
643 return bm_has_conflict_with(bm, a1, a1 + 4, eStore);
barta79df6e2008-03-14 17:07:51 +0000644}
645
646Bool bm_store_8_has_conflict_with(const struct bitmap* const bm, const Addr a1)
647{
bart3772a982008-03-15 08:11:03 +0000648 if ((a1 & 7) == 0)
bartf8bc71d2008-03-15 11:42:34 +0000649 return bm_aligned_store_has_conflict_with(bm, a1, 8);
bart3772a982008-03-15 08:11:03 +0000650 else
651 return bm_has_conflict_with(bm, a1, a1 + 8, eStore);
barta79df6e2008-03-14 17:07:51 +0000652}
653
bart36556122008-03-13 19:24:30 +0000654Bool bm_store_has_conflict_with(const struct bitmap* const bm,
655 const Addr a1, const Addr a2)
656{
bart3772a982008-03-15 08:11:03 +0000657 return bm_has_conflict_with(bm, a1, a2, eStore);
sewardjaf44c822007-11-25 14:01:38 +0000658}
659
660void bm_swap(struct bitmap* const bm1, struct bitmap* const bm2)
661{
bart3772a982008-03-15 08:11:03 +0000662 OSet* const tmp = bm1->oset;
663 bm1->oset = bm2->oset;
664 bm2->oset = tmp;
sewardjaf44c822007-11-25 14:01:38 +0000665}
666
bartf647d342008-03-24 19:12:12 +0000667/** Merge bitmaps *lhs and *rhs into *lhs. */
sewardjaf44c822007-11-25 14:01:38 +0000668void bm_merge2(struct bitmap* const lhs,
669 const struct bitmap* const rhs)
670{
bart3772a982008-03-15 08:11:03 +0000671 struct bitmap2* bm2l;
bartf647d342008-03-24 19:12:12 +0000672 struct bitmap2ref* bm2l_ref;
673 struct bitmap2* bm2r;
674 const struct bitmap2ref* bm2r_ref;
sewardjaf44c822007-11-25 14:01:38 +0000675
bart3772a982008-03-15 08:11:03 +0000676 VG_(OSetGen_ResetIter)(rhs->oset);
sewardjaf44c822007-11-25 14:01:38 +0000677
bartf647d342008-03-24 19:12:12 +0000678 for ( ; (bm2r_ref = VG_(OSetGen_Next)(rhs->oset)) != 0; )
bart3772a982008-03-15 08:11:03 +0000679 {
bartf647d342008-03-24 19:12:12 +0000680 bm2r = bm2r_ref->bm2;
681 bm2l_ref = VG_(OSetGen_Lookup)(lhs->oset, &bm2r->addr);
682 if (bm2l_ref)
bart3772a982008-03-15 08:11:03 +0000683 {
bartf647d342008-03-24 19:12:12 +0000684 bm2l = bm2l_ref->bm2;
685 if (bm2l != bm2r)
686 {
687 if (bm2l->refcnt > 1)
688 bm2l = bm2_make_exclusive(lhs, bm2l_ref);
689 bm2_merge(bm2l, bm2r);
690 }
691 }
692 else
693 {
694 bm2_insert_addref(lhs, bm2r);
695 }
bart3772a982008-03-15 08:11:03 +0000696 }
sewardjaf44c822007-11-25 14:01:38 +0000697}
698
699/**
700 * Report whether there are any RW / WR / WW patterns in lhs and rhs.
701 * @param lhs First bitmap.
702 * @param rhs Bitmap to be compared with lhs.
703 * @return !=0 if there are data races, == 0 if there are none.
704 */
705int bm_has_races(const struct bitmap* const lhs,
706 const struct bitmap* const rhs)
707{
bart3772a982008-03-15 08:11:03 +0000708 VG_(OSetGen_ResetIter)(lhs->oset);
709 VG_(OSetGen_ResetIter)(rhs->oset);
sewardjaf44c822007-11-25 14:01:38 +0000710
bart3772a982008-03-15 08:11:03 +0000711 for (;;)
712 {
bartf647d342008-03-24 19:12:12 +0000713 const struct bitmap2ref* bm2l_ref;
714 const struct bitmap2ref* bm2r_ref;
715 const struct bitmap2* bm2l;
716 const struct bitmap2* bm2r;
bart3772a982008-03-15 08:11:03 +0000717 const struct bitmap1* bm1l;
718 const struct bitmap1* bm1r;
719 unsigned k;
sewardjaf44c822007-11-25 14:01:38 +0000720
bartf647d342008-03-24 19:12:12 +0000721 bm2l_ref = VG_(OSetGen_Next)(lhs->oset);
722 bm2l = bm2l_ref->bm2;
723 bm2r_ref = VG_(OSetGen_Next)(rhs->oset);
724 bm2r = bm2r_ref->bm2;
bart3772a982008-03-15 08:11:03 +0000725 while (bm2l && bm2r && bm2l->addr != bm2r->addr)
726 {
727 if (bm2l->addr < bm2r->addr)
bartf647d342008-03-24 19:12:12 +0000728 bm2l = (bm2l_ref = VG_(OSetGen_Next)(lhs->oset))->bm2;
bart3772a982008-03-15 08:11:03 +0000729 else
bartf647d342008-03-24 19:12:12 +0000730 bm2r = (bm2r_ref = VG_(OSetGen_Next)(rhs->oset))->bm2;
bart3772a982008-03-15 08:11:03 +0000731 }
732 if (bm2l == 0 || bm2r == 0)
733 break;
734
735 bm1l = &bm2l->bm1;
736 bm1r = &bm2r->bm1;
737
738 for (k = 0; k < BITMAP1_UWORD_COUNT; k++)
739 {
740 unsigned b;
741 for (b = 0; b < BITS_PER_UWORD; b++)
sewardjaf44c822007-11-25 14:01:38 +0000742 {
bart3772a982008-03-15 08:11:03 +0000743 UWord const access
744 = ((bm1l->bm0_r[k] & bm0_mask(b)) ? LHS_R : 0)
745 | ((bm1l->bm0_w[k] & bm0_mask(b)) ? LHS_W : 0)
746 | ((bm1r->bm0_r[k] & bm0_mask(b)) ? RHS_R : 0)
747 | ((bm1r->bm0_w[k] & bm0_mask(b)) ? RHS_W : 0);
748 Addr const a = MAKE_ADDRESS(bm2l->addr, k * BITS_PER_UWORD | b);
749 if (HAS_RACE(access) && ! drd_is_suppressed(a, a + 1))
750 {
751 return 1;
752 }
sewardjaf44c822007-11-25 14:01:38 +0000753 }
bart3772a982008-03-15 08:11:03 +0000754 }
755 }
756 return 0;
sewardjaf44c822007-11-25 14:01:38 +0000757}
758
sewardjaf44c822007-11-25 14:01:38 +0000759void bm_print(const struct bitmap* const bm)
760{
bart3772a982008-03-15 08:11:03 +0000761 struct bitmap2* bm2;
bartf647d342008-03-24 19:12:12 +0000762 struct bitmap2ref* bm2ref;
sewardjaf44c822007-11-25 14:01:38 +0000763
bart3772a982008-03-15 08:11:03 +0000764 VG_(OSetGen_ResetIter)(bm->oset);
sewardjaf44c822007-11-25 14:01:38 +0000765
bartf647d342008-03-24 19:12:12 +0000766 for ( ; (bm2ref = VG_(OSetGen_Next)(bm->oset)) != 0; )
bart3772a982008-03-15 08:11:03 +0000767 {
bartf647d342008-03-24 19:12:12 +0000768 const struct bitmap1* bm1;
bart0008f5b2008-03-22 17:07:39 +0000769 unsigned b;
bartf647d342008-03-24 19:12:12 +0000770
771 bm2 = bm2ref->bm2;
772 bm1 = &bm2->bm1;
bart0008f5b2008-03-22 17:07:39 +0000773 for (b = 0; b < ADDR0_COUNT; b++)
bart3772a982008-03-15 08:11:03 +0000774 {
bart0008f5b2008-03-22 17:07:39 +0000775 const Addr a = (bm2->addr << ADDR0_BITS) | b;
776 const Bool r = bm0_is_set(bm1->bm0_r, b) != 0;
777 const Bool w = bm0_is_set(bm1->bm0_w, b) != 0;
778 if (r || w)
sewardjaf44c822007-11-25 14:01:38 +0000779 {
bart0008f5b2008-03-22 17:07:39 +0000780 VG_(printf)("0x%08lx %c %c\n",
781 a,
782 w ? 'W' : ' ',
783 r ? 'R' : ' ');
sewardjaf44c822007-11-25 14:01:38 +0000784 }
bart3772a982008-03-15 08:11:03 +0000785 }
786 }
sewardjaf44c822007-11-25 14:01:38 +0000787}
788
789ULong bm_get_bitmap_creation_count(void)
790{
bart3772a982008-03-15 08:11:03 +0000791 return s_bitmap_creation_count;
sewardjaf44c822007-11-25 14:01:38 +0000792}
793
794ULong bm_get_bitmap2_creation_count(void)
795{
bart3772a982008-03-15 08:11:03 +0000796 return s_bitmap2_creation_count;
sewardjaf44c822007-11-25 14:01:38 +0000797}
798
bartf647d342008-03-24 19:12:12 +0000799/** Allocate and initialize a second level bitmap. */
800static struct bitmap2* bm2_new(const UWord a1)
801{
802 struct bitmap2* bm2;
803
804 bm2 = VG_(malloc)(sizeof(*bm2));
805 bm2->addr = a1;
806 bm2->refcnt = 1;
807
808 s_bitmap2_creation_count++;
809
810 return bm2;
811}
812
813/** Make a copy of a shared second level bitmap such that the copy can be
814 * modified.
815 *
816 * @param a1 client address shifted right by ADDR0_BITS.
817 * @param bm bitmap pointer.
818 */
819static
820struct bitmap2* bm2_make_exclusive(struct bitmap* const bm,
821 struct bitmap2ref* const bm2ref)
822{
823 UWord a1;
824 struct bitmap2* bm2;
825 struct bitmap2* bm2_copy;
826
827 tl_assert(bm);
828 tl_assert(bm2ref);
829 bm2 = bm2ref->bm2;
830 tl_assert(bm2);
831 tl_assert(bm2->refcnt > 1);
832 bm2->refcnt--;
833 tl_assert(bm2->refcnt >= 1);
834 a1 = bm2->addr;
835 bm2_copy = bm2_new(a1);
836 tl_assert(bm2_copy);
837 tl_assert(bm2_copy->addr == a1);
838 tl_assert(bm2_copy->refcnt == 1);
839 VG_(memcpy)(&bm2_copy->bm1, &bm2->bm1, sizeof(bm2->bm1));
840 bm2ref->bm2 = bm2_copy;
841
842 bm_update_cache(bm, a1, bm2_copy);
843
844 return bm2_copy;
845}
846
sewardjaf44c822007-11-25 14:01:38 +0000847static void bm2_merge(struct bitmap2* const bm2l,
848 const struct bitmap2* const bm2r)
849{
bart3772a982008-03-15 08:11:03 +0000850 unsigned k;
sewardjaf44c822007-11-25 14:01:38 +0000851
bart33e56c92008-03-24 06:41:30 +0000852 tl_assert(bm2l);
853 tl_assert(bm2r);
bart3772a982008-03-15 08:11:03 +0000854 tl_assert(bm2l->addr == bm2r->addr);
bartf647d342008-03-24 19:12:12 +0000855 tl_assert(bm2l->refcnt == 1);
sewardjaf44c822007-11-25 14:01:38 +0000856
bart3772a982008-03-15 08:11:03 +0000857 for (k = 0; k < BITMAP1_UWORD_COUNT; k++)
858 {
859 bm2l->bm1.bm0_r[k] |= bm2r->bm1.bm0_r[k];
860 }
861 for (k = 0; k < BITMAP1_UWORD_COUNT; k++)
862 {
863 bm2l->bm1.bm0_w[k] |= bm2r->bm1.bm0_w[k];
864 }
sewardjaf44c822007-11-25 14:01:38 +0000865}
866
867#if 0
868
869/* Unit test */
870static
871struct { Addr address; SizeT size; BmAccessTypeT access_type; }
bart3772a982008-03-15 08:11:03 +0000872 s_args[] = {
bart0008f5b2008-03-22 17:07:39 +0000873 { 0 + ADDR0_COUNT, 1, eLoad },
874 { 666 + ADDR0_COUNT, 4, eLoad },
875 { 667 + ADDR0_COUNT, 2, eStore },
bart33e56c92008-03-24 06:41:30 +0000876 { -2 + 2*ADDR0_COUNT, 1, eStore },
bart0008f5b2008-03-22 17:07:39 +0000877 { 0x0001ffffUL, 1, eLoad },
878 { 0x0002ffffUL, 1, eLoad },
879 { 0x00ffffffUL, 1, eLoad },
880 { 0xffffffffUL, 1, eStore },
bart3772a982008-03-15 08:11:03 +0000881 };
sewardjaf44c822007-11-25 14:01:38 +0000882
883void bm_test(void)
884{
bart3772a982008-03-15 08:11:03 +0000885 struct bitmap* bm;
886 struct bitmap* bm2;
bart0008f5b2008-03-22 17:07:39 +0000887 unsigned i, j;
sewardjaf44c822007-11-25 14:01:38 +0000888
bart3772a982008-03-15 08:11:03 +0000889 VG_(printf)("Start of DRD BM unit test.\n");
sewardjaf44c822007-11-25 14:01:38 +0000890
bart3772a982008-03-15 08:11:03 +0000891 bm = bm_new();
sewardjaf44c822007-11-25 14:01:38 +0000892
bart3772a982008-03-15 08:11:03 +0000893 for (i = 0; i < sizeof(s_args)/sizeof(s_args[0]); i++)
894 {
895 bm_access_range(bm,
896 s_args[i].address,
897 s_args[i].address + s_args[i].size,
898 s_args[i].access_type);
899 }
sewardjaf44c822007-11-25 14:01:38 +0000900
bart3772a982008-03-15 08:11:03 +0000901 VG_(printf)("Map contents -- should contain 10 addresses:\n");
902 bm_print(bm);
sewardjaf44c822007-11-25 14:01:38 +0000903
bart3772a982008-03-15 08:11:03 +0000904 for (i = 0; i < sizeof(s_args)/sizeof(s_args[0]); i++)
905 {
906 for (j = 0; j < s_args[i].size; j++)
907 {
908 tl_assert(bm_has_1(bm, s_args[i].address + j, s_args[i].access_type));
909 }
910 }
sewardjaf44c822007-11-25 14:01:38 +0000911
bart3772a982008-03-15 08:11:03 +0000912 VG_(printf)("Merge result:\n");
bart0008f5b2008-03-22 17:07:39 +0000913 bm2 = bm_new();
914 bm_merge2(bm2, bm);
915 bm_merge2(bm2, bm);
bart3772a982008-03-15 08:11:03 +0000916 bm_print(bm);
sewardjaf44c822007-11-25 14:01:38 +0000917
bart0008f5b2008-03-22 17:07:39 +0000918 VG_(printf)("Deleting bitmap bm\n");
bart3772a982008-03-15 08:11:03 +0000919 bm_delete(bm);
bart0008f5b2008-03-22 17:07:39 +0000920 VG_(printf)("Deleting bitmap bm2\n");
bart3772a982008-03-15 08:11:03 +0000921 bm_delete(bm2);
sewardjaf44c822007-11-25 14:01:38 +0000922
bart3772a982008-03-15 08:11:03 +0000923 VG_(printf)("End of DRD BM unit test.\n");
sewardjaf44c822007-11-25 14:01:38 +0000924}
925#endif