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 | |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame^] | 26 | /* |
| 27 | * A bitmap is a data structure that contains information about which |
| 28 | * addresses have been accessed for reading or writing within a given |
| 29 | * segment. |
| 30 | */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 31 | |
| 32 | |
bart | 33e56c9 | 2008-03-24 06:41:30 +0000 | [diff] [blame] | 33 | #ifndef __PUB_DRD_BITMAP_H |
| 34 | #define __PUB_DRD_BITMAP_H |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 35 | |
| 36 | |
| 37 | #include "pub_tool_basics.h" /* Addr, SizeT */ |
| 38 | |
| 39 | |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame^] | 40 | /* Defines. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 41 | |
| 42 | #define LHS_R (1<<0) |
| 43 | #define LHS_W (1<<1) |
| 44 | #define RHS_R (1<<2) |
| 45 | #define RHS_W (1<<3) |
| 46 | #define HAS_RACE(a) ((((a) & RHS_W) && ((a) & (LHS_R | LHS_W))) \ |
| 47 | || (((a) & LHS_W) && ((a) & (RHS_R | RHS_W)))) |
| 48 | |
| 49 | |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame^] | 50 | /* Forward declarations. */ |
| 51 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 52 | struct bitmap; |
| 53 | |
| 54 | |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame^] | 55 | /* Datatype definitions. */ |
| 56 | |
bart | 5e234ac | 2008-03-16 08:39:54 +0000 | [diff] [blame] | 57 | typedef enum { eLoad, eStore, eStart, eEnd } BmAccessTypeT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 58 | |
| 59 | |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame^] | 60 | /* Function declarations. */ |
bart | 588d90f | 2008-04-06 13:05:58 +0000 | [diff] [blame] | 61 | |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame^] | 62 | struct bitmap* DRD_(bm_new)(void); |
| 63 | void DRD_(bm_delete)(struct bitmap* const bm); |
| 64 | void DRD_(bm_access_range)(struct bitmap* const bm, |
| 65 | const Addr a1, const Addr a2, |
| 66 | const BmAccessTypeT access_type); |
| 67 | void DRD_(bm_access_range_load)(struct bitmap* const bm, |
| 68 | const Addr a1, const Addr a2); |
| 69 | void DRD_(bm_access_load_1)(struct bitmap* const bm, const Addr a1); |
| 70 | void DRD_(bm_access_load_2)(struct bitmap* const bm, const Addr a1); |
| 71 | void DRD_(bm_access_load_4)(struct bitmap* const bm, const Addr a1); |
| 72 | void DRD_(bm_access_load_8)(struct bitmap* const bm, const Addr a1); |
| 73 | void DRD_(bm_access_range_store)(struct bitmap* const bm, |
| 74 | const Addr a1, const Addr a2); |
| 75 | void DRD_(bm_access_store_1)(struct bitmap* const bm, const Addr a1); |
| 76 | void DRD_(bm_access_store_2)(struct bitmap* const bm, const Addr a1); |
| 77 | void DRD_(bm_access_store_4)(struct bitmap* const bm, const Addr a1); |
| 78 | void DRD_(bm_access_store_8)(struct bitmap* const bm, const Addr a1); |
| 79 | Bool DRD_(bm_has)(struct bitmap* const bm, |
| 80 | const Addr a1, const Addr a2, |
| 81 | const BmAccessTypeT access_type); |
| 82 | Bool DRD_(bm_has_any_load)(struct bitmap* const bm, |
| 83 | const Addr a1, const Addr a2); |
| 84 | Bool DRD_(bm_has_any_store)(struct bitmap* const bm, |
| 85 | const Addr a1, const Addr a2); |
| 86 | Bool DRD_(bm_has_any_access)(struct bitmap* const bm, |
| 87 | const Addr a1, const Addr a2); |
| 88 | Bool DRD_(bm_has_1)(struct bitmap* const bm, |
| 89 | const Addr address, const BmAccessTypeT access_type); |
| 90 | void DRD_(bm_clear)(struct bitmap* const bm, |
| 91 | const Addr a1, const Addr a2); |
| 92 | void DRD_(bm_clear_load)(struct bitmap* const bm, |
| 93 | const Addr a1, const Addr a2); |
| 94 | void DRD_(bm_clear_store)(struct bitmap* const bm, |
| 95 | const Addr a1, const Addr a2); |
| 96 | Bool DRD_(bm_test_and_clear)(struct bitmap* const bm, |
| 97 | const Addr a1, const Addr a2); |
| 98 | Bool DRD_(bm_has_conflict_with)(struct bitmap* const bm, |
| 99 | const Addr a1, const Addr a2, |
| 100 | const BmAccessTypeT access_type); |
| 101 | Bool DRD_(bm_load_1_has_conflict_with)(struct bitmap* const bm, const Addr a1); |
| 102 | Bool DRD_(bm_load_2_has_conflict_with)(struct bitmap* const bm, const Addr a1); |
| 103 | Bool DRD_(bm_load_4_has_conflict_with)(struct bitmap* const bm, const Addr a1); |
| 104 | Bool DRD_(bm_load_8_has_conflict_with)(struct bitmap* const bm, const Addr a1); |
| 105 | Bool DRD_(bm_load_has_conflict_with)(struct bitmap* const bm, |
| 106 | const Addr a1, const Addr a2); |
| 107 | Bool DRD_(bm_store_1_has_conflict_with)(struct bitmap* const bm,const Addr a1); |
| 108 | Bool DRD_(bm_store_2_has_conflict_with)(struct bitmap* const bm,const Addr a1); |
| 109 | Bool DRD_(bm_store_4_has_conflict_with)(struct bitmap* const bm,const Addr a1); |
| 110 | Bool DRD_(bm_store_8_has_conflict_with)(struct bitmap* const bm,const Addr a1); |
| 111 | Bool DRD_(bm_store_has_conflict_with)(struct bitmap* const bm, |
| 112 | const Addr a1, const Addr a2); |
| 113 | Bool DRD_(bm_equal)(struct bitmap* const lhs, struct bitmap* const rhs); |
| 114 | void DRD_(bm_swap)(struct bitmap* const bm1, struct bitmap* const bm2); |
| 115 | void DRD_(bm_merge2)(struct bitmap* const lhs, |
| 116 | struct bitmap* const rhs); |
| 117 | int DRD_(bm_has_races)(struct bitmap* const bm1, |
| 118 | struct bitmap* const bm2); |
| 119 | void DRD_(bm_report_races)(ThreadId const tid1, ThreadId const tid2, |
| 120 | struct bitmap* const bm1, |
| 121 | struct bitmap* const bm2); |
| 122 | void DRD_(bm_print)(struct bitmap* bm); |
| 123 | ULong DRD_(bm_get_bitmap_creation_count)(void); |
| 124 | ULong DRD_(bm_get_bitmap2_node_creation_count)(void); |
| 125 | ULong DRD_(bm_get_bitmap2_creation_count)(void); |
| 126 | |
| 127 | void DRD_(bm_test)(void); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 128 | |
| 129 | |
bart | 33e56c9 | 2008-03-24 06:41:30 +0000 | [diff] [blame] | 130 | #endif /* __PUB_DRD_BITMAP_H */ |