|
From: <sv...@va...> - 2007-09-16 11:08:54
|
Author: sewardj
Date: 2007-09-16 12:08:56 +0100 (Sun, 16 Sep 2007)
New Revision: 6833
Log:
Track vex r1789 (add IR notification of hardware bus lock/unlock).
* Remove tool handling of IRStmt_MFence and replace by IRStmt_MBE
* In Thrcheck, generate calls to evim__bus_lock/unlock when
IRStmt_MBE(BusLock/BusUnlock) are observed. This provides at least
partially correct handling for x86/amd64 LOCK prefixed instructions.
Modified:
branches/THRCHECK/cachegrind/cg_main.c
branches/THRCHECK/callgrind/main.c
branches/THRCHECK/lackey/lk_main.c
branches/THRCHECK/memcheck/mc_translate.c
branches/THRCHECK/thrcheck/tc_main.c
branches/THRCHECK/thrcheck/tests/tc08_hbl2.stdout.exp
Modified: branches/THRCHECK/cachegrind/cg_main.c
===================================================================
--- branches/THRCHECK/cachegrind/cg_main.c 2007-09-14 09:06:43 UTC (rev 6832)
+++ branches/THRCHECK/cachegrind/cg_main.c 2007-09-16 11:08:56 UTC (rev 6833)
@@ -952,7 +952,7 @@
case Ist_AbiHint:
case Ist_Put:
case Ist_PutI:
- case Ist_MFence:
+ case Ist_MBE:
break;
case Ist_IMark:
Modified: branches/THRCHECK/callgrind/main.c
===================================================================
--- branches/THRCHECK/callgrind/main.c 2007-09-14 09:06:43 UTC (rev 6832)
+++ branches/THRCHECK/callgrind/main.c 2007-09-16 11:08:56 UTC (rev 6833)
@@ -468,7 +468,7 @@
case Ist_Put:
case Ist_PutI:
- case Ist_MFence:
+ case Ist_MBE:
case Ist_Exit:
break;
Modified: branches/THRCHECK/lackey/lk_main.c
===================================================================
--- branches/THRCHECK/lackey/lk_main.c 2007-09-14 09:06:43 UTC (rev 6832)
+++ branches/THRCHECK/lackey/lk_main.c 2007-09-16 11:08:56 UTC (rev 6833)
@@ -670,7 +670,7 @@
case Ist_AbiHint:
case Ist_Put:
case Ist_PutI:
- case Ist_MFence:
+ case Ist_MBE:
addStmtToIRSB( sbOut, st );
break;
Modified: branches/THRCHECK/memcheck/mc_translate.c
===================================================================
--- branches/THRCHECK/memcheck/mc_translate.c 2007-09-14 09:06:43 UTC (rev 6832)
+++ branches/THRCHECK/memcheck/mc_translate.c 2007-09-16 11:08:56 UTC (rev 6833)
@@ -3290,7 +3290,7 @@
return isBogusAtom(st->Ist.AbiHint.base);
case Ist_NoOp:
case Ist_IMark:
- case Ist_MFence:
+ case Ist_MBE:
return False;
default:
unhandled:
@@ -3470,7 +3470,7 @@
case Ist_NoOp:
case Ist_IMark:
- case Ist_MFence:
+ case Ist_MBE:
break;
case Ist_Dirty:
Modified: branches/THRCHECK/thrcheck/tc_main.c
===================================================================
--- branches/THRCHECK/thrcheck/tc_main.c 2007-09-14 09:06:43 UTC (rev 6832)
+++ branches/THRCHECK/thrcheck/tc_main.c 2007-09-16 11:08:56 UTC (rev 6833)
@@ -3565,6 +3565,35 @@
}
+static void instrument_memory_bus_event ( IRSB* bbOut, IRMBusEvent event )
+{
+ switch (event) {
+ case Imbe_Fence:
+ break; /* not interesting */
+ case Imbe_BusLock:
+ case Imbe_BusUnlock:
+ addStmtToIRSB(
+ bbOut,
+ IRStmt_Dirty(
+ unsafeIRDirty_0_N(
+ 0/*regparms*/,
+ event == Imbe_BusLock ? "evim__bus_lock"
+ : "evim__bus_unlock",
+ VG_(fnptr_to_fnentry)(
+ event == Imbe_BusLock ? &evim__bus_lock
+ : &evim__bus_unlock
+ ),
+ mkIRExprVec_0()
+ )
+ )
+ );
+ break;
+ default:
+ tl_assert(0);
+ }
+ }
+
+
static
IRSB* tc_instrument ( VgCallbackClosure* closure,
IRSB* bbIn,
@@ -3602,12 +3631,15 @@
case Ist_AbiHint:
case Ist_Put:
case Ist_PutI:
- case Ist_MFence:
case Ist_IMark:
case Ist_Exit:
/* None of these can contain any memory references. */
break;
+ case Ist_MBE:
+ instrument_memory_bus_event( bbOut, st->Ist.MBE.event );
+ break;
+
case Ist_Store:
instrument_mem_access(
bbOut,
@@ -3725,7 +3757,7 @@
if (0)
VG_(printf)("SET_MY_PTHREAD_T (tid %d): pthread_t = %p\n", (Int)tid,
(void*)args[1]);
- map_pthread_t_to_Thread_INIT();
+ map_pthread_t_to_Thread_INIT();
my_thr = map_threads_maybe_lookup( tid );
/* This assertion should hold because the map_threads (tid to
Thread*) binding should have been made at the point of
@@ -3762,7 +3794,7 @@
if (0)
VG_(printf)("NOTIFY_JOIN_COMPLETE (tid %d): quitter = %p\n", (Int)tid,
(void*)args[1]);
- map_pthread_t_to_Thread_INIT();
+ map_pthread_t_to_Thread_INIT();
found = TC_(lookupFM)( map_pthread_t_to_Thread,
NULL, (Word*)&thr_q, (Word)args[1] );
/* Can this fail? It would mean that our pthread_join
@@ -3824,7 +3856,7 @@
break;
/* Thread successfully completed pthread_cond_wait, cond=arg[1],
- mutex=arg[2] */
+ mutex=arg[2] */
case _VG_USERREQ__TC_PTHREAD_COND_WAIT_POST:
evim__TC_PTHREAD_COND_WAIT_POST( tid,
(void*)args[1], (void*)args[2] );
Modified: branches/THRCHECK/thrcheck/tests/tc08_hbl2.stdout.exp
===================================================================
--- branches/THRCHECK/thrcheck/tests/tc08_hbl2.stdout.exp 2007-09-14 09:06:43 UTC (rev 6832)
+++ branches/THRCHECK/thrcheck/tests/tc08_hbl2.stdout.exp 2007-09-16 11:08:56 UTC (rev 6833)
@@ -1,10 +1,3 @@
-child: new value 1
-child: new value 2
-child: new value 3
-child: new value 4
-child: new value 5
child: new value 6
-child: new value 7
-child: new value 8
-child: new value 9
child: new value 10
+done, x = 10
|