p = DRD_(barrier_get_or_allocate)(barrier, barrier_type, count);
- if (s_trace_barrier)
- {
+ if (s_trace_barrier) {
if (reinitialization)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] barrier_reinit %s 0x%lx count %ld -> %ld\n",
- DRD_(thread_get_running_tid)(),
- barrier_get_typename(p),
- barrier,
- p->count,
- count);
- }
+ DRD_(trace_msg)("[%d] barrier_reinit %s 0x%lx count %ld -> %ld\n",
+ DRD_(thread_get_running_tid)(),
+ barrier_get_typename(p), barrier, p->count, count);
else
- {
- VG_(message)(Vg_UserMsg,
- "[%d] barrier_init %s 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- barrier_get_typename(p),
- barrier);
- }
+ DRD_(trace_msg)("[%d] barrier_init %s 0x%lx\n",
+ DRD_(thread_get_running_tid)(),
+ barrier_get_typename(p),
+ barrier);
}
if (reinitialization && p->count != count)
p = DRD_(barrier_get)(barrier);
if (s_trace_barrier)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] barrier_destroy %s 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- barrier_get_typename(p),
- barrier);
- }
+ DRD_(trace_msg)("[%d] barrier_destroy %s 0x%lx\n",
+ DRD_(thread_get_running_tid)(),
+ barrier_get_typename(p), barrier);
if (p == 0)
{
tl_assert(p);
if (s_trace_barrier)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] barrier_pre_wait %s 0x%lx iteration %ld\n",
- DRD_(thread_get_running_tid)(),
- barrier_get_typename(p),
- barrier,
- p->pre_iteration);
- }
+ DRD_(trace_msg)("[%d] barrier_pre_wait %s 0x%lx iteration %ld\n",
+ DRD_(thread_get_running_tid)(),
+ barrier_get_typename(p), barrier, p->pre_iteration);
/* Clean up nodes associated with finished threads. */
oset = p->oset[p->pre_iteration & 1];
p = DRD_(barrier_get)(barrier);
if (s_trace_barrier)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] barrier_post_wait %s 0x%lx iteration %ld%s\n",
- tid,
- p ? barrier_get_typename(p) : "(?)",
- barrier,
- p ? p->post_iteration : -1,
- serializing ? " (serializing)" : "");
- }
+ DRD_(trace_msg)("[%d] barrier_post_wait %s 0x%lx iteration %ld%s\n",
+ tid, p ? barrier_get_typename(p) : "(?)",
+ barrier, p ? p->post_iteration : -1,
+ serializing ? " (serializing)" : "");
/*
* If p == 0, this means that the barrier has been destroyed after
#include "drd_clientobj.h"
+#include "drd_error.h"
#include "drd_suppression.h"
#include "pub_tool_basics.h"
#include "pub_tool_libcassert.h"
tl_assert(VG_(OSetGen_Lookup)(s_clientobj_set, &a1) == 0);
if (s_trace_clientobj)
- {
- VG_(message)(Vg_UserMsg, "Adding client object 0x%lx of type %d\n", a1, t);
- }
+ DRD_(trace_msg)("Adding client object 0x%lx of type %d\n", a1, t);
p = VG_(OSetGen_AllocNode)(s_clientobj_set, sizeof(*p));
VG_(memset)(p, 0, sizeof(*p));
{
tl_assert(p);
- if (s_trace_clientobj)
- {
- VG_(message)(Vg_UserMsg, "Removing client object 0x%lx of type %d\n",
- p->any.a1, p->any.type);
+ if (s_trace_clientobj) {
+ DRD_(trace_msg)("Removing client object 0x%lx of type %d\n", p->any.a1,
+ p->any.type);
#if 0
VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(),
VG_(clo_backtrace_size));
struct cond_info* p;
if (DRD_(s_trace_cond))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] cond_init cond 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- cond);
- }
+ DRD_(trace_msg)("[%d] cond_init cond 0x%lx\n",
+ DRD_(thread_get_running_tid)(), cond);
p = DRD_(cond_get)(cond);
struct cond_info* p;
if (DRD_(s_trace_cond))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] cond_destroy cond 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- cond);
- }
+ DRD_(trace_msg)("[%d] cond_destroy cond 0x%lx\n",
+ DRD_(thread_get_running_tid)(), cond);
p = DRD_(cond_get)(cond);
if (p == 0)
struct mutex_info* q;
if (DRD_(s_trace_cond))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] cond_pre_wait cond 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- cond);
- }
+ DRD_(trace_msg)("[%d] cond_pre_wait cond 0x%lx\n",
+ DRD_(thread_get_running_tid)(), cond);
p = cond_get_or_allocate(cond);
if (!p)
struct cond_info* p;
if (DRD_(s_trace_cond))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] cond_post_wait cond 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- cond);
- }
+ DRD_(trace_msg)("[%d] cond_post_wait cond 0x%lx\n",
+ DRD_(thread_get_running_tid)(), cond);
p = DRD_(cond_get)(cond);
if (!p)
p = DRD_(cond_get)(cond);
if (DRD_(s_trace_cond))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] cond_signal cond 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- cond);
- }
+ DRD_(trace_msg)("[%d] cond_signal cond 0x%lx\n",
+ DRD_(thread_get_running_tid)(), cond);
tl_assert(DRD_(pthread_cond_initializer));
if (!p && VG_(memcmp)((void*)cond, (void*)DRD_(pthread_cond_initializer),
struct cond_info* p;
if (DRD_(s_trace_cond))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] cond_broadcast cond 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- cond);
- }
+ DRD_(trace_msg)("[%d] cond_broadcast cond 0x%lx\n",
+ DRD_(thread_get_running_tid)(), cond);
p = DRD_(cond_get)(cond);
tl_assert(DRD_(pthread_cond_initializer));
#include "pub_tool_libcprint.h" /* VG_(printf)() */
#include "pub_tool_machine.h"
#include "pub_tool_mallocfree.h" /* VG_(malloc), VG_(free) */
+#include "pub_tool_options.h" /* VG_(clo_xml) */
#include "pub_tool_threadstate.h" /* VG_(get_pthread_id)() */
#include "pub_tool_tooliface.h" /* VG_(needs_tool_errors)() */
s_show_conflicting_segments = scs;
}
+void DRD_(trace_msg)(const char* format, ...)
+{
+ va_list vargs;
+ va_start(vargs, format);
+ VG_(vmessage)(Vg_UserMsg, format, vargs);
+ va_end(vargs);
+}
+
/**
* Describe the client address a as good as possible, putting the result in ai.
*/
void DRD_(set_show_conflicting_segments)(const Bool scs);
void DRD_(register_error_handlers)(void);
+void DRD_(trace_msg)(const char* format, ...) PRINTF_CHECK(1, 2);
#endif /* __DRD_ERROR_H */
p = DRD_(hb_get_or_allocate)(hb);
if (DRD_(s_trace_hb))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] happens_before 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- hb);
- }
+ DRD_(trace_msg)("[%d] happens_before 0x%lx\n",
+ DRD_(thread_get_running_tid)(), hb);
if (!p)
return;
p = DRD_(hb_get_or_allocate)(hb);
if (DRD_(s_trace_hb))
- {
- VG_(message)(Vg_UserMsg, "[%d] happens_after 0x%lx\n",
- DRD_(thread_get_running_tid)(), hb);
- }
+ DRD_(trace_msg)("[%d] happens_after 0x%lx\n",
+ DRD_(thread_get_running_tid)(), hb);
if (!p)
return;
struct hb_info* p;
if (DRD_(s_trace_hb))
- {
- VG_(message)(Vg_UserMsg, "[%d] happens_done 0x%lx\n",
- DRD_(thread_get_running_tid)(), hb);
- }
+ DRD_(trace_msg)("[%d] happens_done 0x%lx\n",
+ DRD_(thread_get_running_tid)(), hb);
p = DRD_(hb_get)(hb);
if (!p)
char* vc;
vc = DRD_(vc_aprint)(DRD_(thread_get_vc)(DRD_(thread_get_running_tid)()));
- VG_(message)(Vg_UserMsg,
- "%s 0x%lx size %ld (thread %d / vc %s)\n",
- access_type == eLoad
- ? "load "
- : access_type == eStore
- ? "store"
- : access_type == eStart
- ? "start"
- : access_type == eEnd
- ? "end "
- : "????",
- addr,
- size,
- DRD_(thread_get_running_tid)(),
- vc);
+ DRD_(trace_msg)("%s 0x%lx size %ld (thread %d / vc %s)\n",
+ access_type == eLoad ? "load "
+ : access_type == eStore ? "store"
+ : access_type == eStart ? "start"
+ : access_type == eEnd ? "end " : "????",
+ addr, size, DRD_(thread_get_running_tid)(), vc);
VG_(free)(vc);
VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(),
VG_(clo_backtrace_size));
tl_assert(a1 <= a2);
if (!is_stack_mem && s_trace_alloc)
- VG_(message)(Vg_UserMsg, "Started using memory range 0x%lx + %ld%s\n",
- a1, len, DRD_(running_thread_inside_pthread_create)()
- ? " (inside pthread_create())" : "");
+ DRD_(trace_msg)("Started using memory range 0x%lx + %ld%s\n",
+ a1, len, DRD_(running_thread_inside_pthread_create)()
+ ? " (inside pthread_create())" : "");
if (!is_stack_mem && DRD_(g_free_is_write))
DRD_(thread_stop_using_mem)(a1, a2);
DRD_(trace_mem_access)(a1, len, eEnd);
if (!is_stack_mem && s_trace_alloc)
- VG_(message)(Vg_UserMsg, "Stopped using memory range 0x%lx + %ld\n",
- a1, len);
+ DRD_(trace_msg)("Stopped using memory range 0x%lx + %ld\n",
+ a1, len);
if (!is_stack_mem || DRD_(get_check_stack_accesses)())
{
tl_assert(p);
if (s_trace_mutex)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] mutex_destroy %s 0x%lx rc %d owner %d\n",
- DRD_(thread_get_running_tid)(),
- DRD_(mutex_get_typename)(p),
- p->a1,
- p ? p->recursion_count : -1,
- p ? p->owner : DRD_INVALID_THREADID);
- }
+ DRD_(trace_msg)("[%d] mutex_destroy %s 0x%lx rc %d owner %d\n",
+ DRD_(thread_get_running_tid)(),
+ DRD_(mutex_get_typename)(p), p->a1,
+ p ? p->recursion_count : -1,
+ p ? p->owner : DRD_INVALID_THREADID);
if (mutex_is_locked(p))
{
struct mutex_info* p;
if (s_trace_mutex)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] mutex_init %s 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- DRD_(mutex_type_name)(mutex_type),
- mutex);
- }
+ DRD_(trace_msg)("[%d] mutex_init %s 0x%lx\n",
+ DRD_(thread_get_running_tid)(),
+ DRD_(mutex_type_name)(mutex_type),
+ mutex);
if (mutex_type == mutex_type_invalid_mutex)
{
mutex_type = p->mutex_type;
if (s_trace_mutex)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] %s %s 0x%lx rc %d owner %d\n",
- DRD_(thread_get_running_tid)(),
- trylock ? "pre_mutex_lock " : "mutex_trylock ",
- p ? DRD_(mutex_get_typename)(p) : "(?)",
- mutex,
- p ? p->recursion_count : -1,
- p ? p->owner : DRD_INVALID_THREADID);
- }
+ DRD_(trace_msg)("[%d] %s %s 0x%lx rc %d owner %d\n",
+ DRD_(thread_get_running_tid)(),
+ trylock ? "pre_mutex_lock " : "mutex_trylock ",
+ p ? DRD_(mutex_get_typename)(p) : "(?)",
+ mutex, p ? p->recursion_count : -1,
+ p ? p->owner : DRD_INVALID_THREADID);
if (p == 0)
{
p = DRD_(mutex_get)(mutex);
if (s_trace_mutex)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] %s %s 0x%lx rc %d owner %d%s\n",
- drd_tid,
- post_cond_wait ? "cond_post_wait " : "post_mutex_lock",
- p ? DRD_(mutex_get_typename)(p) : "(?)",
- mutex,
- p ? p->recursion_count : 0,
- p ? p->owner : VG_INVALID_THREADID,
- took_lock ? "" : " (locking failed)");
- }
+ DRD_(trace_msg)("[%d] %s %s 0x%lx rc %d owner %d%s\n",
+ drd_tid,
+ post_cond_wait ? "cond_post_wait " : "post_mutex_lock",
+ p ? DRD_(mutex_get_typename)(p) : "(?)",
+ mutex, p ? p->recursion_count : 0,
+ p ? p->owner : VG_INVALID_THREADID,
+ took_lock ? "" : " (locking failed)");
if (! p || ! took_lock)
return;
if (p && mutex_type == mutex_type_unknown)
mutex_type = p->mutex_type;
- if (s_trace_mutex)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] mutex_unlock %s 0x%lx rc %d\n",
- drd_tid,
- p ? DRD_(mutex_get_typename)(p) : "(?)",
- mutex,
- p ? p->recursion_count : 0);
+ if (s_trace_mutex) {
+ DRD_(trace_msg)("[%d] mutex_unlock %s 0x%lx rc %d\n",
+ drd_tid, p ? DRD_(mutex_get_typename)(p) : "(?)",
+ mutex, p ? p->recursion_count : 0);
}
if (p == 0 || mutex_type == mutex_type_invalid_mutex)
tl_assert(p);
if (DRD_(s_trace_rwlock))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] rwlock_destroy 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- p->a1);
- }
+ DRD_(trace_msg)("[%d] rwlock_destroy 0x%lx\n",
+ DRD_(thread_get_running_tid)(), p->a1);
if (DRD_(rwlock_is_locked)(p))
{
struct rwlock_info* p;
if (DRD_(s_trace_rwlock))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] rwlock_init 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- rwlock);
- }
+ DRD_(trace_msg)("[%d] rwlock_init 0x%lx\n",
+ DRD_(thread_get_running_tid)(), rwlock);
p = DRD_(rwlock_get)(rwlock);
struct rwlock_info* p;
if (DRD_(s_trace_rwlock))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] pre_rwlock_rdlock 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- rwlock);
- }
+ DRD_(trace_msg)("[%d] pre_rwlock_rdlock 0x%lx\n",
+ DRD_(thread_get_running_tid)(), rwlock);
p = DRD_(rwlock_get_or_allocate)(rwlock, rwlock_type);
tl_assert(p);
struct rwlock_thread_info* q;
if (DRD_(s_trace_rwlock))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] post_rwlock_rdlock 0x%lx\n",
- drd_tid,
- rwlock);
- }
+ DRD_(trace_msg)("[%d] post_rwlock_rdlock 0x%lx\n", drd_tid, rwlock);
p = DRD_(rwlock_get)(rwlock);
p = DRD_(rwlock_get)(rwlock);
if (DRD_(s_trace_rwlock))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] pre_rwlock_wrlock 0x%lx\n",
- DRD_(thread_get_running_tid)(),
- rwlock);
- }
+ DRD_(trace_msg)("[%d] pre_rwlock_wrlock 0x%lx\n",
+ DRD_(thread_get_running_tid)(), rwlock);
if (p == 0)
p = DRD_(rwlock_get_or_allocate)(rwlock, rwlock_type);
p = DRD_(rwlock_get)(rwlock);
if (DRD_(s_trace_rwlock))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] post_rwlock_wrlock 0x%lx\n",
- drd_tid,
- rwlock);
- }
+ DRD_(trace_msg)("[%d] post_rwlock_wrlock 0x%lx\n", drd_tid, rwlock);
if (! p || ! took_lock)
return;
struct rwlock_thread_info* q;
if (DRD_(s_trace_rwlock))
- {
- VG_(message)(Vg_UserMsg,
- "[%d] rwlock_unlock 0x%lx\n",
- drd_tid,
- rwlock);
- }
+ DRD_(trace_msg)("[%d] rwlock_unlock 0x%lx\n", drd_tid, rwlock);
p = DRD_(rwlock_get)(rwlock);
if (p == 0)
Segment* sg;
if (s_trace_semaphore)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] sem_init 0x%lx value %u\n",
- DRD_(thread_get_running_tid)(),
- semaphore,
- value);
- }
+ DRD_(trace_msg)("[%d] sem_init 0x%lx value %u\n",
+ DRD_(thread_get_running_tid)(), semaphore, value);
+
p = semaphore_get(semaphore);
if (p)
{
p = semaphore_get(semaphore);
if (s_trace_semaphore)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] sem_destroy 0x%lx value %u\n",
- DRD_(thread_get_running_tid)(),
- semaphore,
- p ? p->value : 0);
- }
+ DRD_(trace_msg)("[%d] sem_destroy 0x%lx value %u\n",
+ DRD_(thread_get_running_tid)(), semaphore,
+ p ? p->value : 0);
if (p == 0)
{
Segment* sg;
if (s_trace_semaphore)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] sem_open 0x%lx name %s"
- " oflag %#lx mode %#lo value %u\n",
- DRD_(thread_get_running_tid)(),
- semaphore, name, oflag, mode, value);
- }
+ DRD_(trace_msg)("[%d] sem_open 0x%lx name %s"
+ " oflag %#lx mode %#lo value %u\n",
+ DRD_(thread_get_running_tid)(),
+ semaphore, name, oflag, mode, value);
/* Return if the sem_open() call failed. */
if (! semaphore)
p = semaphore_get(semaphore);
if (s_trace_semaphore)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] sem_close 0x%lx value %u\n",
- DRD_(thread_get_running_tid)(),
- semaphore,
- p ? p->value : 0);
- }
+ DRD_(trace_msg)("[%d] sem_close 0x%lx value %u\n",
+ DRD_(thread_get_running_tid)(), semaphore,
+ p ? p->value : 0);
if (p == 0)
{
p = semaphore_get(semaphore);
if (s_trace_semaphore)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] sem_wait 0x%lx value %u -> %u\n",
- DRD_(thread_get_running_tid)(),
- semaphore,
- p ? p->value : 0,
- p ? p->value - 1 : 0);
- }
+ DRD_(trace_msg)("[%d] sem_wait 0x%lx value %u -> %u\n",
+ DRD_(thread_get_running_tid)(), semaphore,
+ p ? p->value : 0, p ? p->value - 1 : 0);
if (p)
{
p->value++;
if (s_trace_semaphore)
- {
- VG_(message)(Vg_UserMsg,
- "[%d] sem_post 0x%lx value %u -> %u\n",
- DRD_(thread_get_running_tid)(),
- semaphore,
- p->value - 1, p->value);
- }
+ DRD_(trace_msg)("[%d] sem_post 0x%lx value %u -> %u\n",
+ DRD_(thread_get_running_tid)(),
+ semaphore, p->value - 1, p->value);
p->last_sem_post_tid = tid;
sg = 0;
", new vc: %s", vc);
VG_(free)(vc);
}
- VG_(message)(Vg_DebugMsg, "%s\n", msg);
+ DRD_(trace_msg)("%s\n", msg);
VG_(free)(msg);
}
tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID);
if (DRD_(thread_get_trace_fork_join)())
- VG_(message)(Vg_UserMsg, "[%d] drd_thread_pre_cancel %d\n",
- DRD_(g_drd_running_tid), tid);
+ DRD_(trace_msg)("[%d] drd_thread_pre_cancel %d\n",
+ DRD_(g_drd_running_tid), tid);
}
/**