From: Bart Van Assche Date: Sun, 16 Mar 2008 10:42:33 +0000 (+0000) Subject: Removed support for thread names. X-Git-Tag: svn/VALGRIND_3_4_0~860 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e97c6854de59ef7a9f16c378210e69c86da2627;p=thirdparty%2Fvalgrind.git Removed support for thread names. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7704 --- diff --git a/exp-drd/drd_clientreq.c b/exp-drd/drd_clientreq.c index e03f7aa074..c2a34857f5 100644 --- a/exp-drd/drd_clientreq.c +++ b/exp-drd/drd_clientreq.c @@ -93,10 +93,6 @@ static Bool drd_handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret) 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; diff --git a/exp-drd/drd_clientreq.h b/exp-drd/drd_clientreq.h index 0c73d91b0c..8d421d6514 100644 --- a/exp-drd/drd_clientreq.h +++ b/exp-drd/drd_clientreq.h @@ -9,9 +9,6 @@ enum { /* 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. */ diff --git a/exp-drd/drd_error.c b/exp-drd/drd_error.c index e3a7bc9f26..50e8ff9f68 100644 --- a/exp-drd/drd_error.c +++ b/exp-drd/drd_error.c @@ -181,8 +181,8 @@ Char* describe_addr_text(Addr const a, SizeT const len, AddrInfo* const ai, { 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: { @@ -235,9 +235,9 @@ void drd_report_data_race2(Error* const err, const DataRaceErrInfo* const dri) 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)); @@ -258,7 +258,7 @@ void drd_report_data_race2(Error* const err, const DataRaceErrInfo* const dri) { 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); } diff --git a/exp-drd/drd_error.h b/exp-drd/drd_error.h index ab95c8f487..5da18b5cc3 100644 --- a/exp-drd/drd_error.h +++ b/exp-drd/drd_error.h @@ -78,7 +78,7 @@ struct { // Used by: 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. diff --git a/exp-drd/drd_main.c b/exp-drd/drd_main.c index fc9fc5c812..db33579222 100644 --- a/exp-drd/drd_main.c +++ b/exp-drd/drd_main.c @@ -154,7 +154,7 @@ static void drd_trace_mem_access(const Addr addr, const SizeT size, 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 @@ -166,7 +166,6 @@ static void drd_trace_mem_access(const Addr addr, const SizeT size, : "????", addr, size, - thread_get_name(thread_get_running_tid()), VG_(get_running_tid)(), thread_get_running_tid(), vc); @@ -184,7 +183,7 @@ static void drd_report_race(const Addr addr, const SizeT size, 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; diff --git a/exp-drd/drd_thread.c b/exp-drd/drd_thread.c index fafac5f80c..dc59818352 100644 --- a/exp-drd/drd_thread.c +++ b/exp-drd/drd_thread.c @@ -122,9 +122,6 @@ DrdThreadId VgThreadIdToNewDrdThreadId(const ThreadId tid) 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) @@ -350,32 +347,6 @@ void thread_set_joinable(const DrdThreadId tid, const Bool joinable) 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); @@ -688,15 +659,14 @@ void thread_print_all(void) 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); @@ -711,10 +681,7 @@ static void show_call_stack(const DrdThreadId tid, { 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) { diff --git a/exp-drd/drd_thread.h b/exp-drd/drd_thread.h index f92b551b90..24e3506c0e 100644 --- a/exp-drd/drd_thread.h +++ b/exp-drd/drd_thread.h @@ -63,7 +63,6 @@ typedef struct 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. @@ -109,10 +108,6 @@ DrdThreadId thread_lookup_stackaddr(const Addr a, 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); diff --git a/exp-drd/tests/fp_race.c b/exp-drd/tests/fp_race.c index facf6e4baf..d23d7580b8 100644 --- a/exp-drd/tests/fp_race.c +++ b/exp-drd/tests/fp_race.c @@ -52,20 +52,11 @@ static int s_use_mutex = 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, - 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) @@ -123,8 +114,6 @@ int main(int argc, char** argv) 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); diff --git a/exp-drd/tests/fp_race.stderr.exp b/exp-drd/tests/fp_race.stderr.exp index 09e5131875..bceb943444 100644 --- a/exp-drd/tests/fp_race.stderr.exp +++ b/exp-drd/tests/fp_race.stderr.exp @@ -1,20 +1,20 @@ -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) diff --git a/exp-drd/tests/pth_cond_race.c b/exp-drd/tests/pth_cond_race.c index 367d585c48..ad77bacf62 100644 --- a/exp-drd/tests/pth_cond_race.c +++ b/exp-drd/tests/pth_cond_race.c @@ -23,20 +23,11 @@ static int s_use_mutex = 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) @@ -68,8 +59,6 @@ int main(int argc, char** argv) 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); diff --git a/exp-drd/tests/pth_detached.c b/exp-drd/tests/pth_detached.c index 0d4eea5641..8e64f91427 100644 --- a/exp-drd/tests/pth_detached.c +++ b/exp-drd/tests/pth_detached.c @@ -12,23 +12,9 @@ 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); @@ -47,7 +33,6 @@ static int get_finished_count() static void* thread_func1(void* arg) { - set_thread_name("thread_func1[%d]", *(int*)arg); write(STDOUT_FILENO, ".", 1); increment_finished_count(); return 0; @@ -55,7 +40,6 @@ static void* thread_func1(void* arg) 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(); @@ -66,16 +50,11 @@ int main(int argc, char** argv) { 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; diff --git a/exp-drd/tests/pth_detached_sem.c b/exp-drd/tests/pth_detached_sem.c index af8df170c9..91b0bb0cf7 100644 --- a/exp-drd/tests/pth_detached_sem.c +++ b/exp-drd/tests/pth_detached_sem.c @@ -16,23 +16,9 @@ #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); @@ -40,7 +26,6 @@ static void increment_finished_count() static void* thread_func1(void* arg) { - set_thread_name("thread_func1[%d]", *(int*)arg); write(STDOUT_FILENO, ".", 1); increment_finished_count(); return 0; @@ -48,7 +33,6 @@ static void* thread_func1(void* arg) 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(); @@ -59,16 +43,11 @@ int main(int argc, char** argv) { 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; diff --git a/exp-drd/tests/sem_as_mutex.c b/exp-drd/tests/sem_as_mutex.c index b0842f5fff..7a1c358ee3 100644 --- a/exp-drd/tests/sem_as_mutex.c +++ b/exp-drd/tests/sem_as_mutex.c @@ -53,20 +53,11 @@ static int s_do_mutual_exclusion = 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, - 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) @@ -124,8 +115,6 @@ int main(int argc, char** argv) 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); diff --git a/exp-drd/tests/sem_as_mutex.stderr.exp b/exp-drd/tests/sem_as_mutex.stderr.exp index e6b9616845..ccd4d003dd 100644 --- a/exp-drd/tests/sem_as_mutex.stderr.exp +++ b/exp-drd/tests/sem_as_mutex.stderr.exp @@ -1,20 +1,20 @@ -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)