本文整理汇总了C++中DRD_函数的典型用法代码示例。如果您正苦于以下问题:C++ DRD_函数的具体用法?C++ DRD_怎么用?C++ DRD_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DRD_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mutex_delete_thread
/**
* Call this function when thread tid stops to exist, such that the
* "last owner" field can be cleared if it still refers to that thread.
*/
static void mutex_delete_thread(struct mutex_info* p, const DrdThreadId tid)
{
tl_assert(p);
if (p->owner == tid && p->recursion_count > 0)
{
MutexErrInfo MEI = { DRD_(thread_get_running_tid)(),
p->a1, p->recursion_count, p->owner };
VG_(maybe_record_error)(VG_(get_running_tid)(),
MutexErr,
VG_(get_IP)(VG_(get_running_tid)()),
"Mutex still locked at thread exit",
&MEI);
p->owner = VG_INVALID_THREADID;
}
}
示例2: DRD_
/**
* Initialize the memory 'vc' points at as a vector clock with size 'size'.
* If the pointer 'vcelem' is not null, it is assumed to be an array with
* 'size' elements and it becomes the initial value of the vector clock.
*/
void DRD_(vc_init)(VectorClock* const vc,
const VCElem* const vcelem,
const unsigned size)
{
tl_assert(vc);
vc->size = 0;
vc->capacity = 0;
vc->vc = 0;
DRD_(vc_reserve)(vc, size);
tl_assert(size == 0 || vc->vc != 0);
if (vcelem)
{
VG_(memcpy)(vc->vc, vcelem, size * sizeof(vcelem[0]));
vc->size = size;
}
}
示例3: DRD_
/** Called before pthread_mutex_lock() is invoked. If a data structure for
* the client-side object was not yet created, do this now. Also check whether
* an attempt is made to lock recursively a synchronization object that must
* not be locked recursively.
*/
void DRD_(mutex_pre_lock)(const Addr mutex, MutexT mutex_type,
const Bool trylock)
{
struct mutex_info* p;
p = DRD_(mutex_get_or_allocate)(mutex, mutex_type);
if (mutex_type == mutex_type_unknown)
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);
}
if (p == 0)
{
DRD_(not_a_mutex)(mutex);
return;
}
tl_assert(p);
if (mutex_type == mutex_type_invalid_mutex)
{
DRD_(not_a_mutex)(mutex);
return;
}
if (! trylock
&& p->owner == DRD_(thread_get_running_tid)()
&& p->recursion_count >= 1
&& mutex_type != mutex_type_recursive_mutex)
{
MutexErrInfo MEI = { DRD_(thread_get_running_tid)(),
p->a1, p->recursion_count, p->owner };
VG_(maybe_record_error)(VG_(get_running_tid)(),
MutexErr,
VG_(get_IP)(VG_(get_running_tid)()),
"Recursive locking not allowed",
&MEI);
}
}
示例4: DRD_
void DRD_(stop_tracing_address_range)(const Addr a1, const Addr a2)
{
tl_assert(a1 < a2);
DRD_(bm_clear_load)(DRD_(s_suppressed), a1, a2);
if (DRD_(g_any_address_traced))
{
DRD_(g_any_address_traced)
= DRD_(bm_has_any_load)(DRD_(s_suppressed), 0, ~(Addr)0);
}
}
示例5: drd_start_using_mem
static __inline__
void drd_start_using_mem(const Addr a1, const SizeT len,
const Bool is_stack_mem)
{
const Addr a2 = a1 + len;
tl_assert(a1 <= a2);
if (!is_stack_mem && s_trace_alloc)
DRD_(trace_msg)("Started using memory range 0x%lx + %ld%s",
a1, len, DRD_(running_thread_inside_pthread_create)()
? " (inside pthread_create())" : "");
#if 0
if (!is_stack_mem && DRD_(g_free_is_write))
DRD_(thread_stop_using_mem)(a1, a2);
#else
/*
* Sometimes it happens that a client starts using a memory range that has
* been accessed before but for which drd_stop_using_mem() has not been
* called for the entire range. It is not yet clear whether this is an
* out-of-range access by the client, an issue in the Valgrind core or an
* issue in DRD. Avoid that this issue triggers false positive reports by
* always clearing accesses for newly allocated memory ranges. See also
* http://bugs.kde.org/show_bug.cgi?id=297147.
*/
DRD_(thread_stop_using_mem)(a1, a2);
#endif
if (UNLIKELY(DRD_(any_address_is_traced)()))
{
DRD_(trace_mem_access)(a1, len, eStart, 0, 0);
}
if (UNLIKELY(DRD_(running_thread_inside_pthread_create)()))
{
DRD_(start_suppression)(a1, a2, "pthread_create()");
}
}
示例6: DRD_
/**
* Called after sem_wait() finished.
* @note Do not rely on the value of 'waited' -- some glibc versions do
* not set it correctly.
*/
void DRD_(semaphore_post_wait)(const DrdThreadId tid, const Addr semaphore,
const Bool waited)
{
struct semaphore_info* p;
Segment* sg;
p = DRD_(semaphore_get)(semaphore);
if (s_trace_semaphore)
{
VG_(message)(Vg_UserMsg,
"[%d/%d] semaphore_wait 0x%lx value %u -> %u",
VG_(get_running_tid)(),
DRD_(thread_get_running_tid)(),
semaphore,
p ? p->value : 0,
p ? p->value - 1 : 0);
}
tl_assert(p);
tl_assert(p->waiters > 0);
p->waiters--;
tl_assert((int)p->waiters >= 0);
tl_assert((int)p->value >= 0);
if (p->value == 0)
{
SemaphoreErrInfo sei = { semaphore };
VG_(maybe_record_error)(VG_(get_running_tid)(),
SemaphoreErr,
VG_(get_IP)(VG_(get_running_tid)()),
"Invalid semaphore",
&sei);
return;
}
p->value--;
tl_assert((int)p->value >= 0);
if (p->waits_to_skip > 0)
p->waits_to_skip--;
else
{
sg = DRD_(segment_pop)(p);
tl_assert(sg);
if (sg)
{
if (p->last_sem_post_tid != tid
&& p->last_sem_post_tid != DRD_INVALID_THREADID)
{
DRD_(thread_combine_vc2)(tid, &sg->vc);
}
DRD_(sg_put)(sg);
DRD_(thread_new_segment)(tid);
s_semaphore_segment_creation_count++;
}
}
}
示例7: sg_init
/**
* Initialize the memory 'sg' points at.
*
* @note The creator and created thread ID's may be equal.
* @note This function copies the vector clock of thread 'creator', a technique
* also known as clock snooping. This will only work reliably if the thread
* that called pthread_create() waits until the created thread has copied
* the vector clock.
*/
static void sg_init(Segment* const sg,
const DrdThreadId creator,
const DrdThreadId created)
{
Segment* creator_sg;
ThreadId vg_created = DRD_(DrdThreadIdToVgThreadId)(created);
tl_assert(sg);
tl_assert(creator == DRD_INVALID_THREADID
|| DRD_(IsValidDrdThreadId)(creator));
creator_sg = (creator != DRD_INVALID_THREADID
? DRD_(thread_get_segment)(creator) : 0);
sg->g_next = NULL;
sg->g_prev = NULL;
sg->thr_next = NULL;
sg->thr_prev = NULL;
sg->tid = created;
sg->refcnt = 1;
if (vg_created != VG_INVALID_THREADID && VG_(get_SP)(vg_created) != 0)
sg->stacktrace = VG_(record_ExeContext)(vg_created, 0);
else
sg->stacktrace = 0;
if (creator_sg)
DRD_(vc_copy)(&sg->vc, &creator_sg->vc);
else
DRD_(vc_init)(&sg->vc, 0, 0);
DRD_(vc_increment)(&sg->vc, created);
DRD_(bm_init)(&sg->bm);
if (s_trace_segment)
{
HChar* vc;
vc = DRD_(vc_aprint)(&sg->vc);
VG_(message)(Vg_DebugMsg, "New segment for thread %u with vc %s\n",
created, vc);
VG_(free)(vc);
}
}
示例8: barrier_delete_thread
/** Called when thread tid stops to exist. */
static void barrier_delete_thread(struct barrier_info* const p,
const DrdThreadId tid)
{
struct barrier_thread_info* q;
const UWord word_tid = tid;
q = VG_(OSetGen_Remove)(p->oset, &word_tid);
/*
* q is only non-zero if the barrier object has been used by thread tid
* after the barrier_init() call and before the thread finished.
*/
if (q)
{
DRD_(barrier_thread_destroy)(q);
VG_(OSetGen_FreeNode)(p->oset, q);
}
}
示例9: pthread_mutex_init_intercept
static __always_inline
int pthread_mutex_init_intercept(pthread_mutex_t *mutex,
const pthread_mutexattr_t* attr)
{
int ret;
OrigFn fn;
int mt;
VALGRIND_GET_ORIG_FN(fn);
mt = PTHREAD_MUTEX_DEFAULT;
if (attr)
pthread_mutexattr_gettype(attr, &mt);
VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__PRE_MUTEX_INIT,
mutex, DRD_(pthread_to_drd_mutex_type)(mt),
0, 0, 0);
CALL_FN_W_WW(ret, fn, mutex, attr);
VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__POST_MUTEX_INIT,
mutex, 0, 0, 0, 0);
return ret;
}
示例10: DRD_
static void DRD_(print_usage)(void)
{
VG_(printf)(
" --check-stack-var=yes|no Whether or not to report data races on\n"
" stack variables [no].\n"
" --exclusive-threshold=<n> Print an error message if any mutex or\n"
" writer lock is held longer than the specified time (in milliseconds).\n"
" --first-race-only=yes|no Only report the first data race that occurs on\n"
" a memory location instead of all races [no].\n"
" --report-signal-unlocked=yes|no Whether to report calls to\n"
" pthread_cond_signal() where the mutex associated\n"
" with the signal via pthread_cond_wait() is not\n"
" locked at the time the signal is sent [yes].\n"
" --segment-merging=yes|no Controls segment merging [yes].\n"
" Segment merging is an algorithm to limit memory usage of the\n"
" data race detection algorithm. Disabling segment merging may\n"
" improve the accuracy of the so-called 'other segments' displayed\n"
" in race reports but can also trigger an out of memory error.\n"
" --segment-merging-interval=<n> Perform segment merging every time n new\n"
" segments have been created. Default: %d.\n"
" --shared-threshold=<n> Print an error message if a reader lock\n"
" is held longer than the specified time (in milliseconds).\n"
" --show-confl-seg=yes|no Show conflicting segments in race reports [yes].\n"
" --show-stack-usage=yes|no Print stack usage at thread exit time [no].\n"
" --var-info=yes|no Display the names of global, static and\n"
" stack variables when a race is reported on such a variable. This\n"
" information is by default not displayed since for big programs\n"
" reading in all debug information at once may cause an out of\n"
" memory error [no].\n"
"\n"
" drd options for monitoring process behavior:\n"
" --trace-addr=<address> Trace all load and store activity for the.\n"
" specified address [off].\n"
" --trace-barrier=yes|no Trace all barrier activity [no].\n"
" --trace-cond=yes|no Trace all condition variable activity [no].\n"
" --trace-fork-join=yes|no Trace all thread fork/join activity [no].\n"
" --trace-mutex=yes|no Trace all mutex activity [no].\n"
" --trace-rwlock=yes|no Trace all reader-writer lock activity[no].\n"
" --trace-semaphore=yes|no Trace all semaphore activity [no].\n",
DRD_(thread_get_segment_merge_interval)()
);
VG_(replacement_malloc_print_usage)();
}
示例11: clientobj_remove_obj
/**
* Remove the information that was stored about the client object p.
*
* @note The order of operations below is important. The client object is
* removed from the client object set after the cleanup function has been
* called such that if the cleanup function can still use the function
* DRD_(clientobj_get_any)(). This happens e.g. in the function
* first_observed() in drd_error.c.
*/
static Bool clientobj_remove_obj(DrdClientobj* const p)
{
tl_assert(p);
if (s_trace_clientobj) {
DRD_(trace_msg)("Removing client object 0x%lx of type %d", p->any.a1,
p->any.type);
#if 0
VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(),
VG_(clo_backtrace_size));
#endif
}
tl_assert(p->any.cleanup);
(*p->any.cleanup)(p);
VG_(OSetGen_Remove)(s_clientobj_set, &p->any.a1);
VG_(OSetGen_FreeNode)(s_clientobj_set, p);
return True;
}
示例12: bm_test1
void bm_test1(void)
{
struct bitmap* bm;
struct bitmap* bm2;
unsigned i, j;
bm = DRD_(bm_new)();
for (i = 0; i < sizeof(s_test1_args)/sizeof(s_test1_args[0]); i++)
{
DRD_(bm_access_range)(bm,
s_test1_args[i].address,
s_test1_args[i].address + s_test1_args[i].size,
s_test1_args[i].access_type);
}
for (i = 0; i < sizeof(s_test1_args)/sizeof(s_test1_args[0]); i++)
{
for (j = 0;
first_address_with_higher_lsb(j) <= s_test1_args[i].size;
j = first_address_with_higher_lsb(j))
{
tl_assert(DRD_(bm_has_1)(bm,
s_test1_args[i].address + j,
s_test1_args[i].access_type));
}
}
bm2 = DRD_(bm_new)();
DRD_(bm_merge2)(bm2, bm);
DRD_(bm_merge2)(bm2, bm);
assert(bm_equal_print_diffs(bm2, bm));
if (s_verbose)
VG_(printf)("Deleting bitmap bm\n");
DRD_(bm_delete)(bm);
if (s_verbose)
VG_(printf)("Deleting bitmap bm2\n");
DRD_(bm_delete)(bm2);
}
示例13: drd_pre_mem_read_asciiz
static void drd_pre_mem_read_asciiz(const CorePart part,
const ThreadId tid,
Char* const s,
const Addr a)
{
const char* p = (void*)a;
SizeT size = 0;
/* Note: the expression '*p' reads client memory and may crash if the */
/* client provided an invalid pointer ! */
while (*p)
{
p++;
size++;
}
if (size > 0)
{
DRD_(trace_load)(a, size);
}
}
示例14: DRD_
/**
* Combine the vector clock corresponding to the last unlock operation of
* reader-writer lock p into the vector clock of thread 'tid'.
*/
static void DRD_(rwlock_combine_other_vc)(struct rwlock_info* const p,
const DrdThreadId tid,
const Bool readers_too)
{
struct rwlock_thread_info* q;
VectorClock old_vc;
DRD_(vc_copy)(&old_vc, DRD_(thread_get_vc)(tid));
VG_(OSetGen_ResetIter)(p->thread_info);
for ( ; (q = VG_(OSetGen_Next)(p->thread_info)) != 0; ) {
if (q->tid != tid) {
if (q->latest_wrlocked_segment)
DRD_(vc_combine)(DRD_(thread_get_vc)(tid),
&q->latest_wrlocked_segment->vc);
if (readers_too && q->latest_rdlocked_segment)
DRD_(vc_combine)(DRD_(thread_get_vc)(tid),
&q->latest_rdlocked_segment->vc);
}
}
DRD_(thread_update_conflict_set)(tid, &old_vc);
DRD_(vc_cleanup)(&old_vc);
}
示例15: PTH_FUNC
// pthread_mutex_init
PTH_FUNC(int, pthreadZumutexZuinit,
pthread_mutex_t *mutex,
const pthread_mutexattr_t* attr)
{
int ret;
int res;
OrigFn fn;
int mt;
VALGRIND_GET_ORIG_FN(fn);
mt = PTHREAD_MUTEX_DEFAULT;
if (attr)
pthread_mutexattr_gettype(attr, &mt);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_MUTEX_INIT,
mutex, DRD_(pthread_to_drd_mutex_type)(mt),
0, 0, 0);
CALL_FN_W_WW(ret, fn, mutex, attr);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_INIT,
mutex, 0, 0, 0, 0);
return ret;
}