VG_(free));
}
-/** Deallocate the memory allocated by barrier_initialize() and in p->oset.
- * Called by clientobj_destroy().
+/**
+ * Deallocate the memory allocated by barrier_initialize() and in p->oset.
+ * Called by clientobj_destroy().
*/
void DRD_(barrier_cleanup)(struct barrier_info* p)
{
tl_assert(barrier_type == pthread_barrier || barrier_type == gomp_barrier);
tl_assert(offsetof(DrdClientobj, barrier) == 0);
- p = &(clientobj_get(barrier, ClientBarrier)->barrier);
+ p = &(DRD_(clientobj_get)(barrier, ClientBarrier)->barrier);
if (p == 0)
{
- p = &(clientobj_add(barrier, ClientBarrier)->barrier);
+ p = &(DRD_(clientobj_add)(barrier, ClientBarrier)->barrier);
DRD_(barrier_initialize)(p, barrier, barrier_type, count);
}
return p;
static struct barrier_info* DRD_(barrier_get)(const Addr barrier)
{
tl_assert(offsetof(DrdClientobj, barrier) == 0);
- return &(clientobj_get(barrier, ClientBarrier)->barrier);
+ return &(DRD_(clientobj_get)(barrier, ClientBarrier)->barrier);
}
/** Initialize a barrier with client address barrier, client size size, and
&bei);
}
- clientobj_remove(p->a1, ClientBarrier);
+ DRD_(clientobj_remove)(p->a1, ClientBarrier);
}
/** Called before pthread_barrier_wait(). */
{
struct barrier_info* p;
- clientobj_resetiter();
- for ( ; (p = &clientobj_next(ClientBarrier)->barrier) != 0; )
+ DRD_(clientobj_resetiter)();
+ for ( ; (p = &(DRD_(clientobj_next)(ClientBarrier)->barrier)) != 0; )
{
struct barrier_thread_info* q;
const UWord word_tid = tid;
#include "pub_tool_threadstate.h" // VG_(get_running_tid)()
-// Local variables.
+/* Local variables. */
static OSet* s_clientobj;
static Bool s_trace_clientobj;
-// Function definitions.
+/* Function definitions. */
-void clientobj_set_trace(const Bool trace)
+void DRD_(clientobj_set_trace)(const Bool trace)
{
s_trace_clientobj = trace;
}
/** Initialize the client object set. */
-void clientobj_init(void)
+void DRD_(clientobj_init)(void)
{
tl_assert(s_clientobj == 0);
s_clientobj = VG_(OSetGen_Create)(0, 0, VG_(malloc), "drd.clientobj.ci.1",
tl_assert(s_clientobj);
}
-/** Free the memory allocated for the client object set.
- * @pre Client object set is empty.
+/**
+ * Free the memory allocated for the client object set.
+ *
+ * @pre Client object set is empty.
*/
-void clientobj_cleanup(void)
+void DRD_(clientobj_cleanup)(void)
{
tl_assert(s_clientobj);
tl_assert(VG_(OSetGen_Size)(s_clientobj) == 0);
* Return 0 if there is no client object in the set with the specified start
* address.
*/
-DrdClientobj* clientobj_get_any(const Addr addr)
+DrdClientobj* DRD_(clientobj_get_any)(const Addr addr)
{
return VG_(OSetGen_Lookup)(s_clientobj, &addr);
}
* and that has object type t. Return 0 if there is no client object in the
* set with the specified start address.
*/
-DrdClientobj* clientobj_get(const Addr addr, const ObjType t)
+DrdClientobj* DRD_(clientobj_get)(const Addr addr, const ObjType t)
{
DrdClientobj* p;
p = VG_(OSetGen_Lookup)(s_clientobj, &addr);
/** Return true if and only if the address range of any client object overlaps
* with the specified address range.
*/
-Bool clientobj_present(const Addr a1, const Addr a2)
+Bool DRD_(clientobj_present)(const Addr a1, const Addr a2)
{
DrdClientobj *p;
* of type t. Suppress data race reports on the address range [addr,addr+size[.
* @pre No other client object is present in the address range [addr,addr+size[.
*/
-DrdClientobj*
-clientobj_add(const Addr a1, const ObjType t)
+DrdClientobj* DRD_(clientobj_add)(const Addr a1, const ObjType t)
{
DrdClientobj* p;
- tl_assert(! clientobj_present(a1, a1 + 1));
+ tl_assert(! DRD_(clientobj_present)(a1, a1 + 1));
tl_assert(VG_(OSetGen_Lookup)(s_clientobj, &a1) == 0);
if (s_trace_clientobj)
return p;
}
-Bool clientobj_remove(const Addr addr, const ObjType t)
+Bool DRD_(clientobj_remove)(const Addr addr, const ObjType t)
{
DrdClientobj* p;
return False;
}
-void clientobj_stop_using_mem(const Addr a1, const Addr a2)
+void DRD_(clientobj_stop_using_mem)(const Addr a1, const Addr a2)
{
Addr removed_at;
DrdClientobj* p;
if (a1 <= p->any.a1 && p->any.a1 < a2)
{
removed_at = p->any.a1;
- clientobj_remove(p->any.a1, p->any.type);
+ DRD_(clientobj_remove)(p->any.a1, p->any.type);
/* The above call removes an element from the oset and hence */
/* invalidates the iterator. Set the iterator back. */
VG_(OSetGen_ResetIter)(s_clientobj);
}
}
-void clientobj_resetiter(void)
+void DRD_(clientobj_resetiter)(void)
{
VG_(OSetGen_ResetIter)(s_clientobj);
}
-DrdClientobj* clientobj_next(const ObjType t)
+DrdClientobj* DRD_(clientobj_next)(const ObjType t)
{
DrdClientobj* p;
while ((p = VG_(OSetGen_Next)(s_clientobj)) != 0 && p->any.type != t)
return p;
}
-const char* clientobj_type_name(const ObjType t)
+const char* DRD_(clientobj_type_name)(const ObjType t)
{
switch (t)
{
#define __DRD_CLIENTOBJ_H
+#include "drd_basics.h" /* DrdThreadId */
#include "drd_clientreq.h" /* MutexT */
-#include "drd_thread.h" /* DrdThreadId */
#include "pub_tool_basics.h"
#include "pub_tool_execontext.h" /* ExeContext */
#include "pub_tool_oset.h"
#include "pub_tool_xarray.h"
-// Forward declarations.
+/* Forward declarations. */
union drd_clientobj;
-// Type definitions.
+/* Type definitions. */
typedef enum {
ClientMutex = 1,
struct mutex_info
{
- Addr a1;
- ObjType type;
- void (*cleanup)(union drd_clientobj*);
- ExeContext* first_observed_at;
- MutexT mutex_type; // pthread_mutex_t or pthread_spinlock_t.
- int recursion_count; // 0 if free, >= 1 if locked.
- DrdThreadId owner; // owner if locked, last owner if free.
- Segment* last_locked_segment;
- ULong acquiry_time_ms;
- ExeContext* acquired_at;
+ Addr a1;
+ ObjType type;
+ void (*cleanup)(union drd_clientobj*);
+ ExeContext* first_observed_at;
+ MutexT mutex_type; // pthread_mutex_t or pthread_spinlock_t.
+ int recursion_count; // 0 if free, >= 1 if locked.
+ DrdThreadId owner; // owner if locked, last owner if free.
+ struct segment* last_locked_segment;
+ ULong acquiry_time_ms;
+ ExeContext* acquired_at;
};
struct cond_info
} DrdClientobj;
-// Function declarations.
-
-void clientobj_set_trace(const Bool trace);
-void clientobj_init(void);
-void clientobj_cleanup(void);
-DrdClientobj* clientobj_get_any(const Addr addr);
-DrdClientobj* clientobj_get(const Addr addr, const ObjType t);
-Bool clientobj_present(const Addr a1, const Addr a2);
-DrdClientobj* clientobj_add(const Addr a1, const ObjType t);
-Bool clientobj_remove(const Addr addr, const ObjType t);
-void clientobj_stop_using_mem(const Addr a1, const Addr a2);
-void clientobj_resetiter(void);
-DrdClientobj* clientobj_next(const ObjType t);
-const char* clientobj_type_name(const ObjType t);
+/* Function declarations. */
+
+void DRD_(clientobj_set_trace)(const Bool trace);
+void DRD_(clientobj_init)(void);
+void DRD_(clientobj_cleanup)(void);
+DrdClientobj* DRD_(clientobj_get_any)(const Addr addr);
+DrdClientobj* DRD_(clientobj_get)(const Addr addr, const ObjType t);
+Bool DRD_(clientobj_present)(const Addr a1, const Addr a2);
+DrdClientobj* DRD_(clientobj_add)(const Addr a1, const ObjType t);
+Bool DRD_(clientobj_remove)(const Addr addr, const ObjType t);
+void DRD_(clientobj_stop_using_mem)(const Addr a1, const Addr a2);
+void DRD_(clientobj_resetiter)(void);
+DrdClientobj* DRD_(clientobj_next)(const ObjType t);
+const char* DRD_(clientobj_type_name)(const ObjType t);
#endif /* __DRD_CLIENTOBJ_H */
p->mutex = 0;
}
-/** Free the memory that was allocated by cond_initialize(). Called by
- * clientobj_remove().
+/**
+ * Free the memory that was allocated by cond_initialize(). Called by
+ * DRD_(clientobj_remove)().
*/
static void cond_cleanup(struct cond_info* p)
{
if (p->mutex)
{
struct mutex_info* q;
- q = &clientobj_get(p->mutex, ClientMutex)->mutex;
+ q = &(DRD_(clientobj_get)(p->mutex, ClientMutex)->mutex);
tl_assert(q);
{
CondDestrErrInfo cde = { p->a1, q->a1, q->owner };
struct cond_info *p;
tl_assert(offsetof(DrdClientobj, cond) == 0);
- p = &clientobj_get(cond, ClientCondvar)->cond;
+ p = &(DRD_(clientobj_get)(cond, ClientCondvar)->cond);
if (p == 0)
{
- p = &clientobj_add(cond, ClientCondvar)->cond;
+ p = &(DRD_(clientobj_add)(cond, ClientCondvar)->cond);
cond_initialize(p, cond);
}
return p;
static struct cond_info* cond_get(const Addr cond)
{
tl_assert(offsetof(DrdClientobj, cond) == 0);
- return &clientobj_get(cond, ClientCondvar)->cond;
+ return &(DRD_(clientobj_get)(cond, ClientCondvar)->cond);
}
/** Called before pthread_cond_init(). */
&cei);
}
- clientobj_remove(p->a1, ClientCondvar);
+ DRD_(clientobj_remove)(p->a1, ClientCondvar);
}
/** Called before pthread_cond_wait(). Note: before this function is called,
{
DrdClientobj* cl;
- cl = clientobj_get_any(obj);
+ cl = DRD_(clientobj_get_any)(obj);
if (cl)
{
tl_assert(cl->any.first_observed_at);
VG_(message)(Vg_UserMsg,
"%s 0x%lx was first observed at:",
- clientobj_type_name(cl->any.type),
+ DRD_(clientobj_type_name)(cl->any.type),
obj);
VG_(pp_ExeContext)(cl->any.first_observed_at);
}
if (trace_barrier != -1)
DRD_(barrier_set_trace)(trace_barrier);
if (trace_clientobj != -1)
- clientobj_set_trace(trace_clientobj);
+ DRD_(clientobj_set_trace)(trace_clientobj);
if (trace_cond != -1)
cond_set_trace(trace_cond);
if (trace_csw != -1)
if (! is_stack_mem || DRD_(get_check_stack_accesses)())
{
thread_stop_using_mem(a1, a2);
- clientobj_stop_using_mem(a1, a2);
+ DRD_(clientobj_stop_using_mem)(a1, a2);
DRD_(suppression_stop_using_mem)(a1, a2);
}
}
DRD_(suppression_init)();
- clientobj_init();
+ DRD_(clientobj_init)();
}
struct mutex_info* p;
tl_assert(offsetof(DrdClientobj, mutex) == 0);
- p = &clientobj_get(mutex, ClientMutex)->mutex;
+ p = &(DRD_(clientobj_get)(mutex, ClientMutex)->mutex);
if (p)
{
return p;
}
- if (clientobj_present(mutex, mutex + 1))
+ if (DRD_(clientobj_present)(mutex, mutex + 1))
{
not_a_mutex(mutex);
return 0;
tl_assert(mutex_type != mutex_type_unknown);
- p = &clientobj_add(mutex, ClientMutex)->mutex;
+ p = &(DRD_(clientobj_add)(mutex, ClientMutex)->mutex);
mutex_initialize(p, mutex, mutex_type);
return p;
}
struct mutex_info* mutex_get(const Addr mutex)
{
tl_assert(offsetof(DrdClientobj, mutex) == 0);
- return &clientobj_get(mutex, ClientMutex)->mutex;
+ return &(DRD_(clientobj_get)(mutex, ClientMutex)->mutex);
}
/** Called before pthread_mutex_init(). */
return;
}
- clientobj_remove(mutex, ClientMutex);
+ DRD_(clientobj_remove)(mutex, ClientMutex);
}
/** Called before pthread_mutex_lock() is invoked. If a data structure for
{
struct mutex_info* p;
- clientobj_resetiter();
- for ( ; (p = &clientobj_next(ClientMutex)->mutex) != 0; )
+ DRD_(clientobj_resetiter)();
+ for ( ; (p = &(DRD_(clientobj_next)(ClientMutex)->mutex)) != 0; )
{
if (p->owner == tid && p->recursion_count > 0)
{
struct rwlock_info* p;
tl_assert(offsetof(DrdClientobj, rwlock) == 0);
- p = &clientobj_get(rwlock, ClientRwlock)->rwlock;
+ p = &(DRD_(clientobj_get)(rwlock, ClientRwlock)->rwlock);
if (p)
{
return p;
}
- if (clientobj_present(rwlock, rwlock + 1))
+ if (DRD_(clientobj_present)(rwlock, rwlock + 1))
{
GenericErrInfo GEI;
VG_(maybe_record_error)(VG_(get_running_tid)(),
return 0;
}
- p = &clientobj_add(rwlock, ClientRwlock)->rwlock;
+ p = &(DRD_(clientobj_add)(rwlock, ClientRwlock)->rwlock);
rwlock_initialize(p, rwlock);
return p;
}
static struct rwlock_info* rwlock_get(const Addr rwlock)
{
tl_assert(offsetof(DrdClientobj, rwlock) == 0);
- return &clientobj_get(rwlock, ClientRwlock)->rwlock;
+ return &(DRD_(clientobj_get)(rwlock, ClientRwlock)->rwlock);
}
/** Called before pthread_rwlock_init(). */
return;
}
- clientobj_remove(rwlock, ClientRwlock);
+ DRD_(clientobj_remove)(rwlock, ClientRwlock);
}
/** Called before pthread_rwlock_rdlock() is invoked. If a data structure for
{
struct rwlock_info* p;
- clientobj_resetiter();
- for ( ; (p = &clientobj_next(ClientRwlock)->rwlock) != 0; )
+ DRD_(clientobj_resetiter)();
+ for ( ; (p = &(DRD_(clientobj_next)(ClientRwlock)->rwlock)) != 0; )
{
struct rwlock_thread_info* q;
if (rwlock_is_locked_by(p, tid))
VG_(free), sizeof(Segment*));
}
-/** Free the memory that was allocated by semaphore_initialize(). Called by
- * clientobj_remove().
+/**
+ * Free the memory that was allocated by semaphore_initialize(). Called by
+ * DRD_(clientobj_remove)().
*/
static void semaphore_cleanup(struct semaphore_info* p)
{
struct semaphore_info *p;
tl_assert(offsetof(DrdClientobj, semaphore) == 0);
- p = &clientobj_get(semaphore, ClientSemaphore)->semaphore;
+ p = &(DRD_(clientobj_get)(semaphore, ClientSemaphore)->semaphore);
if (p == 0)
{
tl_assert(offsetof(DrdClientobj, semaphore) == 0);
- p = &clientobj_add(semaphore, ClientSemaphore)->semaphore;
+ p = &(DRD_(clientobj_add)(semaphore, ClientSemaphore)->semaphore);
semaphore_initialize(p, semaphore);
}
return p;
static struct semaphore_info* semaphore_get(const Addr semaphore)
{
tl_assert(offsetof(DrdClientobj, semaphore) == 0);
- return &clientobj_get(semaphore, ClientSemaphore)->semaphore;
+ return &(DRD_(clientobj_get)(semaphore, ClientSemaphore)->semaphore);
}
/** Called before sem_init(). */
return;
}
- clientobj_remove(semaphore, ClientSemaphore);
+ DRD_(clientobj_remove)(semaphore, ClientSemaphore);
}
/** Called before sem_wait(). */