summaryrefslogtreecommitdiff
path: root/coregrind/m_scheduler
diff options
context:
space:
mode:
authorsewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2006-12-23 01:21:12 +0000
committersewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2006-12-23 01:21:12 +0000
commit975618137c5e56cc8f633d5747727f26e2fbc90b (patch)
treec87d8d328cb53c99fc9662521632d58574945d08 /coregrind/m_scheduler
parentbf57ce7d35884056dfc780bd8755f03f21af3fa3 (diff)
Change the core-tool interface 'thread_run' event to be more useful:
- Rename the event to 'thread_runstate'. - Add arguments: pass also a boolean indicating whether the thread is running or stopping, and a 64-bit int showing how many blocks overall have run, so tools can make a rough estimate of workload. The boolean allows tools to see threads starting and stopping. Prior to this, de-schedule events were invisible to tools. - Call the callback (hand the event to tools) just before client code is run, and again immediately after it stops running. This should give correct sequencing w.r.t posting of thread creation/ destruction events. In order to make callgrind work without complex changes, I added a simple impedance-matching function 'clg_thread_runstate_callback' which hands thread-run events onwards to CLG_(thread_run). Use this new 'thread_runstate' with care: it will be called before and after every translation, which means it will be called ~500k times in a startup of firefox. So the callback needs to be fast. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6413 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'coregrind/m_scheduler')
-rw-r--r--coregrind/m_scheduler/scheduler.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c
index e439e499..27bff898 100644
--- a/coregrind/m_scheduler/scheduler.c
+++ b/coregrind/m_scheduler/scheduler.c
@@ -233,10 +233,6 @@ void VG_(acquire_BigLock)(ThreadId tid, HChar* who)
VG_(sprintf)(buf, " acquired lock (%s)", who);
print_sched_event(tid, buf);
}
-
- // While thre modeling is disable, issue thread_run events here
- // VG_(tm_thread_switchto)(tid);
- VG_TRACK( thread_run, tid );
}
/*
@@ -616,6 +612,9 @@ static UInt run_thread_for_a_while ( ThreadId tid )
VG_(printf)("\n");
}
+ // Tell the tool this thread is about to run client code
+ VG_TRACK( thread_runstate, tid, True, bbs_done );
+
vg_assert(VG_(in_generated_code) == False);
VG_(in_generated_code) = True;
@@ -641,6 +640,9 @@ static UInt run_thread_for_a_while ( ThreadId tid )
vg_assert(done_this_time >= 0);
bbs_done += (ULong)done_this_time;
+ // Tell the tool this thread has stopped running client code
+ VG_TRACK( thread_runstate, tid, False, bbs_done );
+
return trc;
}
@@ -652,6 +654,7 @@ static UInt run_noredir_translation ( Addr hcode, ThreadId tid )
volatile Int jumped;
volatile ThreadState* tst;
volatile UWord argblock[4];
+ volatile UInt retval;
/* Paranoia */
vg_assert(VG_(is_valid_tid)(tid));
@@ -686,6 +689,9 @@ static UInt run_noredir_translation ( Addr hcode, ThreadId tid )
argblock[2] = 0; /* next guest IP is written here */
argblock[3] = 0; /* guest state ptr afterwards is written here */
+ // Tell the tool this thread is about to run client code
+ VG_TRACK( thread_runstate, tid, True, bbs_done );
+
vg_assert(VG_(in_generated_code) == False);
VG_(in_generated_code) = True;
@@ -703,16 +709,23 @@ static UInt run_noredir_translation ( Addr hcode, ThreadId tid )
vg_assert(argblock[2] == 0); /* next guest IP was not written */
vg_assert(argblock[3] == 0); /* trc was not written */
block_signals(tid);
- return VG_TRC_FAULT_SIGNAL;
+ retval = VG_TRC_FAULT_SIGNAL;
} else {
/* store away the guest program counter */
VG_(set_IP)( tid, argblock[2] );
if (argblock[3] == argblock[1])
/* the guest state pointer afterwards was unchanged */
- return VG_TRC_BORING;
+ retval = VG_TRC_BORING;
else
- return (UInt)argblock[3];
+ retval = (UInt)argblock[3];
}
+
+ bbs_done++;
+
+ // Tell the tool this thread has stopped running client code
+ VG_TRACK( thread_runstate, tid, False, bbs_done );
+
+ return retval;
}