From: Tom Hughes Date: Wed, 2 Jan 2008 10:13:04 +0000 (+0000) Subject: Mark the main thread as running while the initial memory declarations X-Git-Tag: svn/VALGRIND_3_4_0~1118 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d3def869f3501ebfaf0725dd8451ccfb059346ac;p=thirdparty%2Fvalgrind.git 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 . git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7310 --- diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 3861cfb7a7..92401b7f22 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -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); } //-------------------------------------------------------------- diff --git a/exp-drd/drd_main.c b/exp-drd/drd_main.c index 12c0887e9e..d18b8b2d02 100644 --- a/exp-drd/drd_main.c +++ b/exp-drd/drd_main.c @@ -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); diff --git a/exp-drd/drd_thread.c b/exp-drd/drd_thread.c index 8ab9938f2e..4277e1b2ee 100644 --- a/exp-drd/drd_thread.c +++ b/exp-drd/drd_thread.c @@ -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);