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 | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 26 | #include "drd_clientobj.h" /* struct mutex_info */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 27 | #include "drd_error.h" |
| 28 | #include "drd_malloc_wrappers.h" |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 29 | #include "drd_mutex.h" |
| 30 | #include "drd_suppression.h" /* drd_start_suppression() */ |
| 31 | #include "pub_drd_bitmap.h" /* LHS_W, ... */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 32 | #include "pub_tool_vki.h" |
| 33 | #include "pub_tool_basics.h" |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 34 | #include "pub_tool_libcassert.h" /* tl_assert() */ |
| 35 | #include "pub_tool_libcbase.h" /* strlen() */ |
| 36 | #include "pub_tool_libcfile.h" /* VG_(get_startup_wd)() */ |
| 37 | #include "pub_tool_libcprint.h" /* VG_(printf)() */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 38 | #include "pub_tool_machine.h" |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 39 | #include "pub_tool_mallocfree.h" /* VG_(malloc), VG_(free) */ |
| 40 | #include "pub_tool_threadstate.h" /* VG_(get_pthread_id)() */ |
| 41 | #include "pub_tool_tooliface.h" /* VG_(needs_tool_errors)() */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 42 | |
| 43 | |
bart | 16d76e5 | 2008-03-18 17:08:08 +0000 | [diff] [blame] | 44 | /* Local variables. */ |
| 45 | |
| 46 | static Bool s_drd_show_conflicting_segments = True; |
| 47 | |
| 48 | |
| 49 | void set_show_conflicting_segments(const Bool scs) |
| 50 | { |
| 51 | s_drd_show_conflicting_segments = scs; |
| 52 | } |
| 53 | |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 54 | /** Describe a data address range [a,a+len[ as good as possible, for error |
| 55 | * messages, putting the result in ai. |
| 56 | */ |
bart | ff1252a | 2008-03-16 17:27:25 +0000 | [diff] [blame] | 57 | static |
| 58 | void describe_malloced_addr(Addr const a, SizeT const len, AddrInfo* const ai) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 59 | { |
bart | ff1252a | 2008-03-16 17:27:25 +0000 | [diff] [blame] | 60 | Addr data; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 61 | |
bart | ff1252a | 2008-03-16 17:27:25 +0000 | [diff] [blame] | 62 | if (drd_heap_addrinfo(a, &data, &ai->size, &ai->lastchange)) |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 63 | { |
bart | ff1252a | 2008-03-16 17:27:25 +0000 | [diff] [blame] | 64 | ai->akind = eMallocd; |
| 65 | ai->rwoffset = a - data; |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 66 | } |
bart | ff1252a | 2008-03-16 17:27:25 +0000 | [diff] [blame] | 67 | else |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 68 | { |
bart | ff1252a | 2008-03-16 17:27:25 +0000 | [diff] [blame] | 69 | ai->akind = eUnknown; |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 70 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 71 | } |
| 72 | |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 73 | /** Report where a mutex has been observed for the first time. The printed |
| 74 | * call stack will either refer to a pthread_mutex_init() or a |
| 75 | * pthread_mutex_lock() call. |
| 76 | */ |
| 77 | static void mutex_first_observed(const Addr mutex) |
| 78 | { |
| 79 | struct mutex_info* mi; |
| 80 | |
| 81 | mi = mutex_get(mutex); |
| 82 | if (mi) |
| 83 | { |
| 84 | tl_assert(mi->first_observed_at); |
| 85 | VG_(message)(Vg_UserMsg, |
| 86 | "Mutex 0x%lx was first observed at:", mutex); |
| 87 | VG_(pp_ExeContext)(mi->first_observed_at); |
| 88 | } |
| 89 | } |
| 90 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 91 | static |
| 92 | void drd_report_data_race2(Error* const err, const DataRaceErrInfo* const dri) |
| 93 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 94 | AddrInfo ai; |
bart | f993b87 | 2008-04-01 18:19:50 +0000 | [diff] [blame] | 95 | const unsigned descr_size = 256; |
| 96 | Char* descr1 = VG_(malloc)(descr_size); |
| 97 | Char* descr2 = VG_(malloc)(descr_size); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 98 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 99 | tl_assert(dri); |
| 100 | tl_assert(dri->addr); |
| 101 | tl_assert(dri->size > 0); |
bart | fdd8d4e | 2008-04-01 18:38:29 +0000 | [diff] [blame] | 102 | tl_assert(descr1); |
| 103 | tl_assert(descr2); |
bart | b515eb1 | 2008-03-07 18:52:38 +0000 | [diff] [blame] | 104 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 105 | descr1[0] = 0; |
| 106 | descr2[0] = 0; |
bart | f993b87 | 2008-04-01 18:19:50 +0000 | [diff] [blame] | 107 | VG_(get_data_description)(descr1, descr2, descr_size, dri->addr); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 108 | if (descr1[0] == 0) |
| 109 | { |
bart | ff1252a | 2008-03-16 17:27:25 +0000 | [diff] [blame] | 110 | describe_malloced_addr(dri->addr, dri->size, &ai); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 111 | } |
| 112 | VG_(message)(Vg_UserMsg, |
bart | aa97a54 | 2008-03-16 17:57:01 +0000 | [diff] [blame] | 113 | "Conflicting %s by thread %d/%d at 0x%08lx size %ld", |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 114 | dri->access_type == eStore ? "store" : "load", |
bart | 354009c | 2008-03-16 10:42:33 +0000 | [diff] [blame] | 115 | DrdThreadIdToVgThreadId(dri->tid), |
bart | aa97a54 | 2008-03-16 17:57:01 +0000 | [diff] [blame] | 116 | dri->tid, |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 117 | dri->addr, |
| 118 | dri->size); |
| 119 | VG_(pp_ExeContext)(VG_(get_error_where)(err)); |
| 120 | if (descr1[0]) |
| 121 | { |
| 122 | VG_(message)(Vg_UserMsg, "%s", descr1); |
| 123 | VG_(message)(Vg_UserMsg, "%s", descr2); |
| 124 | } |
| 125 | else if (ai.akind == eMallocd && ai.lastchange) |
| 126 | { |
| 127 | VG_(message)(Vg_UserMsg, |
| 128 | "Address 0x%lx is at offset %ld from 0x%lx." |
| 129 | " Allocation context:", |
| 130 | dri->addr, ai.rwoffset, dri->addr - ai.rwoffset); |
| 131 | VG_(pp_ExeContext)(ai.lastchange); |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | VG_(message)(Vg_UserMsg, "Allocation context: unknown."); |
| 136 | } |
bart | 16d76e5 | 2008-03-18 17:08:08 +0000 | [diff] [blame] | 137 | if (s_drd_show_conflicting_segments) |
| 138 | { |
| 139 | thread_report_conflicting_segments(dri->tid, |
| 140 | dri->addr, dri->size, dri->access_type); |
| 141 | } |
bart | f993b87 | 2008-04-01 18:19:50 +0000 | [diff] [blame] | 142 | |
| 143 | VG_(free)(descr2); |
| 144 | VG_(free)(descr1); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | static Bool drd_tool_error_eq(VgRes res, Error* e1, Error* e2) |
| 148 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 149 | return False; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | static void drd_tool_error_pp(Error* const e) |
| 153 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 154 | switch (VG_(get_error_kind)(e)) |
| 155 | { |
| 156 | case DataRaceErr: { |
| 157 | drd_report_data_race2(e, VG_(get_error_extra)(e)); |
| 158 | break; |
| 159 | } |
| 160 | case MutexErr: { |
| 161 | MutexErrInfo* p = (MutexErrInfo*)(VG_(get_error_extra)(e)); |
| 162 | tl_assert(p); |
bart | 6b71761 | 2008-03-24 09:29:38 +0000 | [diff] [blame] | 163 | if (p->recursion_count >= 0) |
| 164 | { |
| 165 | VG_(message)(Vg_UserMsg, |
| 166 | "%s: mutex 0x%lx, recursion count %d, owner %d.", |
| 167 | VG_(get_error_string)(e), |
| 168 | p->mutex, |
| 169 | p->recursion_count, |
| 170 | p->owner); |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | VG_(message)(Vg_UserMsg, |
bart | 52e8291 | 2008-03-24 19:31:33 +0000 | [diff] [blame] | 175 | "The object at address 0x%lx is not a mutex.", |
bart | 6b71761 | 2008-03-24 09:29:38 +0000 | [diff] [blame] | 176 | p->mutex); |
| 177 | } |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 178 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 179 | break; |
| 180 | } |
| 181 | case CondErr: { |
| 182 | CondErrInfo* cdei =(CondErrInfo*)(VG_(get_error_extra)(e)); |
| 183 | VG_(message)(Vg_UserMsg, |
| 184 | "%s: cond 0x%lx", |
bart | be8a12c | 2008-03-17 18:36:55 +0000 | [diff] [blame] | 185 | VG_(get_error_string)(e), |
| 186 | cdei->cond); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 187 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 188 | break; |
| 189 | } |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 190 | case CondDestrErr: { |
| 191 | CondDestrErrInfo* cdi = (CondDestrErrInfo*)(VG_(get_error_extra)(e)); |
| 192 | VG_(message)(Vg_UserMsg, |
| 193 | "%s: cond 0x%lx, mutex 0x%lx locked by thread %d/%d", |
| 194 | VG_(get_error_string)(e), |
| 195 | cdi->cond, cdi->mutex, |
| 196 | DrdThreadIdToVgThreadId(cdi->tid), cdi->tid); |
| 197 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 198 | mutex_first_observed(cdi->mutex); |
| 199 | break; |
| 200 | } |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 201 | case CondRaceErr: { |
| 202 | CondRaceErrInfo* cei = (CondRaceErrInfo*)(VG_(get_error_extra)(e)); |
| 203 | VG_(message)(Vg_UserMsg, |
bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 204 | "Probably a race condition: condition variable 0x%lx has been" |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 205 | " signaled but the associated mutex 0x%lx is not locked" |
| 206 | " by the signalling thread.", |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 207 | cei->cond, cei->mutex); |
| 208 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 209 | mutex_first_observed(cei->mutex); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 210 | break; |
| 211 | } |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 212 | case CondWaitErr: { |
| 213 | CondWaitErrInfo* cwei = (CondWaitErrInfo*)(VG_(get_error_extra)(e)); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 214 | VG_(message)(Vg_UserMsg, |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 215 | "%s: condition variable 0x%lx, mutexes 0x%lx and 0x%lx", |
bart | be8a12c | 2008-03-17 18:36:55 +0000 | [diff] [blame] | 216 | VG_(get_error_string)(e), |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 217 | cwei->cond, |
| 218 | cwei->mutex1, |
| 219 | cwei->mutex2); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 220 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 221 | mutex_first_observed(cwei->mutex1); |
| 222 | mutex_first_observed(cwei->mutex2); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 223 | break; |
| 224 | } |
| 225 | case SemaphoreErr: { |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame] | 226 | SemaphoreErrInfo* sei = (SemaphoreErrInfo*)(VG_(get_error_extra)(e)); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 227 | tl_assert(sei); |
| 228 | VG_(message)(Vg_UserMsg, |
| 229 | "%s: semaphore 0x%lx", |
| 230 | VG_(get_error_string)(e), |
| 231 | sei->semaphore); |
| 232 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 233 | break; |
| 234 | } |
| 235 | case BarrierErr: { |
| 236 | BarrierErrInfo* sei =(BarrierErrInfo*)(VG_(get_error_extra)(e)); |
| 237 | tl_assert(sei); |
| 238 | VG_(message)(Vg_UserMsg, |
| 239 | "%s: barrier 0x%lx", |
| 240 | VG_(get_error_string)(e), |
| 241 | sei->barrier); |
| 242 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 243 | break; |
| 244 | } |
| 245 | case RwlockErr: { |
| 246 | RwlockErrInfo* p = (RwlockErrInfo*)(VG_(get_error_extra)(e)); |
| 247 | tl_assert(p); |
| 248 | VG_(message)(Vg_UserMsg, |
| 249 | "%s: rwlock 0x%lx.", |
| 250 | VG_(get_error_string)(e), |
| 251 | p->rwlock); |
| 252 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 253 | break; |
| 254 | } |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 255 | case HoldtimeErr: { |
| 256 | HoldtimeErrInfo* p =(HoldtimeErrInfo*)(VG_(get_error_extra)(e)); |
| 257 | tl_assert(p); |
| 258 | tl_assert(p->acquired_at); |
| 259 | VG_(message)(Vg_UserMsg, "Acquired at:"); |
| 260 | VG_(pp_ExeContext)(p->acquired_at); |
| 261 | VG_(message)(Vg_UserMsg, |
| 262 | "Lock on %s 0x%lx was held during %d ms (threshold: %d ms).", |
| 263 | VG_(get_error_string)(e), |
| 264 | p->synchronization_object, |
| 265 | p->hold_time_ms, |
| 266 | p->threshold_ms); |
| 267 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 268 | break; |
| 269 | } |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 270 | case GenericErr: { |
| 271 | //GenericErrInfo* gei =(GenericErrInfo*)(VG_(get_error_extra)(e)); |
| 272 | VG_(message)(Vg_UserMsg, "%s", VG_(get_error_string)(e)); |
| 273 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 274 | break; |
| 275 | } |
| 276 | default: |
| 277 | VG_(message)(Vg_UserMsg, |
| 278 | "%s", |
| 279 | VG_(get_error_string)(e)); |
| 280 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 281 | break; |
| 282 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | static UInt drd_tool_error_update_extra(Error* e) |
| 286 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 287 | switch (VG_(get_error_kind)(e)) |
| 288 | { |
| 289 | case DataRaceErr: |
| 290 | return sizeof(DataRaceErrInfo); |
| 291 | case MutexErr: |
| 292 | return sizeof(MutexErrInfo); |
| 293 | case CondErr: |
| 294 | return sizeof(CondErrInfo); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 295 | case CondDestrErr: |
| 296 | return sizeof(CondDestrErrInfo); |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 297 | case CondRaceErr: |
| 298 | return sizeof(CondRaceErrInfo); |
| 299 | case CondWaitErr: |
| 300 | return sizeof(CondWaitErrInfo); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 301 | case SemaphoreErr: |
| 302 | return sizeof(SemaphoreErrInfo); |
| 303 | case BarrierErr: |
| 304 | return sizeof(BarrierErrInfo); |
| 305 | case RwlockErr: |
| 306 | return sizeof(RwlockErrInfo); |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 307 | case HoldtimeErr: |
| 308 | return sizeof(HoldtimeErrInfo); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 309 | case GenericErr: |
| 310 | return sizeof(GenericErrInfo); |
| 311 | default: |
| 312 | tl_assert(False); |
| 313 | break; |
| 314 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | static Bool drd_tool_error_recog(Char* const name, Supp* const supp) |
| 318 | { |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 319 | SuppKind skind = 0; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 320 | |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 321 | if (VG_(strcmp)(name, STR_DataRaceErr) == 0) |
| 322 | ; |
| 323 | else if (VG_(strcmp)(name, STR_MutexErr) == 0) |
| 324 | ; |
| 325 | else if (VG_(strcmp)(name, STR_CondErr) == 0) |
| 326 | ; |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 327 | else if (VG_(strcmp)(name, STR_CondDestrErr) == 0) |
| 328 | ; |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 329 | else if (VG_(strcmp)(name, STR_CondRaceErr) == 0) |
| 330 | ; |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 331 | else if (VG_(strcmp)(name, STR_CondWaitErr) == 0) |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 332 | ; |
| 333 | else if (VG_(strcmp)(name, STR_SemaphoreErr) == 0) |
| 334 | ; |
| 335 | else if (VG_(strcmp)(name, STR_BarrierErr) == 0) |
| 336 | ; |
| 337 | else if (VG_(strcmp)(name, STR_RwlockErr) == 0) |
| 338 | ; |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 339 | else if (VG_(strcmp)(name, STR_HoldtimeErr) == 0) |
| 340 | ; |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 341 | else if (VG_(strcmp)(name, STR_GenericErr) == 0) |
| 342 | ; |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 343 | else |
| 344 | return False; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 345 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 346 | VG_(set_supp_kind)(supp, skind); |
| 347 | return True; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | static Bool drd_tool_error_read_extra(Int fd, Char* buf, Int nBuf, Supp* supp) |
| 351 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 352 | return True; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | static Bool drd_tool_error_matches(Error* const e, Supp* const supp) |
| 356 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 357 | switch (VG_(get_supp_kind)(supp)) |
| 358 | { |
| 359 | } |
| 360 | return True; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | static Char* drd_tool_error_name(Error* e) |
| 364 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 365 | switch (VG_(get_error_kind)(e)) |
| 366 | { |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 367 | case DataRaceErr: return VGAPPEND(STR_, DataRaceErr); |
| 368 | case MutexErr: return VGAPPEND(STR_, MutexErr); |
| 369 | case CondErr: return VGAPPEND(STR_, CondErr); |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 370 | case CondDestrErr: return VGAPPEND(STR_, CondDestrErr); |
bart | 3bb1cec | 2008-06-28 16:01:43 +0000 | [diff] [blame] | 371 | case CondRaceErr: return VGAPPEND(STR_, CondRaceErr); |
| 372 | case CondWaitErr: return VGAPPEND(STR_, CondWaitErr); |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 373 | case SemaphoreErr: return VGAPPEND(STR_, SemaphoreErr); |
| 374 | case BarrierErr: return VGAPPEND(STR_, BarrierErr); |
| 375 | case RwlockErr: return VGAPPEND(STR_, RwlockErr); |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 376 | case HoldtimeErr: return VGAPPEND(STR_, HoldtimeErr); |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 377 | case GenericErr: return VGAPPEND(STR_, GenericErr); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 378 | default: |
| 379 | tl_assert(0); |
| 380 | } |
| 381 | return 0; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | static void drd_tool_error_print_extra(Error* e) |
| 385 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 386 | switch (VG_(get_error_kind)(e)) |
| 387 | { |
| 388 | // VG_(printf)(" %s\n", VG_(get_error_string)(err)); |
| 389 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | void drd_register_error_handlers(void) |
| 393 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 394 | // Tool error reporting. |
| 395 | VG_(needs_tool_errors)(drd_tool_error_eq, |
| 396 | drd_tool_error_pp, |
| 397 | True, |
| 398 | drd_tool_error_update_extra, |
| 399 | drd_tool_error_recog, |
| 400 | drd_tool_error_read_extra, |
| 401 | drd_tool_error_matches, |
| 402 | drd_tool_error_name, |
| 403 | drd_tool_error_print_extra); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 404 | } |