- Added support for most of the ANNOTATE_...() macro's supported by
ThreadSanitizer.
- Modified DRD's error reporting code such that it does no longer let
the Valgrind core print the Valgrind thread ID but that it now prints
the DRD thread ID and name. Updated expected output files where
necessary.
- Modified drd/test/Makefile.am such that the tests using gcc's built-in
functions for atomic memory access such that these are only compiled when
the gcc version in use supports these built-in functions.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10186 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/drd/drd_thread.c b/drd/drd_thread.c
index cf22859..c8740e3 100644
--- a/drd/drd_thread.c
+++ b/drd/drd_thread.c
@@ -156,7 +156,9 @@
DRD_(g_threadinfo)[i].stack_min_min = 0;
DRD_(g_threadinfo)[i].stack_startup = 0;
DRD_(g_threadinfo)[i].stack_max = 0;
- DRD_(g_threadinfo)[i].is_recording = True;
+ DRD_(thread_set_name)(i, "");
+ DRD_(g_threadinfo)[i].is_recording_loads = True;
+ DRD_(g_threadinfo)[i].is_recording_stores = True;
DRD_(g_threadinfo)[i].synchr_nesting = 0;
tl_assert(DRD_(g_threadinfo)[i].first == 0);
tl_assert(DRD_(g_threadinfo)[i].last == 0);
@@ -494,6 +496,34 @@
DRD_(g_threadinfo)[tid].detached_posix_thread = ! joinable;
}
+/** Obtain the thread number and the user-assigned thread name. */
+const char* DRD_(thread_get_name)(const DrdThreadId tid)
+{
+ tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
+ && tid != DRD_INVALID_THREADID);
+
+ return DRD_(g_threadinfo)[tid].name;
+}
+
+/** Set the name of the specified thread. */
+void DRD_(thread_set_name)(const DrdThreadId tid, const char* const name)
+{
+ tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
+ && tid != DRD_INVALID_THREADID);
+
+ if (name == NULL || name[0] == 0)
+ VG_(snprintf)(DRD_(g_threadinfo)[tid].name,
+ sizeof(DRD_(g_threadinfo)[tid].name),
+ "Thread %d",
+ tid);
+ else
+ VG_(snprintf)(DRD_(g_threadinfo)[tid].name,
+ sizeof(DRD_(g_threadinfo)[tid].name),
+ "Thread %d (%s)",
+ tid, name);
+ DRD_(g_threadinfo)[tid].name[sizeof(DRD_(g_threadinfo)[tid].name) - 1] = 0;
+}
+
/**
* Update s_vg_running_tid, DRD_(g_drd_running_tid) and recalculate the
* conflict set.
@@ -884,22 +914,24 @@
}
}
-/** Start recording memory access information. */
-void DRD_(thread_start_recording)(const DrdThreadId tid)
+/** Specify whether memory loads should be recorded. */
+void DRD_(thread_set_record_loads)(const DrdThreadId tid, const Bool enabled)
{
tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
&& tid != DRD_INVALID_THREADID);
- tl_assert(! DRD_(g_threadinfo)[tid].is_recording);
- DRD_(g_threadinfo)[tid].is_recording = True;
+ tl_assert(enabled == !! enabled);
+
+ DRD_(g_threadinfo)[tid].is_recording_loads = enabled;
}
-/** Stop recording memory access information. */
-void DRD_(thread_stop_recording)(const DrdThreadId tid)
+/** Specify whether memory stores should be recorded. */
+void DRD_(thread_set_record_stores)(const DrdThreadId tid, const Bool enabled)
{
tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
&& tid != DRD_INVALID_THREADID);
- tl_assert(DRD_(g_threadinfo)[tid].is_recording);
- DRD_(g_threadinfo)[tid].is_recording = False;
+ tl_assert(enabled == !! enabled);
+
+ DRD_(g_threadinfo)[tid].is_recording_stores = enabled;
}
/**