Mega-merge of my last 2 weeks hacking. This basically does the groundwork
for pthread_* support. Major changes:
* Valgrind now contains a (skeletal!) user-space pthreads
implementation. The exciting bits are in new file vg_scheduler.c.
This contains thread management and scheduling, including nasty crud
to do with making some syscalls (read,write,nanosleep) nonblocking.
Also implementation of pthread_ functions: create join
mutex_{create,destroy,lock,unlock} and cancel.
* As a side effect of the above, major improvements to signal handling
and to the client-request machinery. This is now used to intercept
malloc/free etc too; the hacky way this is done before is gone.
Another side effect is that vg_dispatch.S is greatly simplified.
Also, the horrible hacks to do with delivering signals to threads
blocked in syscalls are gone, since the new mechanisms cover this case
easily.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@52 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/vg_constants.h b/vg_constants.h
index ef48ef0..b1b1b32 100644
--- a/vg_constants.h
+++ b/vg_constants.h
@@ -50,23 +50,18 @@
#define VGP_(str) VGAPPEND(vgProf_,str)
#define VGOFF_(str) VGAPPEND(vgOff_,str)
-/* Reasons why the inner simulation loop might stop (i.e. why has
- vg_dispatch_ctr reached zero? */
-#define VG_Y_SIGCHECK 0 /* signal check due */
-#define VG_Y_SMC 1 /* write to code detected */
-#define VG_Y_EXIT 2 /* natural or debug end to simulation */
-#define VG_Y_TRANSLATE 3 /* translation of vg_m_eip needed */
-/* Check for pending signals every this-many jumps. Since this
- happens in the region of once per millisecond, we also take the
- opportunity do do a bit of quick sanity checking at the same time.
- Look at the call sites of VG_(deliver_signals). */
-#define VG_SIGCHECK_INTERVAL 1000
-
-/* A ,agic values that %ebp might be set to when returning to the
+/* Magic values that %ebp might be set to when returning to the
dispatcher. The only other legitimate value is to point to the
- start of VG_(baseBlock). */
-#define VG_EBP_DISPATCH_CHECKED 17
+ start of VG_(baseBlock). These also are return values from
+ VG_(run_innerloop) to the scheduler. */
+#define VG_TRC_EBP_JMP_SPECIAL 17
+#define VG_TRC_EBP_JMP_SYSCALL 19
+#define VG_TRC_EBP_JMP_CLIENTREQ 23
+
+#define VG_TRC_INNER_COUNTERZERO 29 /* ebp can't have this; sched return only */
+#define VG_TRC_INNER_FASTMISS 31 /* ditto. Means fast-cache miss. */
+#define VG_TRC_UNRESUMABLE_SIGNAL 37 /* ditto; got sigsegv/sigbus */
/* Debugging hack for assembly code ... sigh. */
#if 0
@@ -75,12 +70,13 @@
#define OYNK(nnn)
#endif
-#if 1
+#if 0
#define OYNNK(nnn) pushal; pushl $nnn; call VG_(oynk) ; addl $4,%esp; popal
#else
#define OYNNK(nnn)
#endif
+
/* Constants for the fast translation lookup cache. */
#define VG_TT_FAST_BITS 15
#define VG_TT_FAST_SIZE (1 << VG_TT_FAST_BITS)
@@ -88,6 +84,7 @@
/* Constants for the fast original-code-write check cache. */
+
/* Usually you want this to be zero. */
#define VG_SMC_FASTCHECK_IN_C 0