Added inline function running_thread_is_recording(). Removed function thread_is_recording().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7672 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/exp-drd/drd_main.c b/exp-drd/drd_main.c
index 35e3cef..7ad153d 100644
--- a/exp-drd/drd_main.c
+++ b/exp-drd/drd_main.c
@@ -153,10 +153,12 @@
{
Segment* sg;
+#if 0
tl_assert(thread_get_running_tid()
== VgThreadIdToDrdThreadId(VG_(get_running_tid())));
+#endif
- if (! thread_is_recording(thread_get_running_tid()))
+ if (! running_thread_is_recording())
return;
#if 1
@@ -199,10 +201,12 @@
{
Segment* sg;
+#if 0
tl_assert(thread_get_running_tid()
== VgThreadIdToDrdThreadId(VG_(get_running_tid())));
+#endif
- if (! thread_is_recording(thread_get_running_tid()))
+ if (! running_thread_is_recording())
return;
#if 1
diff --git a/exp-drd/drd_thread.c b/exp-drd/drd_thread.c
index c8ab570..c5e95d1 100644
--- a/exp-drd/drd_thread.c
+++ b/exp-drd/drd_thread.c
@@ -38,38 +38,6 @@
#include "pub_tool_threadstate.h" // VG_(get_pthread_id)()
-// Defines.
-
-#define DRD_N_THREADS VG_N_THREADS
-
-
-// Type definitions.
-
-typedef struct
-{
- Segment* first;
- Segment* last;
- ThreadId vg_threadid;
- PThreadId pt_threadid;
- Addr stack_min_min;
- 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.
- Bool posix_thread_exists;
- /// If true, indicates that there is a corresponding POSIX thread ID and
- /// a corresponding OS thread that is detached.
- Bool detached_posix_thread;
- /// Wether recording of memory accesses is active.
- Bool is_recording;
- /// Nesting level of synchronization functions called by the client.
- Int synchr_nesting;
-} ThreadInfo;
-
-
// Local functions.
static void thread_append_segment(const DrdThreadId tid,
@@ -85,8 +53,8 @@
static ULong s_danger_set_bitmap_creation_count;
static ULong s_danger_set_bitmap2_creation_count;
static ThreadId s_vg_running_tid = VG_INVALID_THREADID;
-static DrdThreadId s_drd_running_tid = DRD_INVALID_THREADID;
-static ThreadInfo s_threadinfo[DRD_N_THREADS];
+DrdThreadId s_drd_running_tid = DRD_INVALID_THREADID;
+ThreadInfo s_threadinfo[DRD_N_THREADS];
static struct bitmap* s_danger_set;
static Bool s_trace_context_switches = False;
static Bool s_trace_danger_set = False;
@@ -760,13 +728,6 @@
s_threadinfo[tid].is_recording = False;
}
-Bool thread_is_recording(const DrdThreadId tid)
-{
- tl_assert(0 <= tid && tid < DRD_N_THREADS && tid != DRD_INVALID_THREADID);
- return (s_threadinfo[tid].synchr_nesting == 0
- && s_threadinfo[tid].is_recording);
-}
-
void thread_print_all(void)
{
unsigned i;
diff --git a/exp-drd/drd_thread.h b/exp-drd/drd_thread.h
index b7b2995..550daaf 100644
--- a/exp-drd/drd_thread.h
+++ b/exp-drd/drd_thread.h
@@ -27,9 +27,17 @@
#define __THREAD_H
-#include "drd_segment.h"
-#include "pub_tool_stacktrace.h" // StackTrace
+// Includes.
+#include "drd_segment.h"
+#include "pub_tool_libcassert.h" // tl_assert()
+#include "pub_tool_stacktrace.h" // StackTrace
+#include "pub_tool_threadstate.h" // VG_N_THREADS
+
+
+// Defines.
+
+#define DRD_N_THREADS VG_N_THREADS
#define DRD_INVALID_THREADID 0
@@ -41,9 +49,44 @@
#define INVALID_POSIX_THREADID ((PThreadId)0)
+// Type definitions.
+
typedef UInt DrdThreadId;
typedef UWord PThreadId;
+typedef struct
+{
+ Segment* first;
+ Segment* last;
+ ThreadId vg_threadid;
+ PThreadId pt_threadid;
+ Addr stack_min_min;
+ 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.
+ Bool posix_thread_exists;
+ /// If true, indicates that there is a corresponding POSIX thread ID and
+ /// a corresponding OS thread that is detached.
+ Bool detached_posix_thread;
+ /// Wether recording of memory accesses is active.
+ Bool is_recording;
+ /// Nesting level of synchronization functions called by the client.
+ Int synchr_nesting;
+} ThreadInfo;
+
+
+// Local variables of drd_thread.c that are declared here such that these
+// can be accessed by inline functions.
+
+extern DrdThreadId s_drd_running_tid;
+extern ThreadInfo s_threadinfo[DRD_N_THREADS];
+
+
+// Function declarations.
void thread_trace_context_switches(const Bool t);
void thread_trace_danger_set(const Bool t);
@@ -86,7 +129,6 @@
void thread_stop_using_mem(const Addr a1, const Addr a2);
void thread_start_recording(const DrdThreadId tid);
void thread_stop_recording(const DrdThreadId tid);
-Bool thread_is_recording(const DrdThreadId tid);
void thread_print_all(void);
void thread_report_races(const DrdThreadId tid);
void thread_report_races_segment(const DrdThreadId tid,
@@ -107,4 +149,14 @@
ULong thread_get_danger_set_bitmap2_creation_count(void);
+static inline
+Bool running_thread_is_recording(void)
+{
+ tl_assert(0 <= s_drd_running_tid && s_drd_running_tid < DRD_N_THREADS
+ && s_drd_running_tid != DRD_INVALID_THREADID);
+ return (s_threadinfo[s_drd_running_tid].synchr_nesting == 0
+ && s_threadinfo[s_drd_running_tid].is_recording);
+}
+
+
#endif // __THREAD_H