result = vg_tid;
break;
- case VG_USERREQ__SET_THREAD_NAME:
- thread_set_name_fmt(drd_tid, (char*)arg[1], arg[2]);
- break;
-
case VG_USERREQ__DRD_START_SUPPRESSION:
drd_start_suppression(arg[1], arg[2], "client");
break;
/* Ask the core the thread ID assigned by Valgrind. */
VG_USERREQ__GET_THREAD_SELF = VG_USERREQ_TOOL_BASE('D', 'R'),
/* args: none. */
- /* Set the name of the thread that performs this client request. */
- VG_USERREQ__SET_THREAD_NAME,
- /* args: null-terminated character string. */
/* To tell the drd tool to suppress data race detection on the specified */
/* address range. */
{
case eStack: {
VG_(snprintf)(buf, n_buf,
- "stack of %s, offset %d",
- thread_get_name(ai->stack_tid), ai->rwoffset);
+ "stack of thread %d, offset %d",
+ ai->stack_tid, ai->rwoffset);
break;
}
case eSegment: {
describe_addr(dri->addr, dri->size, &ai);
}
VG_(message)(Vg_UserMsg,
- "Conflicting %s by %s at 0x%08lx size %ld",
+ "Conflicting %s by thread %d at 0x%08lx size %ld",
dri->access_type == eStore ? "store" : "load",
- thread_get_name(VgThreadIdToDrdThreadId(dri->tid)),
+ DrdThreadIdToVgThreadId(dri->tid),
dri->addr,
dri->size);
VG_(pp_ExeContext)(VG_(get_error_where)(err));
{
VG_(message)(Vg_UserMsg, "Allocation context: unknown.");
}
- thread_report_conflicting_segments(VgThreadIdToDrdThreadId(dri->tid),
+ thread_report_conflicting_segments(dri->tid,
dri->addr, dri->size, dri->access_type);
}
AddrInfo;
typedef struct {
- ThreadId tid; // Thread ID of the running thread.
+ DrdThreadId tid; // Thread ID of the running thread.
Addr addr; // Conflicting address in current thread.
SizeT size; // Size in bytes of conflicting operation.
BmAccessTypeT access_type; // Access type: load or store.
char vc[80];
vc_snprint(vc, sizeof(vc), thread_get_vc(thread_get_running_tid()));
VG_(message)(Vg_UserMsg,
- "%s 0x%lx size %ld %s (vg %d / drd %d / vc %s)",
+ "%s 0x%lx size %ld (vg %d / drd %d / vc %s)",
access_type == eLoad
? "load "
: access_type == eStore
: "????",
addr,
size,
- thread_get_name(thread_get_running_tid()),
VG_(get_running_tid)(),
thread_get_running_tid(),
vc);
if (drd_is_suppressed(addr, addr + size))
return;
- drei.tid = VG_(get_running_tid)();
+ drei.tid = thread_get_running_tid();
drei.addr = addr;
drei.size = size;
drei.access_type = access_type;
s_threadinfo[i].stack_min = 0;
s_threadinfo[i].stack_startup = 0;
s_threadinfo[i].stack_max = 0;
- VG_(snprintf)(s_threadinfo[i].name, sizeof(s_threadinfo[i].name),
- "thread %d", tid);
- s_threadinfo[i].name[sizeof(s_threadinfo[i].name) - 1] = 0;
s_threadinfo[i].is_recording = True;
s_threadinfo[i].synchr_nesting = 0;
if (s_threadinfo[i].first != 0)
s_threadinfo[tid].detached_posix_thread = ! joinable;
}
-const char* thread_get_name(const DrdThreadId tid)
-{
- tl_assert(0 <= tid && tid < DRD_N_THREADS
- && tid != DRD_INVALID_THREADID);
- return s_threadinfo[tid].name;
-}
-
-void thread_set_name(const DrdThreadId tid, const char* const name)
-{
- tl_assert(0 <= tid && tid < DRD_N_THREADS
- && tid != DRD_INVALID_THREADID);
- VG_(strncpy)(s_threadinfo[tid].name, name,
- sizeof(s_threadinfo[tid].name));
- s_threadinfo[tid].name[sizeof(s_threadinfo[tid].name) - 1] = 0;
-}
-
-void thread_set_name_fmt(const DrdThreadId tid, const char* const fmt,
- const UWord arg)
-{
- tl_assert(0 <= tid && tid < DRD_N_THREADS
- && tid != DRD_INVALID_THREADID);
- VG_(snprintf)(s_threadinfo[tid].name, sizeof(s_threadinfo[tid].name),
- fmt, arg);
- s_threadinfo[tid].name[sizeof(s_threadinfo[tid].name) - 1] = 0;
-}
-
void thread_set_vg_running_tid(const ThreadId vg_tid)
{
tl_assert(vg_tid != VG_INVALID_THREADID);
if (s_threadinfo[i].first)
{
VG_(printf)("**************\n"
- "* thread %3d (%d/%d/%d/0x%x/%d/%s) *\n"
+ "* thread %3d (%d/%d/%d/0x%x/%d) *\n"
"**************\n",
i,
s_threadinfo[i].vg_thread_exists,
s_threadinfo[i].vg_threadid,
s_threadinfo[i].posix_thread_exists,
s_threadinfo[i].pt_threadid,
- s_threadinfo[i].detached_posix_thread,
- s_threadinfo[i].name);
+ s_threadinfo[i].detached_posix_thread);
for (p = s_threadinfo[i].first; p; p = p->next)
{
sg_print(p);
{
const ThreadId vg_tid = DrdThreadIdToVgThreadId(tid);
- VG_(message)(Vg_UserMsg,
- "%s (%s)",
- msg,
- thread_get_name(tid));
+ VG_(message)(Vg_UserMsg, "%s (thread %d)", msg, tid);
if (vg_tid != VG_INVALID_THREADID)
{
Addr stack_min;
Addr stack_startup;
Addr stack_max;
- char name[32];
/// Indicates whether the Valgrind core knows about this thread.
Bool vg_thread_exists;
/// Indicates whether there is an associated POSIX thread ID.
void thread_set_pthreadid(const DrdThreadId tid, const PThreadId ptid);
Bool thread_get_joinable(const DrdThreadId tid);
void thread_set_joinable(const DrdThreadId tid, const Bool joinable);
-const char* thread_get_name(const DrdThreadId tid);
-void thread_set_name(const DrdThreadId tid, const char* const name);
-void thread_set_name_fmt(const DrdThreadId tid, const char* const name,
- const UWord arg);
void thread_set_vg_running_tid(const ThreadId vg_tid);
void thread_set_running_tid(const ThreadId vg_tid,
const DrdThreadId drd_tid);
// Function definitions.
-static void set_thread_name(const char* const name)
-{
- int res;
- VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__SET_THREAD_NAME,
- name, 0, 0, 0, 0);
-}
-
int main(int argc, char** argv)
{
int optchar;
pthread_t threadid;
- set_thread_name("main");
-
while ((optchar = getopt(argc, argv, "dmp")) != EOF)
{
switch (optchar)
static void* thread_func(void* thread_arg)
{
- set_thread_name("thread_func");
-
if (s_do_printf)
{
printf("s_d1 = %g (should be 1)\n", s_d1);
-Conflicting load by main at 0x........ size 8
+Conflicting load by thread 1 at 0x........ size 8
at 0x........: main (fp_race.c:?)
Location 0x........ is 0 bytes inside local var "s_d3"
declared at fp_race.c:47, in frame #? of thread 1
-Other segment start (thread_func)
+Other segment start (thread 2)
(thread finished, call stack no longer available)
-Other segment end (thread_func)
+Other segment end (thread 2)
(thread finished, call stack no longer available)
-Conflicting store by main at 0x........ size 8
+Conflicting store by thread 1 at 0x........ size 8
at 0x........: main (fp_race.c:?)
Location 0x........ is 0 bytes inside local var "s_d3"
declared at fp_race.c:47, in frame #? of thread 1
-Other segment start (thread_func)
+Other segment start (thread 2)
(thread finished, call stack no longer available)
-Other segment end (thread_func)
+Other segment end (thread 2)
(thread finished, call stack no longer available)
ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
// Function definitions.
-static void set_thread_name(const char* const name)
-{
- int res;
- VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__SET_THREAD_NAME,
- "%s", name, 0, 0, 0);
-}
-
int main(int argc, char** argv)
{
int optchar;
pthread_t threadid;
- set_thread_name("main");
-
while ((optchar = getopt(argc, argv, "m")) != EOF)
{
switch (optchar)
static void* thread_func(void* thread_arg)
{
- set_thread_name("thread_func");
-
// Wait until the main thread has entered pthread_cond_wait().
pthread_mutex_lock(&s_mutex);
pthread_mutex_unlock(&s_mutex);
static int s_finished_count;
-static int s_set_thread_name;
static pthread_mutex_t s_mutex;
-static void set_thread_name(const char* const fmt, const int arg)
-{
- if (s_set_thread_name)
- {
- int res;
- char name[32];
- snprintf(name, sizeof(name), fmt, arg);
- name[sizeof(name) - 1] = 0;
- VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__SET_THREAD_NAME,
- name, 0, 0, 0, 0);
- }
-}
-
static void increment_finished_count()
{
pthread_mutex_lock(&s_mutex);
static void* thread_func1(void* arg)
{
- set_thread_name("thread_func1[%d]", *(int*)arg);
write(STDOUT_FILENO, ".", 1);
increment_finished_count();
return 0;
static void* thread_func2(void* arg)
{
- set_thread_name("thread_func2[%d]", *(int*)arg);
pthread_detach(pthread_self());
write(STDOUT_FILENO, ".", 1);
increment_finished_count();
{
const int count1 = argc > 1 ? atoi(argv[1]) : 100;
const int count2 = argc > 2 ? atoi(argv[2]) : 100;
- const int do_set_thread_name = argc > 3 ? atoi(argv[3]) != 0 : 0;
int thread_arg[count1 > count2 ? count1 : count2];
int i;
int detachstate;
pthread_attr_t attr;
- s_set_thread_name = do_set_thread_name;
-
- set_thread_name("main", 0);
-
for (i = 0; i < count1 || i < count2; i++)
thread_arg[i] = i;
#include "../drd_clientreq.h"
-static int s_set_thread_name;
static sem_t s_sem;
-static void set_thread_name(const char* const fmt, const int arg)
-{
- if (s_set_thread_name)
- {
- int res;
- char name[32];
- snprintf(name, sizeof(name), fmt, arg);
- name[sizeof(name) - 1] = 0;
- VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__SET_THREAD_NAME,
- name, 0, 0, 0, 0);
- }
-}
-
static void increment_finished_count()
{
sem_post(&s_sem);
static void* thread_func1(void* arg)
{
- set_thread_name("thread_func1[%d]", *(int*)arg);
write(STDOUT_FILENO, ".", 1);
increment_finished_count();
return 0;
static void* thread_func2(void* arg)
{
- set_thread_name("thread_func2[%d]", *(int*)arg);
pthread_detach(pthread_self());
write(STDOUT_FILENO, ".", 1);
increment_finished_count();
{
const int count1 = argc > 1 ? atoi(argv[1]) : 100;
const int count2 = argc > 2 ? atoi(argv[2]) : 100;
- const int do_set_thread_name = argc > 3 ? atoi(argv[3]) != 0 : 0;
int thread_arg[count1 > count2 ? count1 : count2];
int i;
int detachstate;
pthread_attr_t attr;
- s_set_thread_name = do_set_thread_name;
-
- set_thread_name("main", 0);
-
for (i = 0; i < count1 || i < count2; i++)
thread_arg[i] = i;
// Function definitions.
-static void set_thread_name(const char* const name)
-{
- int res;
- VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__SET_THREAD_NAME,
- name, 0, 0, 0, 0);
-}
-
int main(int argc, char** argv)
{
int optchar;
pthread_t threadid;
- set_thread_name("main");
-
while ((optchar = getopt(argc, argv, "dmp")) != EOF)
{
switch (optchar)
static void* thread_func(void* thread_arg)
{
- set_thread_name("thread_func");
-
if (s_do_printf)
{
printf("s_d1 = %g (should be 1)\n", s_d1);
-Conflicting load by main at 0x........ size 8
+Conflicting load by thread 1 at 0x........ size 8
at 0x........: main (sem_as_mutex.c:?)
Location 0x........ is 0 bytes inside local var "s_d3"
declared at sem_as_mutex.c:48, in frame #? of thread 1
-Other segment start (thread_func)
+Other segment start (thread 2)
(thread finished, call stack no longer available)
-Other segment end (thread_func)
+Other segment end (thread 2)
(thread finished, call stack no longer available)
-Conflicting store by main at 0x........ size 8
+Conflicting store by thread 1 at 0x........ size 8
at 0x........: main (sem_as_mutex.c:?)
Location 0x........ is 0 bytes inside local var "s_d3"
declared at sem_as_mutex.c:48, in frame #? of thread 1
-Other segment start (thread_func)
+Other segment start (thread 2)
(thread finished, call stack no longer available)
-Other segment end (thread_func)
+Other segment end (thread 2)
(thread finished, call stack no longer available)
ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)