]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Mark the main thread as running while the initial memory declarations
authorTom Hughes <tom@compton.nu>
Wed, 2 Jan 2008 10:13:04 +0000 (10:13 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 2 Jan 2008 10:13:04 +0000 (10:13 +0000)
are made to the tool so that the tool can associate that memory with
the main thread if it wishes.

Also cleanup existing hacks in the drd tool which worked around the
fact that the core did not set the current thread while declaring the
initial memory.

Path from Bart Van Assche <bart.vanassche@gmail.com>.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7310

coregrind/m_main.c
exp-drd/drd_main.c
exp-drd/drd_thread.c

index 3861cfb7a7d10f059c524065ebe7facef3758f02..92401b7f229bc91336b0092ebb1e3c9dde1ba6c2 100644 (file)
@@ -1763,6 +1763,12 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
    { Addr*     seg_starts;
      Int       n_seg_starts;
 
+     /* Mark the main thread as running while we tell the tool about
+        the client memory so that the tool can associate that memory
+        with the main thread. */
+     tl_assert(VG_(running_tid) == VG_INVALID_THREADID);
+     VG_(running_tid) = tid_main;
+
      seg_starts = get_seg_starts( &n_seg_starts );
      vg_assert(seg_starts && n_seg_starts >= 0);
 
@@ -1821,6 +1827,10 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
                False, /* readable? */
                False, /* writable? */
                True   /* executable? */ );
+
+     /* Clear the running thread indicator */
+     VG_(running_tid) = VG_INVALID_THREADID;
+     tl_assert(VG_(running_tid) == VG_INVALID_THREADID);
    }
 
    //--------------------------------------------------------------
index 12c0887e9e5165b9d1752fd382eb21e658696e42..d18b8b2d02ae3d603700e87c7b9adab254b6e537 100644 (file)
@@ -321,13 +321,6 @@ void drd_pre_thread_create(const ThreadId creator, const ThreadId created)
    const DrdThreadId drd_creator = VgThreadIdToDrdThreadId(creator);
    tl_assert(created != VG_INVALID_THREADID);
    thread_pre_create(drd_creator, created);
-#if 1
-   // Hack: compensation for code missing in coregrind/m_main.c.
-   if (created == 1)
-   {
-      thread_set_running_tid(1, 1);
-   }
-#endif
    if (IsValidDrdThreadId(drd_creator))
    {
       thread_new_segment(drd_creator);
index 8ab9938f2e64a0700d147ecf6fb59f8843062ee3..4277e1b2ee06aa99f855fd8a14972f41c793a205 100644 (file)
@@ -424,17 +424,14 @@ void thread_set_name_fmt(const DrdThreadId tid, const char* const fmt,
 
 DrdThreadId thread_get_running_tid(void)
 {
-   // HACK. To do: remove the if-statement and keep the assert.
-   if (VG_(get_running_tid)() != VG_INVALID_THREADID)
-      tl_assert(VG_(get_running_tid)() == s_vg_running_tid);
+   tl_assert(VG_(get_running_tid)() == s_vg_running_tid);
    tl_assert(s_drd_running_tid != DRD_INVALID_THREADID);
    return s_drd_running_tid;
 }
 
 void thread_set_vg_running_tid(const ThreadId vg_tid)
 {
-   // HACK. To do: uncomment the line below.
-   // tl_assert(vg_tid != VG_INVALID_THREADID);
+   tl_assert(vg_tid != VG_INVALID_THREADID);
 
    if (vg_tid != s_vg_running_tid)
    {
@@ -447,10 +444,6 @@ void thread_set_vg_running_tid(const ThreadId vg_tid)
 
 void thread_set_running_tid(const ThreadId vg_tid, const DrdThreadId drd_tid)
 {
-   // HACK. To do: remove the next two lines.
-   if (vg_tid == VG_INVALID_THREADID)
-      return;
-
    tl_assert(vg_tid != VG_INVALID_THREADID);
    tl_assert(drd_tid != DRD_INVALID_THREADID);