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