1 /*
2 This file is part of drd, a thread error detector.
3
4 Copyright (C) 2006-2017 Bart Van Assche <bvanassche@acm.org>.
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307, USA.
20
21 The GNU General Public License is contained in the file COPYING.
22 */
23
24
25 #include "drd_clientobj.h" /* struct mutex_info */
26 #include "drd_error.h"
27 #include "drd_malloc_wrappers.h"
28 #include "drd_mutex.h"
29 #include "drd_suppression.h" /* drd_start_suppression() */
30 #include "pub_drd_bitmap.h" /* LHS_W, ... */
31 #include "pub_tool_vki.h"
32 #include "pub_tool_basics.h"
33 #include "pub_tool_libcassert.h" /* tl_assert() */
34 #include "pub_tool_libcbase.h" /* strlen() */
35 #include "pub_tool_libcprint.h" /* VG_(printf)() */
36 #include "pub_tool_machine.h"
37 #include "pub_tool_mallocfree.h" /* VG_(malloc), VG_(free) */
38 #include "pub_tool_options.h" /* VG_(clo_xml) */
39 #include "pub_tool_threadstate.h" /* VG_(get_pthread_id)() */
40 #include "pub_tool_tooliface.h" /* VG_(needs_tool_errors)() */
41
42
43 /* Local function declarations. */
44
45 static const HChar* drd_get_error_name(const Error* e);
46
47
48 /* Local variables. */
49
50 static Bool s_show_conflicting_segments = True;
51
52
DRD_(set_show_conflicting_segments)53 void DRD_(set_show_conflicting_segments)(const Bool scs)
54 {
55 s_show_conflicting_segments = scs;
56 }
57
DRD_(trace_msg)58 void DRD_(trace_msg)(const HChar* format, ...)
59 {
60 va_list vargs;
61 va_start(vargs, format);
62 if (VG_(clo_xml)) {
63 VG_(printf_xml)(" <trace><text>");
64 VG_(vprintf_xml)(format, vargs);
65 VG_(printf_xml)("</text></trace>\n");
66 } else {
67 VG_(vmessage)(Vg_UserMsg, format, vargs);
68 VG_(message)(Vg_UserMsg, "\n");
69 }
70 va_end(vargs);
71 }
72
DRD_(trace_msg_w_bt)73 void DRD_(trace_msg_w_bt)(const HChar* format, ...)
74 {
75 va_list vargs;
76 va_start(vargs, format);
77 if (VG_(clo_xml)) {
78 VG_(printf_xml)(" <trace><text>");
79 VG_(vprintf_xml)(format, vargs);
80 VG_(printf_xml)("</text>\n");
81 } else {
82 VG_(vmessage)(Vg_UserMsg, format, vargs);
83 VG_(message)(Vg_UserMsg, "\n");
84 }
85 VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(), VG_(clo_backtrace_size));
86 va_end(vargs);
87 if (VG_(clo_xml))
88 VG_(printf_xml)(" </trace>\n");
89 }
90
91 /**
92 * Emit error message detail in the format requested by the user.
93 */
94 static void print_err_detail(const HChar* format, ...) PRINTF_CHECK(1, 2);
print_err_detail(const HChar * format,...)95 static void print_err_detail(const HChar* format, ...)
96 {
97 va_list vargs;
98 va_start(vargs, format);
99 if (VG_(clo_xml))
100 VG_(vprintf_xml)(format, vargs);
101 else
102 VG_(vmessage)(Vg_UserMsg, format, vargs);
103 va_end(vargs);
104 }
105
106 /**
107 * Describe the client address a as good as possible, putting the result in ai.
108 */
109 static
describe_malloced_addr(Addr const a,AddrInfo * const ai)110 void describe_malloced_addr(Addr const a, AddrInfo* const ai)
111 {
112 Addr heap_block_start;
113
114 if (DRD_(heap_addrinfo)(a, &heap_block_start, &ai->size, &ai->lastchange))
115 {
116 ai->akind = eMallocd;
117 ai->rwoffset = a - heap_block_start;
118 }
119 else
120 {
121 ai->akind = eUnknown;
122 }
123 }
124
125 /**
126 * Report where a client synchronization object has been observed for the first
127 * time. The printed call stack will either refer to a pthread_*_init() or a
128 * pthread_*lock() call.
129 */
first_observed(const Addr obj)130 static void first_observed(const Addr obj)
131 {
132 DrdClientobj* cl;
133
134 cl = DRD_(clientobj_get_any)(obj);
135 if (cl) {
136 tl_assert(cl->any.first_observed_at);
137 if (VG_(clo_xml)) {
138 print_err_detail(" <first_observed_at>\n"
139 " <what>%pS</what>\n"
140 " <address>0x%lx</address>\n",
141 DRD_(clientobj_type_name)(cl->any.type), obj);
142 VG_(pp_ExeContext)(cl->any.first_observed_at);
143 print_err_detail(" </first_observed_at>\n");
144 } else {
145 print_err_detail("%s 0x%lx was first observed at:\n",
146 DRD_(clientobj_type_name)(cl->any.type), obj);
147 VG_(pp_ExeContext)(cl->any.first_observed_at);
148 }
149 }
150 }
151
152 static
drd_report_data_race(const Error * const err,const DataRaceErrInfo * const dri)153 void drd_report_data_race(const Error* const err,
154 const DataRaceErrInfo* const dri)
155 {
156 const Bool xml = VG_(clo_xml);
157 const HChar* const what_prefix = xml ? " <what>" : "";
158 const HChar* const what_suffix = xml ? "</what>" : "";
159 const HChar* const auxwhat_prefix = xml ? " <auxwhat>" : "";
160 const HChar* const auxwhat_suffix = xml ? "</auxwhat>" : "";
161 const HChar* const indent = xml ? " " : "";
162
163 AddrInfo ai;
164 VG_(memset)(&ai, 0, sizeof(ai));
165 ai.akind = eUnknown; // A safe initial value (?)
166
167 DiEpoch cur_ep = VG_(current_DiEpoch)();
168 XArray* /* of HChar */ descr1
169 = VG_(newXA)( VG_(malloc), "drd.error.drdr2.1",
170 VG_(free), sizeof(HChar) );
171 XArray* /* of HChar */ descr2
172 = VG_(newXA)( VG_(malloc), "drd.error.drdr2.2",
173 VG_(free), sizeof(HChar) );
174
175 tl_assert(dri);
176 tl_assert(dri->addr);
177 tl_assert(dri->size > 0);
178
179 (void) VG_(get_data_description)(descr1, descr2, cur_ep, dri->addr);
180 /* If there's nothing in descr1/2, free them. Why is it safe to
181 VG_(indexXA) at zero here? Because VG_(get_data_description)
182 guarantees to zero terminate descr1/2 regardless of the outcome
183 of the call. So there's always at least one element in each XA
184 after the call.
185 */
186 if (0 == VG_(strlen)( VG_(indexXA)( descr1, 0 ))) {
187 VG_(deleteXA)( descr1 );
188 descr1 = NULL;
189 }
190 if (0 == VG_(strlen)( VG_(indexXA)( descr2, 0 ))) {
191 VG_(deleteXA)( descr2 );
192 descr2 = NULL;
193 }
194 /* Assume (assert) that VG_(get_data_description) fills in descr1
195 before it fills in descr2 */
196 if (descr1 == NULL)
197 tl_assert(descr2 == NULL);
198 /* So anyway. Do we have something useful? */
199 if (descr1 == NULL)
200 {
201 /* No. Do Plan B. */
202 describe_malloced_addr(dri->addr, &ai);
203 }
204
205 print_err_detail("%sConflicting %s by thread %u at 0x%08lx size %lu%s\n",
206 what_prefix, dri->access_type == eStore ? "store" : "load",
207 dri->tid, dri->addr, dri->size, what_suffix);
208
209 VG_(pp_ExeContext)(VG_(get_error_where)(err));
210 if (descr1 != NULL) {
211 print_err_detail("%s%s\n", indent, (HChar*)VG_(indexXA)(descr1, 0));
212 if (descr2 != NULL)
213 print_err_detail("%s%s\n", indent, (HChar*)VG_(indexXA)(descr2, 0));
214 } else if (ai.akind == eMallocd && ai.lastchange) {
215 print_err_detail("%sAddress 0x%lx is at offset %ld from 0x%lx.%s%s",
216 auxwhat_prefix, dri->addr, ai.rwoffset,
217 dri->addr - ai.rwoffset, auxwhat_suffix,
218 xml ? "\n" : "");
219 if (xml)
220 print_err_detail(" <allocation_context>\n");
221 else
222 print_err_detail(" Allocation context:\n");
223 VG_(pp_ExeContext)(ai.lastchange);
224 if (xml)
225 print_err_detail(" </allocation_context>\n");
226 } else {
227 const HChar *sect_name;
228 VgSectKind sect_kind;
229
230 sect_kind = VG_(DebugInfo_sect_kind)(§_name, dri->addr);
231 if (sect_kind != Vg_SectUnknown) {
232 print_err_detail("%sAllocation context: %ps section of %ps%s\n",
233 auxwhat_prefix, VG_(pp_SectKind)(sect_kind),
234 sect_name, auxwhat_suffix);
235 } else {
236 print_err_detail("%sAllocation context: unknown.%s\n",
237 auxwhat_prefix, auxwhat_suffix);
238 }
239 }
240 if (s_show_conflicting_segments)
241 {
242 DRD_(thread_report_conflicting_segments)(dri->tid,
243 dri->addr, dri->size,
244 dri->access_type);
245 }
246
247 if (descr2)
248 VG_(deleteXA)(descr2);
249 if (descr1)
250 VG_(deleteXA)(descr1);
251 }
252
253 /**
254 * Compare two error contexts. The core function VG_(maybe_record_error)()
255 * calls this function to compare error contexts such that errors that occur
256 * repeatedly are only printed once. This function is only called by the core
257 * if the error kind of e1 and e2 matches and if the ExeContext's of e1 and
258 * e2 also match.
259 */
drd_compare_error_contexts(VgRes res,const Error * e1,const Error * e2)260 static Bool drd_compare_error_contexts(VgRes res, const Error* e1,
261 const Error* e2)
262 {
263 tl_assert(VG_(get_error_kind)(e1) == VG_(get_error_kind)(e2));
264
265 switch (VG_(get_error_kind)(e1))
266 {
267 case DataRaceErr:
268 {
269 const DataRaceErrInfo* const dri1 = VG_(get_error_extra)(e1);
270 const DataRaceErrInfo* const dri2 = VG_(get_error_extra)(e2);
271 return dri1->access_type == dri2->access_type
272 && dri1->size == dri2->size;
273 }
274 case MutexErr:
275 {
276 const MutexErrInfo* const mei1 = VG_(get_error_extra)(e1);
277 const MutexErrInfo* const mei2 = VG_(get_error_extra)(e2);
278 return mei1->mutex == mei2->mutex;
279 }
280 default:
281 return True;
282 }
283 }
284
285 /**
286 * Called by the core just before an error message will be printed. Used by
287 * DRD to print the thread number as a preamble.
288 */
drd_tool_error_before_pp(const Error * const e)289 static void drd_tool_error_before_pp(const Error* const e)
290 {
291 static DrdThreadId s_last_tid_printed = 1;
292 DrdThreadId* err_extra;
293
294 err_extra = VG_(get_error_extra)(e);
295
296 if (err_extra && *err_extra != s_last_tid_printed && !VG_(clo_xml)) {
297 VG_(umsg)("%s:\n", DRD_(thread_get_name)(*err_extra));
298 s_last_tid_printed = *err_extra;
299 }
300 }
301
302 /** Report an error to the user. */
drd_tool_error_pp(const Error * const e)303 static void drd_tool_error_pp(const Error* const e)
304 {
305 const Bool xml = VG_(clo_xml);
306 const HChar* const what_prefix = xml ? " <what>" : "";
307 const HChar* const what_suffix = xml ? "</what>" : "";
308
309 if (xml)
310 VG_(printf_xml)( " <kind>%pS</kind>\n", drd_get_error_name(e));
311
312 switch (VG_(get_error_kind)(e))
313 {
314 case DataRaceErr: {
315 drd_report_data_race(e, VG_(get_error_extra)(e));
316 break;
317 }
318 case MutexErr: {
319 MutexErrInfo* p = (MutexErrInfo*)(VG_(get_error_extra)(e));
320 tl_assert(p);
321 if (p->recursion_count >= 0) {
322 print_err_detail("%s%s: mutex 0x%lx, recursion count %d, owner %u."
323 "%s\n", what_prefix, VG_(get_error_string)(e),
324 p->mutex, p->recursion_count, p->owner, what_suffix);
325 } else {
326 print_err_detail("%sThe object at address 0x%lx is not a mutex.%s\n",
327 what_prefix, p->mutex, what_suffix);
328 }
329 VG_(pp_ExeContext)(VG_(get_error_where)(e));
330 first_observed(p->mutex);
331 break;
332 }
333 case CondErr: {
334 CondErrInfo* cdei =(CondErrInfo*)(VG_(get_error_extra)(e));
335 print_err_detail("%s%s: cond 0x%lx%s\n", what_prefix,
336 VG_(get_error_string)(e), cdei->cond, what_suffix);
337 VG_(pp_ExeContext)(VG_(get_error_where)(e));
338 first_observed(cdei->cond);
339 break;
340 }
341 case CondDestrErr: {
342 CondDestrErrInfo* cdi = (CondDestrErrInfo*)(VG_(get_error_extra)(e));
343 print_err_detail("%s%s: cond 0x%lx, mutex 0x%lx locked by thread %u%s\n",
344 what_prefix, VG_(get_error_string)(e), cdi->cond,
345 cdi->mutex, cdi->owner, what_suffix);
346 VG_(pp_ExeContext)(VG_(get_error_where)(e));
347 first_observed(cdi->mutex);
348 break;
349 }
350 case CondRaceErr: {
351 CondRaceErrInfo* cei = (CondRaceErrInfo*)(VG_(get_error_extra)(e));
352 print_err_detail("%sProbably a race condition: condition variable 0x%lx"
353 " has been signaled but the associated mutex 0x%lx is"
354 " not locked by the signalling thread.%s\n",
355 what_prefix, cei->cond, cei->mutex, what_suffix);
356 VG_(pp_ExeContext)(VG_(get_error_where)(e));
357 first_observed(cei->cond);
358 first_observed(cei->mutex);
359 break;
360 }
361 case CondWaitErr: {
362 CondWaitErrInfo* cwei = (CondWaitErrInfo*)(VG_(get_error_extra)(e));
363 print_err_detail("%s%s: condition variable 0x%lx, mutexes 0x%lx and"
364 " 0x%lx%s\n", what_prefix, VG_(get_error_string)(e),
365 cwei->cond, cwei->mutex1, cwei->mutex2, what_suffix);
366 VG_(pp_ExeContext)(VG_(get_error_where)(e));
367 first_observed(cwei->cond);
368 first_observed(cwei->mutex1);
369 first_observed(cwei->mutex2);
370 break;
371 }
372 case SemaphoreErr: {
373 SemaphoreErrInfo* sei = (SemaphoreErrInfo*)(VG_(get_error_extra)(e));
374 tl_assert(sei);
375 print_err_detail("%s%s: semaphore 0x%lx%s\n", what_prefix,
376 VG_(get_error_string)(e), sei->semaphore, what_suffix);
377 VG_(pp_ExeContext)(VG_(get_error_where)(e));
378 first_observed(sei->semaphore);
379 break;
380 }
381 case BarrierErr: {
382 BarrierErrInfo* bei = (BarrierErrInfo*)(VG_(get_error_extra)(e));
383 tl_assert(bei);
384 print_err_detail("%s%s: barrier 0x%lx%s\n", what_prefix,
385 VG_(get_error_string)(e), bei->barrier, what_suffix);
386 VG_(pp_ExeContext)(VG_(get_error_where)(e));
387 if (bei->other_context) {
388 if (xml)
389 print_err_detail(" <confl_wait_call>\n");
390 print_err_detail("%sConflicting wait call by thread %u:%s\n",
391 what_prefix, bei->other_tid, what_suffix);
392 VG_(pp_ExeContext)(bei->other_context);
393 if (xml)
394 print_err_detail(" </confl_wait_call>\n");
395 }
396 first_observed(bei->barrier);
397 break;
398 }
399 case RwlockErr: {
400 RwlockErrInfo* p = (RwlockErrInfo*)(VG_(get_error_extra)(e));
401 tl_assert(p);
402 print_err_detail("%s%s: rwlock 0x%lx.%s\n", what_prefix,
403 VG_(get_error_string)(e), p->rwlock, what_suffix);
404 VG_(pp_ExeContext)(VG_(get_error_where)(e));
405 first_observed(p->rwlock);
406 break;
407 }
408 case HoldtimeErr: {
409 HoldtimeErrInfo* p =(HoldtimeErrInfo*)(VG_(get_error_extra)(e));
410 tl_assert(p);
411 tl_assert(p->acquired_at);
412 if (xml)
413 print_err_detail(" <acquired_at>\n");
414 else
415 print_err_detail("Acquired at:\n");
416 VG_(pp_ExeContext)(p->acquired_at);
417 if (xml)
418 print_err_detail(" </acquired_at>\n");
419 print_err_detail("%sLock on %s 0x%lx was held during %u ms"
420 " (threshold: %u ms).%s\n", what_prefix,
421 VG_(get_error_string)(e), p->synchronization_object,
422 p->hold_time_ms, p->threshold_ms, what_suffix);
423 VG_(pp_ExeContext)(VG_(get_error_where)(e));
424 first_observed(p->synchronization_object);
425 break;
426 }
427 case GenericErr: {
428 GenericErrInfo* gei = (GenericErrInfo*)(VG_(get_error_extra)(e));
429 print_err_detail("%s%s%s\n", what_prefix, VG_(get_error_string)(e),
430 what_suffix);
431 VG_(pp_ExeContext)(VG_(get_error_where)(e));
432 if (gei->addr)
433 first_observed(gei->addr);
434 break;
435 }
436 case InvalidThreadId: {
437 InvalidThreadIdInfo* iti =(InvalidThreadIdInfo*)(VG_(get_error_extra)(e));
438 print_err_detail("%s%s 0x%llx%s\n", what_prefix, VG_(get_error_string)(e),
439 iti->ptid, what_suffix);
440 VG_(pp_ExeContext)(VG_(get_error_where)(e));
441 break;
442 }
443 case UnimpHgClReq: {
444 UnimpClReqInfo* uicr =(UnimpClReqInfo*)(VG_(get_error_extra)(e));
445 print_err_detail("%sThe annotation macro %s has not yet been implemented"
446 " in %ps%s\n", what_prefix, uicr->descr,
447 "<valgrind/helgrind.h>", what_suffix);
448 VG_(pp_ExeContext)(VG_(get_error_where)(e));
449 break;
450 }
451 case UnimpDrdClReq: {
452 UnimpClReqInfo* uicr =(UnimpClReqInfo*)(VG_(get_error_extra)(e));
453 print_err_detail("%sThe annotation macro %s has not yet been implemented"
454 " in %ps%s\n", what_prefix, uicr->descr,
455 "<valgrind/drd.h>", what_suffix);
456 VG_(pp_ExeContext)(VG_(get_error_where)(e));
457 break;
458 }
459 default:
460 print_err_detail("%s%s%s\n", what_prefix, VG_(get_error_string)(e),
461 what_suffix);
462 VG_(pp_ExeContext)(VG_(get_error_where)(e));
463 break;
464 }
465 }
466
drd_tool_error_update_extra(const Error * e)467 static UInt drd_tool_error_update_extra(const Error* e)
468 {
469 switch (VG_(get_error_kind)(e))
470 {
471 case DataRaceErr:
472 return sizeof(DataRaceErrInfo);
473 case MutexErr:
474 return sizeof(MutexErrInfo);
475 case CondErr:
476 return sizeof(CondErrInfo);
477 case CondDestrErr:
478 return sizeof(CondDestrErrInfo);
479 case CondRaceErr:
480 return sizeof(CondRaceErrInfo);
481 case CondWaitErr:
482 return sizeof(CondWaitErrInfo);
483 case SemaphoreErr:
484 return sizeof(SemaphoreErrInfo);
485 case BarrierErr:
486 return sizeof(BarrierErrInfo);
487 case RwlockErr:
488 return sizeof(RwlockErrInfo);
489 case HoldtimeErr:
490 return sizeof(HoldtimeErrInfo);
491 case GenericErr:
492 return sizeof(GenericErrInfo);
493 case InvalidThreadId:
494 return sizeof(InvalidThreadIdInfo);
495 case UnimpHgClReq:
496 return sizeof(UnimpClReqInfo);
497 case UnimpDrdClReq:
498 return sizeof(UnimpClReqInfo);
499 default:
500 tl_assert(False);
501 break;
502 }
503 }
504
505 /**
506 * Parse suppression name.
507 *
508 * The suppression types recognized by DRD are the same types as the error
509 * types supported by DRD. So try to match the suppression name against the
510 * names of DRD error types.
511 */
drd_is_recognized_suppression(const HChar * const name,Supp * const supp)512 static Bool drd_is_recognized_suppression(const HChar* const name,
513 Supp* const supp)
514 {
515 DrdErrorKind skind = 0;
516
517 if (VG_(strcmp)(name, STR_DataRaceErr) == 0)
518 skind = DataRaceErr;
519 else if (VG_(strcmp)(name, STR_MutexErr) == 0)
520 skind = MutexErr;
521 else if (VG_(strcmp)(name, STR_CondErr) == 0)
522 skind = CondErr;
523 else if (VG_(strcmp)(name, STR_CondDestrErr) == 0)
524 skind = CondDestrErr;
525 else if (VG_(strcmp)(name, STR_CondRaceErr) == 0)
526 skind = CondRaceErr;
527 else if (VG_(strcmp)(name, STR_CondWaitErr) == 0)
528 skind = CondWaitErr;
529 else if (VG_(strcmp)(name, STR_SemaphoreErr) == 0)
530 skind = SemaphoreErr;
531 else if (VG_(strcmp)(name, STR_BarrierErr) == 0)
532 skind = BarrierErr;
533 else if (VG_(strcmp)(name, STR_RwlockErr) == 0)
534 skind = RwlockErr;
535 else if (VG_(strcmp)(name, STR_HoldtimeErr) == 0)
536 skind = HoldtimeErr;
537 else if (VG_(strcmp)(name, STR_GenericErr) == 0)
538 skind = GenericErr;
539 else if (VG_(strcmp)(name, STR_InvalidThreadId) == 0)
540 skind = InvalidThreadId;
541 else if (VG_(strcmp)(name, STR_UnimpHgClReq) == 0)
542 skind = UnimpHgClReq;
543 else if (VG_(strcmp)(name, STR_UnimpDrdClReq) == 0)
544 skind = UnimpDrdClReq;
545 else
546 return False;
547
548 VG_(set_supp_kind)(supp, skind);
549 return True;
550 }
551
552 /**
553 * Read additional suppression information from the suppression file.
554 *
555 * None of the suppression patterns recognized by DRD has 'extra' lines
556 * of information in the suppression file, so just return True to indicate
557 * that reading the 'extra' lines succeeded.
558 */
559 static
drd_read_extra_suppression_info(Int fd,HChar ** bufpp,SizeT * nBufp,Int * lineno,Supp * supp)560 Bool drd_read_extra_suppression_info(Int fd, HChar** bufpp,
561 SizeT* nBufp, Int* lineno, Supp* supp)
562 {
563 return True;
564 }
565
566 /**
567 * Determine whether or not the types of the given error message and the
568 * given suppression match.
569 */
drd_error_matches_suppression(const Error * const e,const Supp * const supp)570 static Bool drd_error_matches_suppression(const Error* const e,
571 const Supp* const supp)
572 {
573 return VG_(get_supp_kind)(supp) == VG_(get_error_kind)(e);
574 }
575
drd_get_error_name(const Error * e)576 static const HChar* drd_get_error_name(const Error* e)
577 {
578 switch (VG_(get_error_kind)(e))
579 {
580 case DataRaceErr: return VGAPPEND(STR_, DataRaceErr);
581 case MutexErr: return VGAPPEND(STR_, MutexErr);
582 case CondErr: return VGAPPEND(STR_, CondErr);
583 case CondDestrErr: return VGAPPEND(STR_, CondDestrErr);
584 case CondRaceErr: return VGAPPEND(STR_, CondRaceErr);
585 case CondWaitErr: return VGAPPEND(STR_, CondWaitErr);
586 case SemaphoreErr: return VGAPPEND(STR_, SemaphoreErr);
587 case BarrierErr: return VGAPPEND(STR_, BarrierErr);
588 case RwlockErr: return VGAPPEND(STR_, RwlockErr);
589 case HoldtimeErr: return VGAPPEND(STR_, HoldtimeErr);
590 case GenericErr: return VGAPPEND(STR_, GenericErr);
591 case InvalidThreadId: return VGAPPEND(STR_, InvalidThreadId);
592 case UnimpHgClReq: return VGAPPEND(STR_, UnimpHgClReq);
593 case UnimpDrdClReq: return VGAPPEND(STR_, UnimpDrdClReq);
594 default:
595 tl_assert(0);
596 }
597 return 0;
598 }
599
600 /**
601 * Return extra suppression information.
602 *
603 * Invoked while printing a suppression pattern because the user
604 * specified --gen-suppressions=yes or all on the command line. DRD does not
605 * define any 'extra' suppression information.
606 */
607 static
drd_get_extra_suppression_info(const Error * e,HChar * buf,Int nBuf)608 SizeT drd_get_extra_suppression_info(const Error* e,
609 /*OUT*/HChar* buf, Int nBuf)
610 {
611 tl_assert(nBuf >= 1);
612 buf[0] = '\0';
613 return 0;
614 }
615
616 static
drd_print_extra_suppression_use(const Supp * su,HChar * buf,Int nBuf)617 SizeT drd_print_extra_suppression_use(const Supp* su,
618 /*OUT*/HChar* buf, Int nBuf)
619 {
620 tl_assert(nBuf >= 1);
621 buf[0] = '\0';
622 return 0;
623 }
624
625 static
drd_update_extra_suppresion_use(const Error * e,const Supp * supp)626 void drd_update_extra_suppresion_use(const Error* e, const Supp* supp)
627 {
628 return;
629 }
630
631 /** Tell the Valgrind core about DRD's error handlers. */
DRD_(register_error_handlers)632 void DRD_(register_error_handlers)(void)
633 {
634 VG_(needs_tool_errors)(drd_compare_error_contexts,
635 drd_tool_error_before_pp,
636 drd_tool_error_pp,
637 False,
638 drd_tool_error_update_extra,
639 drd_is_recognized_suppression,
640 drd_read_extra_suppression_info,
641 drd_error_matches_suppression,
642 drd_get_error_name,
643 drd_get_extra_suppression_info,
644 drd_print_extra_suppression_use,
645 drd_update_extra_suppresion_use);
646 }
647