]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added inline function running_thread_is_recording(). Removed function thread_is_recor...
authorBart Van Assche <bvanassche@acm.org>
Thu, 13 Mar 2008 18:49:23 +0000 (18:49 +0000)
committerBart Van Assche <bvanassche@acm.org>
Thu, 13 Mar 2008 18:49:23 +0000 (18:49 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7672

exp-drd/drd_main.c
exp-drd/drd_thread.c
exp-drd/drd_thread.h

index 35e3cef9f21ff2c1771feeb7bb72d5f0b20aa9b5..7ad153da66634c41d807d99c657ff12741eec719 100644 (file)
@@ -153,10 +153,12 @@ VG_REGPARM(2) void drd_trace_load(Addr addr, SizeT size)
 {
    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 @@ VG_REGPARM(2) void drd_trace_store(Addr addr, SizeT size)
 {
    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
index c8ab57018bd7dc6be2fc24ba64a4eb4385eac910..c5e95d15586f3302aeb4903c0f56d102138a5cd1 100644 (file)
 #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_update_danger_set_count;
 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 @@ void thread_stop_recording(const DrdThreadId tid)
    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;
index b7b2995976599224ce32d49f013e34ddb0eea157..550daaf5352bcc56c0e53d786c7956ab41c28743 100644 (file)
 #define __THREAD_H
 
 
+// Includes.
+
 #include "drd_segment.h"
-#include "pub_tool_stacktrace.h" // StackTrace
+#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
 
 #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_combine_vc2(const DrdThreadId tid, const VectorClock* const vc);
 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_bitmap_creation_count(void);
 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