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 | } |
| 190 | case CondRaceErr: { |
| 191 | CondRaceErrInfo* cei = (CondRaceErrInfo*)(VG_(get_error_extra)(e)); |
| 192 | VG_(message)(Vg_UserMsg, |
bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 193 | "Probably a race condition: condition variable 0x%lx has been" |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame^] | 194 | " signaled but the associated mutex 0x%lx is not locked" |
| 195 | " by the signalling thread.", |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 196 | cei->cond, cei->mutex); |
| 197 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame^] | 198 | mutex_first_observed(cei->mutex); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 199 | break; |
| 200 | } |
| 201 | case CondDestrErr: { |
| 202 | CondDestrErrInfo* cdi = (CondDestrErrInfo*)(VG_(get_error_extra)(e)); |
| 203 | VG_(message)(Vg_UserMsg, |
bart | aa97a54 | 2008-03-16 17:57:01 +0000 | [diff] [blame] | 204 | "%s: cond 0x%lx, mutex 0x%lx locked by thread %d/%d", |
bart | be8a12c | 2008-03-17 18:36:55 +0000 | [diff] [blame] | 205 | VG_(get_error_string)(e), |
bart | aa97a54 | 2008-03-16 17:57:01 +0000 | [diff] [blame] | 206 | cdi->cond, cdi->mutex, |
| 207 | DrdThreadIdToVgThreadId(cdi->tid), cdi->tid); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 208 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame^] | 209 | mutex_first_observed(cdi->mutex); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 210 | break; |
| 211 | } |
| 212 | case SemaphoreErr: { |
bart | 886b87c | 2008-06-28 13:40:41 +0000 | [diff] [blame^] | 213 | SemaphoreErrInfo* sei = (SemaphoreErrInfo*)(VG_(get_error_extra)(e)); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 214 | tl_assert(sei); |
| 215 | VG_(message)(Vg_UserMsg, |
| 216 | "%s: semaphore 0x%lx", |
| 217 | VG_(get_error_string)(e), |
| 218 | sei->semaphore); |
| 219 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 220 | break; |
| 221 | } |
| 222 | case BarrierErr: { |
| 223 | BarrierErrInfo* sei =(BarrierErrInfo*)(VG_(get_error_extra)(e)); |
| 224 | tl_assert(sei); |
| 225 | VG_(message)(Vg_UserMsg, |
| 226 | "%s: barrier 0x%lx", |
| 227 | VG_(get_error_string)(e), |
| 228 | sei->barrier); |
| 229 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 230 | break; |
| 231 | } |
| 232 | case RwlockErr: { |
| 233 | RwlockErrInfo* p = (RwlockErrInfo*)(VG_(get_error_extra)(e)); |
| 234 | tl_assert(p); |
| 235 | VG_(message)(Vg_UserMsg, |
| 236 | "%s: rwlock 0x%lx.", |
| 237 | VG_(get_error_string)(e), |
| 238 | p->rwlock); |
| 239 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 240 | break; |
| 241 | } |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 242 | case HoldtimeErr: { |
| 243 | HoldtimeErrInfo* p =(HoldtimeErrInfo*)(VG_(get_error_extra)(e)); |
| 244 | tl_assert(p); |
| 245 | tl_assert(p->acquired_at); |
| 246 | VG_(message)(Vg_UserMsg, "Acquired at:"); |
| 247 | VG_(pp_ExeContext)(p->acquired_at); |
| 248 | VG_(message)(Vg_UserMsg, |
| 249 | "Lock on %s 0x%lx was held during %d ms (threshold: %d ms).", |
| 250 | VG_(get_error_string)(e), |
| 251 | p->synchronization_object, |
| 252 | p->hold_time_ms, |
| 253 | p->threshold_ms); |
| 254 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 255 | break; |
| 256 | } |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 257 | case GenericErr: { |
| 258 | //GenericErrInfo* gei =(GenericErrInfo*)(VG_(get_error_extra)(e)); |
| 259 | VG_(message)(Vg_UserMsg, "%s", VG_(get_error_string)(e)); |
| 260 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 261 | break; |
| 262 | } |
| 263 | default: |
| 264 | VG_(message)(Vg_UserMsg, |
| 265 | "%s", |
| 266 | VG_(get_error_string)(e)); |
| 267 | VG_(pp_ExeContext)(VG_(get_error_where)(e)); |
| 268 | break; |
| 269 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | static UInt drd_tool_error_update_extra(Error* e) |
| 273 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 274 | switch (VG_(get_error_kind)(e)) |
| 275 | { |
| 276 | case DataRaceErr: |
| 277 | return sizeof(DataRaceErrInfo); |
| 278 | case MutexErr: |
| 279 | return sizeof(MutexErrInfo); |
| 280 | case CondErr: |
| 281 | return sizeof(CondErrInfo); |
| 282 | case CondRaceErr: |
| 283 | return sizeof(CondRaceErrInfo); |
| 284 | case CondDestrErr: |
| 285 | return sizeof(CondDestrErrInfo); |
| 286 | case SemaphoreErr: |
| 287 | return sizeof(SemaphoreErrInfo); |
| 288 | case BarrierErr: |
| 289 | return sizeof(BarrierErrInfo); |
| 290 | case RwlockErr: |
| 291 | return sizeof(RwlockErrInfo); |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 292 | case HoldtimeErr: |
| 293 | return sizeof(HoldtimeErrInfo); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 294 | case GenericErr: |
| 295 | return sizeof(GenericErrInfo); |
| 296 | default: |
| 297 | tl_assert(False); |
| 298 | break; |
| 299 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | static Bool drd_tool_error_recog(Char* const name, Supp* const supp) |
| 303 | { |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 304 | SuppKind skind = 0; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 305 | |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 306 | if (VG_(strcmp)(name, STR_DataRaceErr) == 0) |
| 307 | ; |
| 308 | else if (VG_(strcmp)(name, STR_MutexErr) == 0) |
| 309 | ; |
| 310 | else if (VG_(strcmp)(name, STR_CondErr) == 0) |
| 311 | ; |
| 312 | else if (VG_(strcmp)(name, STR_CondRaceErr) == 0) |
| 313 | ; |
| 314 | else if (VG_(strcmp)(name, STR_CondDestrErr) == 0) |
| 315 | ; |
| 316 | else if (VG_(strcmp)(name, STR_SemaphoreErr) == 0) |
| 317 | ; |
| 318 | else if (VG_(strcmp)(name, STR_BarrierErr) == 0) |
| 319 | ; |
| 320 | else if (VG_(strcmp)(name, STR_RwlockErr) == 0) |
| 321 | ; |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 322 | else if (VG_(strcmp)(name, STR_HoldtimeErr) == 0) |
| 323 | ; |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 324 | else if (VG_(strcmp)(name, STR_GenericErr) == 0) |
| 325 | ; |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 326 | else |
| 327 | return False; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 328 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 329 | VG_(set_supp_kind)(supp, skind); |
| 330 | return True; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | static Bool drd_tool_error_read_extra(Int fd, Char* buf, Int nBuf, Supp* supp) |
| 334 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 335 | return True; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | static Bool drd_tool_error_matches(Error* const e, Supp* const supp) |
| 339 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 340 | switch (VG_(get_supp_kind)(supp)) |
| 341 | { |
| 342 | } |
| 343 | return True; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | static Char* drd_tool_error_name(Error* e) |
| 347 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 348 | switch (VG_(get_error_kind)(e)) |
| 349 | { |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 350 | case DataRaceErr: return VGAPPEND(STR_, DataRaceErr); |
| 351 | case MutexErr: return VGAPPEND(STR_, MutexErr); |
| 352 | case CondErr: return VGAPPEND(STR_, CondErr); |
| 353 | case CondRaceErr: return VGAPPEND(STR_, CondRaceErr); |
| 354 | case CondDestrErr: return VGAPPEND(STR_, CondDestrErr); |
| 355 | case SemaphoreErr: return VGAPPEND(STR_, SemaphoreErr); |
| 356 | case BarrierErr: return VGAPPEND(STR_, BarrierErr); |
| 357 | case RwlockErr: return VGAPPEND(STR_, RwlockErr); |
bart | 9d5b796 | 2008-05-14 12:25:00 +0000 | [diff] [blame] | 358 | case HoldtimeErr: return VGAPPEND(STR_, HoldtimeErr); |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 359 | case GenericErr: return VGAPPEND(STR_, GenericErr); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 360 | default: |
| 361 | tl_assert(0); |
| 362 | } |
| 363 | return 0; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | static void drd_tool_error_print_extra(Error* e) |
| 367 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 368 | switch (VG_(get_error_kind)(e)) |
| 369 | { |
| 370 | // VG_(printf)(" %s\n", VG_(get_error_string)(err)); |
| 371 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | void drd_register_error_handlers(void) |
| 375 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 376 | // Tool error reporting. |
| 377 | VG_(needs_tool_errors)(drd_tool_error_eq, |
| 378 | drd_tool_error_pp, |
| 379 | True, |
| 380 | drd_tool_error_update_extra, |
| 381 | drd_tool_error_recog, |
| 382 | drd_tool_error_read_extra, |
| 383 | drd_tool_error_matches, |
| 384 | drd_tool_error_name, |
| 385 | drd_tool_error_print_extra); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 386 | } |