|
From: <sv...@va...> - 2007-09-09 21:41:27
|
Author: sewardj
Date: 2007-09-09 22:41:28 +0100 (Sun, 09 Sep 2007)
New Revision: 6805
Log:
Modify two thread-notification events in the core-tool interface.
This removes track_post_thread_create and track_post_thread_join. The
core can only see low level thread creation and exiting, and has no
idea about pthread-level concepts like "pthread_create" and
"pthread_join", so these are a bit ambiguous.
Replace them with track_pre_thread_ll_create, which is notified before
a new thread makes any memory references, and
track_pre_thread_ll_exit, which is notified just before the new thread
exits, that is, after it has made its last memory reference.
Modified:
branches/THRCHECK/coregrind/m_syswrap/syswrap-amd64-linux.c
branches/THRCHECK/coregrind/m_syswrap/syswrap-linux.c
branches/THRCHECK/coregrind/m_syswrap/syswrap-x86-linux.c
branches/THRCHECK/coregrind/m_tooliface.c
branches/THRCHECK/coregrind/pub_core_tooliface.h
Modified: branches/THRCHECK/coregrind/m_syswrap/syswrap-amd64-linux.c
===================================================================
--- branches/THRCHECK/coregrind/m_syswrap/syswrap-amd64-linux.c 2007-09-09 21:34:23 UTC (rev 6804)
+++ branches/THRCHECK/coregrind/m_syswrap/syswrap-amd64-linux.c 2007-09-09 21:41:28 UTC (rev 6805)
@@ -267,6 +267,12 @@
ctst->client_stack_szB = 0;
}
+ /* Assume the clone will succeed, and tell any tool that wants to
+ know that this thread has come into existence. If the clone
+ fails, we'll send out a ll_exit notification for it at the out:
+ label below, to clean up. */
+ VG_TRACK ( pre_thread_ll_create, ptid, ctid );
+
if (flags & VKI_CLONE_SETTLS) {
if (debug)
VG_(printf)("clone child has SETTLS: tls at %p\n", tlsaddr);
@@ -292,6 +298,8 @@
/* clone failed */
VG_(cleanup_thread)(&ctst->arch);
ctst->status = VgTs_Empty;
+ /* oops. Better tell the tool the thread exited in a hurry :-) */
+ VG_TRACK( pre_thread_ll_exit, ctid );
}
return res;
Modified: branches/THRCHECK/coregrind/m_syswrap/syswrap-linux.c
===================================================================
--- branches/THRCHECK/coregrind/m_syswrap/syswrap-linux.c 2007-09-09 21:34:23 UTC (rev 6804)
+++ branches/THRCHECK/coregrind/m_syswrap/syswrap-linux.c 2007-09-09 21:41:28 UTC (rev 6805)
@@ -78,8 +78,6 @@
VG_(printf)("thread tid %d started: stack = %p\n",
tid, &tid);
- VG_TRACK ( post_thread_create, tst->os_state.parent, tid );
-
tst->os_state.lwpid = VG_(gettid)();
tst->os_state.threadgroup = VG_(getpid)();
@@ -128,6 +126,9 @@
c = VG_(count_living_threads)();
vg_assert(c >= 1); /* stay sane */
+ // Tell the tool this thread is exiting
+ VG_TRACK( pre_thread_ll_exit, tid );
+
if (c == 1) {
VG_(debugLog)(1, "syswrap-linux",
Modified: branches/THRCHECK/coregrind/m_syswrap/syswrap-x86-linux.c
===================================================================
--- branches/THRCHECK/coregrind/m_syswrap/syswrap-x86-linux.c 2007-09-09 21:34:23 UTC (rev 6804)
+++ branches/THRCHECK/coregrind/m_syswrap/syswrap-x86-linux.c 2007-09-09 21:41:28 UTC (rev 6805)
@@ -279,6 +279,15 @@
ctst->client_stack_szB = 0;
}
+ /* Assume the clone will succeed, and tell any tool that wants to
+ know that this thread has come into existence. We cannot defer
+ it beyond this point because sys_set_thread_area, just below,
+ causes tCheck to assert by making references to the new ThreadId
+ if we don't state the new thread exists prior to that point.
+ If the clone fails, we'll send out a ll_exit notification for it
+ at the out: label below, to clean up. */
+ VG_TRACK ( pre_thread_ll_create, ptid, ctid );
+
if (flags & VKI_CLONE_SETTLS) {
if (debug)
VG_(printf)("clone child has SETTLS: tls info at %p: idx=%d "
@@ -311,6 +320,8 @@
/* clone failed */
VG_(cleanup_thread)(&ctst->arch);
ctst->status = VgTs_Empty;
+ /* oops. Better tell the tool the thread exited in a hurry :-) */
+ VG_TRACK( pre_thread_ll_exit, ctid );
}
return res;
Modified: branches/THRCHECK/coregrind/m_tooliface.c
===================================================================
--- branches/THRCHECK/coregrind/m_tooliface.c 2007-09-09 21:34:23 UTC (rev 6804)
+++ branches/THRCHECK/coregrind/m_tooliface.c 2007-09-09 21:41:28 UTC (rev 6805)
@@ -332,8 +332,8 @@
DEF(track_start_client_code, ThreadId, ULong)
DEF(track_stop_client_code, ThreadId, ULong)
-DEF(track_post_thread_create, ThreadId, ThreadId)
-DEF(track_post_thread_join, ThreadId, ThreadId)
+DEF(track_pre_thread_ll_create, ThreadId, ThreadId)
+DEF(track_pre_thread_ll_exit, ThreadId)
DEF(track_pre_deliver_signal, ThreadId, Int sigNo, Bool)
DEF(track_post_deliver_signal, ThreadId, Int sigNo)
Modified: branches/THRCHECK/coregrind/pub_core_tooliface.h
===================================================================
--- branches/THRCHECK/coregrind/pub_core_tooliface.h 2007-09-09 21:34:23 UTC (rev 6804)
+++ branches/THRCHECK/coregrind/pub_core_tooliface.h 2007-09-09 21:41:28 UTC (rev 6805)
@@ -207,8 +207,8 @@
void (*track_start_client_code)(ThreadId, ULong);
void (*track_stop_client_code) (ThreadId, ULong);
- void (*track_post_thread_create)(ThreadId, ThreadId);
- void (*track_post_thread_join) (ThreadId, ThreadId);
+ void (*track_pre_thread_ll_create)(ThreadId, ThreadId);
+ void (*track_pre_thread_ll_exit) (ThreadId);
void (*track_pre_deliver_signal) (ThreadId, Int sigNo, Bool);
void (*track_post_deliver_signal)(ThreadId, Int sigNo);
|