bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 1 | /* -*- mode: C; c-basic-offset: 3; -*- */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 2 | /* |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 3 | This file is part of drd, a thread error detector. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 4 | |
bart | 876cafd | 2010-10-10 18:07:31 +0000 | [diff] [blame] | 5 | Copyright (C) 2006-2010 Bart Van Assche <bvanassche@acm.org>. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 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 | #ifndef __DRD_ERROR_H |
| 27 | #define __DRD_ERROR_H |
| 28 | |
| 29 | |
bart | b515eb1 | 2008-03-07 18:52:38 +0000 | [diff] [blame] | 30 | #include "pub_drd_bitmap.h" // BmAccessTypeT |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 31 | #include "drd_thread.h" // DrdThreadId |
| 32 | #include "pub_tool_basics.h" // SizeT |
| 33 | #include "pub_tool_debuginfo.h" // SegInfo |
| 34 | #include "pub_tool_errormgr.h" // ExeContext |
| 35 | |
| 36 | |
| 37 | /* DRD error types. */ |
| 38 | |
| 39 | typedef enum { |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 40 | #define STR_DataRaceErr "ConflictingAccess" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 41 | DataRaceErr = 1, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 42 | #define STR_MutexErr "MutexErr" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 43 | MutexErr = 2, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 44 | #define STR_CondErr "CondErr" |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 45 | CondErr = 3, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 46 | #define STR_CondDestrErr "CondDestrErr" |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 47 | CondDestrErr = 4, |
| 48 | #define STR_CondRaceErr "CondRaceErr" |
| 49 | CondRaceErr = 5, |
| 50 | #define STR_CondWaitErr "CondWaitErr" |
| 51 | CondWaitErr = 6, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 52 | #define STR_SemaphoreErr "SemaphoreErr" |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 53 | SemaphoreErr = 7, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 54 | #define STR_BarrierErr "BarrierErr" |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 55 | BarrierErr = 8, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 56 | #define STR_RwlockErr "RwlockErr" |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 57 | RwlockErr = 9, |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 58 | #define STR_HoldtimeErr "HoldtimeErr" |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 59 | HoldtimeErr = 10, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 60 | #define STR_GenericErr "GenericErr" |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 61 | GenericErr = 11, |
bart | b48bde2 | 2009-07-31 08:26:17 +0000 | [diff] [blame] | 62 | #define STR_InvalidThreadId "InvalidThreadId" |
| 63 | InvalidThreadId = 12, |
bart | 141a7ed | 2010-03-21 17:28:10 +0000 | [diff] [blame] | 64 | #define STR_UnimpHgClReq "UnimpHgClReq" |
| 65 | UnimpHgClReq = 13, |
| 66 | #define STR_UnimpDrdClReq "UnimpDrdClReq" |
| 67 | UnimpDrdClReq = 14, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 68 | } DrdErrorKind; |
| 69 | |
| 70 | /* The classification of a faulting address. */ |
bart | 31b983d | 2010-02-21 14:52:59 +0000 | [diff] [blame] | 71 | typedef |
| 72 | enum { |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 73 | //Undescribed, // as-yet unclassified |
bart | 31b983d | 2010-02-21 14:52:59 +0000 | [diff] [blame] | 74 | eStack, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 75 | eUnknown, // classification yielded nothing useful |
| 76 | //Freed, |
bart | 31b983d | 2010-02-21 14:52:59 +0000 | [diff] [blame] | 77 | eMallocd, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 78 | eSegment, // in a segment (as defined in pub_tool_debuginfo.h) |
| 79 | //UserG, // in a user-defined block |
| 80 | //Mempool, // in a mempool |
| 81 | //Register, // in a register; for Param errors only |
| 82 | } |
| 83 | AddrKind; |
| 84 | |
| 85 | /* Records info about a faulting address. */ |
| 86 | typedef |
| 87 | struct { // Used by: |
| 88 | AddrKind akind; // ALL |
| 89 | SizeT size; // ALL |
njn | c4431bf | 2009-01-15 21:29:24 +0000 | [diff] [blame] | 90 | PtrdiffT rwoffset; // ALL |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 91 | ExeContext* lastchange; // Mallocd |
| 92 | DrdThreadId stack_tid; // Stack |
sewardj | b8b79ad | 2008-03-03 01:35:41 +0000 | [diff] [blame] | 93 | DebugInfo* debuginfo; // Segment |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 94 | Char name[256]; // Segment |
| 95 | Char descr[256]; // Segment |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 96 | } AddrInfo; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 97 | |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 98 | /* |
| 99 | * NOTE: the first member of each error info structure MUST be the thread ID |
| 100 | * in which the error has been observed. |
| 101 | */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 102 | typedef struct { |
bart | 354009c | 2008-03-16 10:42:33 +0000 | [diff] [blame] | 103 | DrdThreadId tid; // Thread ID of the running thread. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 104 | Addr addr; // Conflicting address in current thread. |
| 105 | SizeT size; // Size in bytes of conflicting operation. |
| 106 | BmAccessTypeT access_type; // Access type: load or store. |
| 107 | } DataRaceErrInfo; |
| 108 | |
| 109 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 110 | DrdThreadId tid; |
| 111 | Addr mutex; |
| 112 | Int recursion_count; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 113 | DrdThreadId owner; |
| 114 | } MutexErrInfo; |
| 115 | |
| 116 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 117 | DrdThreadId tid; |
| 118 | Addr cond; |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 119 | } CondErrInfo; |
| 120 | |
| 121 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 122 | DrdThreadId tid; |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 123 | Addr cond; |
| 124 | Addr mutex; |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 125 | DrdThreadId owner; |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 126 | } CondDestrErrInfo; |
| 127 | |
| 128 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 129 | DrdThreadId tid; |
| 130 | Addr cond; |
| 131 | Addr mutex; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 132 | } CondRaceErrInfo; |
| 133 | |
| 134 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 135 | DrdThreadId tid; |
| 136 | Addr cond; |
| 137 | Addr mutex1; |
| 138 | Addr mutex2; |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 139 | } CondWaitErrInfo; |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 140 | |
| 141 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 142 | DrdThreadId tid; |
| 143 | Addr semaphore; |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 144 | } SemaphoreErrInfo; |
| 145 | |
| 146 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 147 | DrdThreadId tid; |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 148 | Addr barrier; |
| 149 | DrdThreadId other_tid; |
| 150 | ExeContext* other_context; |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 151 | } BarrierErrInfo; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 152 | |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame] | 153 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 154 | DrdThreadId tid; |
| 155 | Addr rwlock; |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 156 | } RwlockErrInfo; |
| 157 | |
| 158 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 159 | DrdThreadId tid; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 160 | Addr synchronization_object; |
| 161 | ExeContext* acquired_at; |
| 162 | UInt hold_time_ms; |
| 163 | UInt threshold_ms; |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 164 | } HoldtimeErrInfo; |
| 165 | |
| 166 | typedef struct { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 167 | DrdThreadId tid; |
bart | 62cc232 | 2010-03-07 10:54:21 +0000 | [diff] [blame] | 168 | Addr addr; |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame] | 169 | } GenericErrInfo; |
| 170 | |
bart | b48bde2 | 2009-07-31 08:26:17 +0000 | [diff] [blame] | 171 | typedef struct { |
| 172 | DrdThreadId tid; |
| 173 | ULong ptid; |
| 174 | } InvalidThreadIdInfo; |
bart | 16d76e5 | 2008-03-18 17:08:08 +0000 | [diff] [blame] | 175 | |
bart | 66f196d | 2009-08-15 10:50:35 +0000 | [diff] [blame] | 176 | typedef struct { |
| 177 | DrdThreadId tid; |
| 178 | Char* descr; |
| 179 | } UnimpClReqInfo; |
| 180 | |
bart | 246fbf2 | 2009-02-15 14:46:17 +0000 | [diff] [blame] | 181 | void DRD_(set_show_conflicting_segments)(const Bool scs); |
bart | 1335ecc | 2009-02-14 16:10:53 +0000 | [diff] [blame] | 182 | void DRD_(register_error_handlers)(void); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 183 | |
| 184 | |
| 185 | #endif /* __DRD_ERROR_H */ |