bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 1 | /* -*- mode: C; c-basic-offset: 3; -*- */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 2 | /* |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 3 | This file is part of drd, a thread error detector. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 4 | |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 5 | Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 6 | |
| 7 | This program is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 2 of the |
| 10 | License, or (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 20 | 02111-1307, USA. |
| 21 | |
| 22 | The GNU General Public License is contained in the file COPYING. |
| 23 | */ |
| 24 | |
| 25 | |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 26 | #include "drd_clientobj.h" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 27 | #include "drd_cond.h" |
| 28 | #include "drd_error.h" |
| 29 | #include "drd_mutex.h" |
| 30 | #include "drd_suppression.h" |
bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 31 | #include "pub_tool_errormgr.h" /* VG_(maybe_record_error)() */ |
| 32 | #include "pub_tool_libcassert.h" /* tl_assert() */ |
| 33 | #include "pub_tool_libcprint.h" /* VG_(printf)() */ |
| 34 | #include "pub_tool_machine.h" /* VG_(get_IP)() */ |
| 35 | #include "pub_tool_options.h" /* VG_(clo_backtrace_size) */ |
| 36 | #include "pub_tool_threadstate.h" /* VG_(get_running_tid)() */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 37 | |
| 38 | |
bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 39 | /* Local functions. */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 40 | |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 41 | static void DRD_(cond_cleanup)(struct cond_info* p); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 42 | |
| 43 | |
bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 44 | /* Local variables. */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 45 | |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 46 | static Bool DRD_(s_report_signal_unlocked) = True; |
| 47 | static Bool DRD_(s_trace_cond); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 48 | |
| 49 | |
bart | 46b5fce | 2008-06-28 13:01:30 +0000 | [diff] [blame] | 50 | /* Function definitions. */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 51 | |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 52 | void DRD_(cond_set_report_signal_unlocked)(const Bool r) |
bart | 764dea2 | 2009-02-15 13:16:52 +0000 | [diff] [blame] | 53 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 54 | DRD_(s_report_signal_unlocked) = r; |
bart | 764dea2 | 2009-02-15 13:16:52 +0000 | [diff] [blame] | 55 | } |
| 56 | |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 57 | void DRD_(cond_set_trace)(const Bool trace_cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 58 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 59 | DRD_(s_trace_cond) = trace_cond; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 63 | void DRD_(cond_initialize)(struct cond_info* const p, const Addr cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 64 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 65 | tl_assert(cond != 0); |
| 66 | tl_assert(p->a1 == cond); |
| 67 | tl_assert(p->type == ClientCondvar); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 68 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 69 | p->cleanup = (void(*)(DrdClientobj*))(DRD_(cond_cleanup)); |
| 70 | p->delete_thread = 0; |
| 71 | p->waiter_count = 0; |
| 72 | p->mutex = 0; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 73 | } |
| 74 | |
bart | 195e41f | 2009-02-15 11:34:57 +0000 | [diff] [blame] | 75 | /** |
| 76 | * Free the memory that was allocated by cond_initialize(). Called by |
| 77 | * DRD_(clientobj_remove)(). |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 78 | */ |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 79 | static void DRD_(cond_cleanup)(struct cond_info* p) |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 80 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 81 | tl_assert(p); |
| 82 | if (p->mutex) |
| 83 | { |
| 84 | struct mutex_info* q; |
| 85 | q = &(DRD_(clientobj_get)(p->mutex, ClientMutex)->mutex); |
| 86 | tl_assert(q); |
| 87 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 88 | CondDestrErrInfo cde = { DRD_(thread_get_running_tid)(), |
| 89 | p->a1, q->a1, q->owner }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 90 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 91 | CondDestrErr, |
| 92 | VG_(get_IP)(VG_(get_running_tid)()), |
| 93 | "Destroying condition variable that is being" |
| 94 | " waited upon", |
| 95 | &cde); |
| 96 | } |
| 97 | } |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 98 | } |
| 99 | |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 100 | static struct cond_info* cond_get_or_allocate(const Addr cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 101 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 102 | struct cond_info *p; |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 103 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 104 | tl_assert(offsetof(DrdClientobj, cond) == 0); |
| 105 | p = &(DRD_(clientobj_get)(cond, ClientCondvar)->cond); |
| 106 | if (p == 0) |
| 107 | { |
| 108 | p = &(DRD_(clientobj_add)(cond, ClientCondvar)->cond); |
| 109 | DRD_(cond_initialize)(p, cond); |
| 110 | } |
| 111 | return p; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 112 | } |
| 113 | |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 114 | struct cond_info* DRD_(cond_get)(const Addr cond) |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 115 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 116 | tl_assert(offsetof(DrdClientobj, cond) == 0); |
| 117 | return &(DRD_(clientobj_get)(cond, ClientCondvar)->cond); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /** Called before pthread_cond_init(). */ |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 121 | void DRD_(cond_pre_init)(const Addr cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 122 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 123 | struct cond_info* p; |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 124 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 125 | if (DRD_(s_trace_cond)) |
| 126 | { |
| 127 | VG_(message)(Vg_UserMsg, |
| 128 | "[%d/%d] cond_init cond 0x%lx", |
| 129 | VG_(get_running_tid)(), |
| 130 | DRD_(thread_get_running_tid)(), |
| 131 | cond); |
| 132 | } |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 133 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 134 | p = DRD_(cond_get)(cond); |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 135 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 136 | if (p) |
| 137 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 138 | CondErrInfo cei = { .tid = DRD_(thread_get_running_tid)(), .cond = cond }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 139 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 140 | CondErr, |
| 141 | VG_(get_IP)(VG_(get_running_tid)()), |
| 142 | "initialized twice", |
| 143 | &cei); |
| 144 | } |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 145 | |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 146 | p = cond_get_or_allocate(cond); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 147 | } |
| 148 | |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 149 | /** Called after pthread_cond_destroy(). */ |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 150 | void DRD_(cond_post_destroy)(const Addr cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 151 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 152 | struct cond_info* p; |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 153 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 154 | if (DRD_(s_trace_cond)) |
| 155 | { |
| 156 | VG_(message)(Vg_UserMsg, |
| 157 | "[%d/%d] cond_destroy cond 0x%lx", |
| 158 | VG_(get_running_tid)(), |
| 159 | DRD_(thread_get_running_tid)(), |
| 160 | cond); |
| 161 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 162 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 163 | p = DRD_(cond_get)(cond); |
| 164 | if (p == 0) |
| 165 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 166 | CondErrInfo cei = { .tid = DRD_(thread_get_running_tid)(), .cond = cond }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 167 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 168 | CondErr, |
| 169 | VG_(get_IP)(VG_(get_running_tid)()), |
| 170 | "not a condition variable", |
| 171 | &cei); |
| 172 | return; |
| 173 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 174 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 175 | if (p->waiter_count != 0) |
| 176 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 177 | CondErrInfo cei = { .tid = DRD_(thread_get_running_tid)(), .cond = cond }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 178 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 179 | CondErr, |
| 180 | VG_(get_IP)(VG_(get_running_tid)()), |
| 181 | "destruction of condition variable being waited" |
| 182 | " upon", |
| 183 | &cei); |
| 184 | } |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 185 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 186 | DRD_(clientobj_remove)(p->a1, ClientCondvar); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 187 | } |
| 188 | |
bart | 08e6d6a | 2008-06-28 16:28:49 +0000 | [diff] [blame] | 189 | /** Called before pthread_cond_wait(). Note: before this function is called, |
| 190 | * mutex_unlock() has already been called from drd_clientreq.c. |
| 191 | */ |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 192 | int DRD_(cond_pre_wait)(const Addr cond, const Addr mutex) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 193 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 194 | struct cond_info* p; |
| 195 | struct mutex_info* q; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 196 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 197 | if (DRD_(s_trace_cond)) |
| 198 | { |
| 199 | VG_(message)(Vg_UserMsg, |
| 200 | "[%d/%d] cond_pre_wait cond 0x%lx", |
| 201 | VG_(get_running_tid)(), |
| 202 | DRD_(thread_get_running_tid)(), |
| 203 | cond); |
| 204 | } |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 205 | |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 206 | p = cond_get_or_allocate(cond); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 207 | tl_assert(p); |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 208 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 209 | if (p->waiter_count == 0) |
| 210 | { |
| 211 | p->mutex = mutex; |
| 212 | } |
| 213 | else if (p->mutex != mutex) |
| 214 | { |
| 215 | CondWaitErrInfo cwei |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 216 | = { .tid = DRD_(thread_get_running_tid)(), |
| 217 | .cond = cond, .mutex1 = p->mutex, .mutex2 = mutex }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 218 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 219 | CondWaitErr, |
| 220 | VG_(get_IP)(VG_(get_running_tid)()), |
| 221 | "Inconsistent association of condition variable" |
| 222 | " and mutex", |
| 223 | &cwei); |
| 224 | } |
| 225 | tl_assert(p->mutex); |
| 226 | q = DRD_(mutex_get)(p->mutex); |
| 227 | if (q |
| 228 | && q->owner == DRD_(thread_get_running_tid)() && q->recursion_count > 0) |
| 229 | { |
| 230 | const ThreadId vg_tid = VG_(get_running_tid)(); |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 231 | MutexErrInfo MEI = { DRD_(thread_get_running_tid)(), |
| 232 | q->a1, q->recursion_count, q->owner }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 233 | VG_(maybe_record_error)(vg_tid, |
| 234 | MutexErr, |
| 235 | VG_(get_IP)(vg_tid), |
| 236 | "Mutex locked recursively", |
| 237 | &MEI); |
| 238 | } |
| 239 | else if (q == 0) |
| 240 | { |
| 241 | DRD_(not_a_mutex)(p->mutex); |
| 242 | } |
bart | 08e6d6a | 2008-06-28 16:28:49 +0000 | [diff] [blame] | 243 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 244 | return ++p->waiter_count; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 245 | } |
| 246 | |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 247 | /** Called after pthread_cond_wait(). */ |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 248 | int DRD_(cond_post_wait)(const Addr cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 249 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 250 | struct cond_info* p; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 251 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 252 | if (DRD_(s_trace_cond)) |
| 253 | { |
| 254 | VG_(message)(Vg_UserMsg, |
| 255 | "[%d/%d] cond_post_wait cond 0x%lx", |
| 256 | VG_(get_running_tid)(), |
| 257 | DRD_(thread_get_running_tid)(), |
| 258 | cond); |
| 259 | } |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 260 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 261 | p = DRD_(cond_get)(cond); |
| 262 | if (p) |
| 263 | { |
| 264 | if (p->waiter_count > 0) |
bart | a9c5508 | 2008-06-28 16:55:35 +0000 | [diff] [blame] | 265 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 266 | --p->waiter_count; |
| 267 | if (p->waiter_count == 0) |
| 268 | { |
| 269 | p->mutex = 0; |
| 270 | } |
bart | a9c5508 | 2008-06-28 16:55:35 +0000 | [diff] [blame] | 271 | } |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 272 | return p->waiter_count; |
| 273 | } |
| 274 | return 0; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 275 | } |
| 276 | |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 277 | static void DRD_(cond_signal)(Addr const cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 278 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 279 | const ThreadId vg_tid = VG_(get_running_tid)(); |
| 280 | const DrdThreadId drd_tid = DRD_(VgThreadIdToDrdThreadId)(vg_tid); |
| 281 | struct cond_info* const cond_p = DRD_(cond_get)(cond); |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 282 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 283 | if (cond_p && cond_p->waiter_count > 0) |
| 284 | { |
| 285 | if (DRD_(s_report_signal_unlocked) |
| 286 | && ! DRD_(mutex_is_locked_by)(cond_p->mutex, drd_tid)) |
| 287 | { |
| 288 | /* A signal is sent while the associated mutex has not been locked. */ |
| 289 | /* This can indicate but is not necessarily a race condition. */ |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame^] | 290 | CondRaceErrInfo cei = { .tid = DRD_(thread_get_running_tid)(), |
| 291 | .cond = cond, |
| 292 | .mutex = cond_p->mutex, |
| 293 | }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 294 | VG_(maybe_record_error)(vg_tid, |
| 295 | CondRaceErr, |
| 296 | VG_(get_IP)(vg_tid), |
| 297 | "CondErr", |
| 298 | &cei); |
| 299 | } |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | /* No other thread is waiting for the signal, hence the signal will be */ |
| 304 | /* lost. This is normal in a POSIX threads application. */ |
| 305 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 306 | } |
| 307 | |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 308 | /** Called before pthread_cond_signal(). */ |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 309 | void DRD_(cond_pre_signal)(Addr const cond) |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 310 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 311 | if (DRD_(s_trace_cond)) |
| 312 | { |
| 313 | VG_(message)(Vg_UserMsg, |
| 314 | "[%d/%d] cond_signal cond 0x%lx", |
| 315 | VG_(get_running_tid)(), |
| 316 | DRD_(thread_get_running_tid)(), |
| 317 | cond); |
| 318 | } |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 319 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 320 | DRD_(cond_signal)(cond); |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 321 | } |
| 322 | |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 323 | /** Called before pthread_cond_broadcast(). */ |
bart | dc1ef03 | 2009-02-15 14:18:02 +0000 | [diff] [blame] | 324 | void DRD_(cond_pre_broadcast)(Addr const cond) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 325 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 326 | if (DRD_(s_trace_cond)) |
| 327 | { |
| 328 | VG_(message)(Vg_UserMsg, |
| 329 | "[%d/%d] cond_broadcast cond 0x%lx", |
| 330 | VG_(get_running_tid)(), |
| 331 | DRD_(thread_get_running_tid)(), |
| 332 | cond); |
| 333 | } |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 334 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 335 | DRD_(cond_signal)(cond); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 336 | } |