|
From: <sv...@va...> - 2008-01-02 10:13:05
|
Author: tom
Date: 2008-01-02 10:13:04 +0000 (Wed, 02 Jan 2008)
New Revision: 7310
Log:
Mark the main thread as running while the initial memory declarations
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 <bar...@gm...>.
Modified:
trunk/coregrind/m_main.c
trunk/exp-drd/drd_main.c
trunk/exp-drd/drd_thread.c
Modified: trunk/coregrind/m_main.c
===================================================================
--- trunk/coregrind/m_main.c 2008-01-02 10:07:44 UTC (rev 7309)
+++ trunk/coregrind/m_main.c 2008-01-02 10:13:04 UTC (rev 7310)
@@ -1763,6 +1763,12 @@
{ 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 @@
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);
}
//--------------------------------------------------------------
Modified: trunk/exp-drd/drd_main.c
===================================================================
--- trunk/exp-drd/drd_main.c 2008-01-02 10:07:44 UTC (rev 7309)
+++ trunk/exp-drd/drd_main.c 2008-01-02 10:13:04 UTC (rev 7310)
@@ -321,13 +321,6 @@
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);
Modified: trunk/exp-drd/drd_thread.c
===================================================================
--- trunk/exp-drd/drd_thread.c 2008-01-02 10:07:44 UTC (rev 7309)
+++ trunk/exp-drd/drd_thread.c 2008-01-02 10:13:04 UTC (rev 7310)
@@ -424,17 +424,14 @@
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_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);
|