sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | This file is part of drd, a data race detector. |
| 3 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 4 | Copyright (C) 2006-2008 Bart Van Assche |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 5 | 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 | |
bart | 33e56c9 | 2008-03-24 06:41:30 +0000 | [diff] [blame] | 31 | #ifndef __PUB_DRD_BITMAP_H |
| 32 | #define __PUB_DRD_BITMAP_H |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 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. |
| 49 | struct bitmap; |
| 50 | |
| 51 | |
| 52 | // Datatype definitions. |
bart | 5e234ac | 2008-03-16 08:39:54 +0000 | [diff] [blame] | 53 | typedef enum { eLoad, eStore, eStart, eEnd } BmAccessTypeT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 54 | |
| 55 | |
| 56 | // Function declarations. |
| 57 | struct bitmap* bm_new(void); |
| 58 | void bm_delete(struct bitmap* const bm); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 59 | void bm_access_range(struct bitmap* const bm, |
| 60 | const Addr a1, const Addr a2, |
| 61 | const BmAccessTypeT access_type); |
bart | 3655612 | 2008-03-13 19:24:30 +0000 | [diff] [blame] | 62 | void bm_access_range_load(struct bitmap* const bm, |
| 63 | const Addr a1, const Addr a2); |
bart | a79df6e | 2008-03-14 17:07:51 +0000 | [diff] [blame] | 64 | void bm_access_load_1(struct bitmap* const bm, const Addr a1); |
| 65 | void bm_access_load_2(struct bitmap* const bm, const Addr a1); |
| 66 | void bm_access_load_4(struct bitmap* const bm, const Addr a1); |
| 67 | void bm_access_load_8(struct bitmap* const bm, const Addr a1); |
bart | d5f2370 | 2008-05-10 08:22:45 +0000 | [diff] [blame] | 68 | void bm_access_range_store(struct bitmap* const bm, |
| 69 | const Addr a1, const Addr a2); |
bart | a79df6e | 2008-03-14 17:07:51 +0000 | [diff] [blame] | 70 | void bm_access_store_1(struct bitmap* const bm, const Addr a1); |
| 71 | void bm_access_store_2(struct bitmap* const bm, const Addr a1); |
| 72 | void bm_access_store_4(struct bitmap* const bm, const Addr a1); |
| 73 | void bm_access_store_8(struct bitmap* const bm, const Addr a1); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 74 | Bool bm_has(struct bitmap* const bm, |
bart | 3655612 | 2008-03-13 19:24:30 +0000 | [diff] [blame] | 75 | const Addr a1, const Addr a2, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 76 | const BmAccessTypeT access_type); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 77 | Bool bm_has_any_load(struct bitmap* const bm, |
bart | d490707 | 2008-03-30 18:41:07 +0000 | [diff] [blame] | 78 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 79 | Bool bm_has_any_store(struct bitmap* const bm, |
bart | d490707 | 2008-03-30 18:41:07 +0000 | [diff] [blame] | 80 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 81 | Bool bm_has_any_access(struct bitmap* const bm, |
bart | c2c81db | 2008-05-10 11:19:10 +0000 | [diff] [blame] | 82 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 83 | Bool bm_has_1(struct bitmap* const bm, |
bart | c2c81db | 2008-05-10 11:19:10 +0000 | [diff] [blame] | 84 | const Addr address, const BmAccessTypeT access_type); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 85 | void bm_clear(struct bitmap* const bm, |
bart | 3655612 | 2008-03-13 19:24:30 +0000 | [diff] [blame] | 86 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 87 | void bm_clear_load(struct bitmap* const bm, |
bart | 9c4224c | 2008-03-29 14:40:08 +0000 | [diff] [blame] | 88 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 89 | void bm_clear_store(struct bitmap* const bm, |
bart | 9c4224c | 2008-03-29 14:40:08 +0000 | [diff] [blame] | 90 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 91 | Bool bm_test_and_clear(struct bitmap* const bm, |
bart | 8bf2f8b | 2008-03-30 17:56:43 +0000 | [diff] [blame] | 92 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 93 | Bool bm_has_conflict_with(struct bitmap* const bm, |
bart | 3655612 | 2008-03-13 19:24:30 +0000 | [diff] [blame] | 94 | const Addr a1, const Addr a2, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 95 | const BmAccessTypeT access_type); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 96 | Bool bm_load_1_has_conflict_with(struct bitmap* const bm, const Addr a1); |
| 97 | Bool bm_load_2_has_conflict_with(struct bitmap* const bm, const Addr a1); |
| 98 | Bool bm_load_4_has_conflict_with(struct bitmap* const bm, const Addr a1); |
| 99 | Bool bm_load_8_has_conflict_with(struct bitmap* const bm, const Addr a1); |
| 100 | Bool bm_load_has_conflict_with(struct bitmap* const bm, |
bart | 3655612 | 2008-03-13 19:24:30 +0000 | [diff] [blame] | 101 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 102 | Bool bm_store_1_has_conflict_with(struct bitmap* const bm,const Addr a1); |
| 103 | Bool bm_store_2_has_conflict_with(struct bitmap* const bm,const Addr a1); |
| 104 | Bool bm_store_4_has_conflict_with(struct bitmap* const bm,const Addr a1); |
| 105 | Bool bm_store_8_has_conflict_with(struct bitmap* const bm,const Addr a1); |
| 106 | Bool bm_store_has_conflict_with(struct bitmap* const bm, |
bart | 3655612 | 2008-03-13 19:24:30 +0000 | [diff] [blame] | 107 | const Addr a1, const Addr a2); |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 108 | Bool bm_equal(struct bitmap* const lhs, struct bitmap* const rhs); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 109 | void bm_swap(struct bitmap* const bm1, struct bitmap* const bm2); |
| 110 | void bm_merge2(struct bitmap* const lhs, |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 111 | struct bitmap* const rhs); |
| 112 | int bm_has_races(struct bitmap* const bm1, |
| 113 | struct bitmap* const bm2); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 114 | void bm_report_races(ThreadId const tid1, ThreadId const tid2, |
bart | 7e81a17 | 2008-06-09 19:50:51 +0000 | [diff] [blame] | 115 | struct bitmap* const bm1, |
| 116 | struct bitmap* const bm2); |
| 117 | void bm_print(struct bitmap* bm); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 118 | ULong bm_get_bitmap_creation_count(void); |
bart | 588d90f | 2008-04-06 13:05:58 +0000 | [diff] [blame] | 119 | ULong bm_get_bitmap2_node_creation_count(void); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 120 | ULong bm_get_bitmap2_creation_count(void); |
bart | 588d90f | 2008-04-06 13:05:58 +0000 | [diff] [blame] | 121 | |
bart | 33e56c9 | 2008-03-24 06:41:30 +0000 | [diff] [blame] | 122 | void bm_test(void); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 123 | |
| 124 | |
bart | 33e56c9 | 2008-03-24 06:41:30 +0000 | [diff] [blame] | 125 | #endif /* __PUB_DRD_BITMAP_H */ |