From cadc28816d1eb59c0f7b497508fe6d5304ab10ec Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 24 Dec 2006 07:51:17 +0000 Subject: [PATCH] Split the thread_runstate event into two, start_client_code and stop_client_code, which is a bit clearer and easier to work with. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6418 --- callgrind/main.c | 15 +++++---------- coregrind/m_scheduler/scheduler.c | 8 ++++---- coregrind/m_tooliface.c | 3 ++- coregrind/pub_core_tooliface.h | 3 ++- include/pub_tool_tooliface.h | 26 +++++++++++++------------- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/callgrind/main.c b/callgrind/main.c index 5b31e90323..00646629c3 100644 --- a/callgrind/main.c +++ b/callgrind/main.c @@ -1022,17 +1022,12 @@ void CLG_(fini)(Int exitcode) /*--- Setup ---*/ /*--------------------------------------------------------------------*/ -static void clg_thread_runstate_callback ( ThreadId tid, - Bool is_running, - ULong blocks_done ) +static void clg_start_client_code_callback ( ThreadId tid, ULong blocks_done ) { static ULong last_blocks_done = 0; if (0) - VG_(printf)("%d %c %llu\n", - (Int)tid, is_running ? 'R' : 's', blocks_done); - - if (!is_running) return; + VG_(printf)("%d R %llu\n", (Int)tid, blocks_done); /* throttle calls to CLG_(run_thread) by number of BBs executed */ if (blocks_done - last_blocks_done < 5000) return; @@ -1107,9 +1102,9 @@ void CLG_(pre_clo_init)(void) VG_(needs_syscall_wrapper)(CLG_(pre_syscalltime), CLG_(post_syscalltime)); - VG_(track_thread_runstate) ( & clg_thread_runstate_callback ); - VG_(track_pre_deliver_signal) ( & CLG_(pre_signal) ); - VG_(track_post_deliver_signal) ( & CLG_(post_signal) ); + VG_(track_start_client_code) ( & clg_start_client_code_callback ); + VG_(track_pre_deliver_signal) ( & CLG_(pre_signal) ); + VG_(track_post_deliver_signal)( & CLG_(post_signal) ); CLG_(set_clo_defaults)(); } diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 27bff8989d..cb8fc0f423 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -613,7 +613,7 @@ static UInt run_thread_for_a_while ( ThreadId tid ) } // Tell the tool this thread is about to run client code - VG_TRACK( thread_runstate, tid, True, bbs_done ); + VG_TRACK( start_client_code, tid, bbs_done ); vg_assert(VG_(in_generated_code) == False); VG_(in_generated_code) = True; @@ -641,7 +641,7 @@ static UInt run_thread_for_a_while ( ThreadId tid ) bbs_done += (ULong)done_this_time; // Tell the tool this thread has stopped running client code - VG_TRACK( thread_runstate, tid, False, bbs_done ); + VG_TRACK( stop_client_code, tid, bbs_done ); return trc; } @@ -690,7 +690,7 @@ static UInt run_noredir_translation ( Addr hcode, ThreadId tid ) 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_TRACK( start_client_code, tid, bbs_done ); vg_assert(VG_(in_generated_code) == False); VG_(in_generated_code) = True; @@ -723,7 +723,7 @@ static UInt run_noredir_translation ( Addr hcode, ThreadId tid ) bbs_done++; // Tell the tool this thread has stopped running client code - VG_TRACK( thread_runstate, tid, False, bbs_done ); + VG_TRACK( stop_client_code, tid, bbs_done ); return retval; } diff --git a/coregrind/m_tooliface.c b/coregrind/m_tooliface.c index cb0bef9943..6d4f2437a3 100644 --- a/coregrind/m_tooliface.c +++ b/coregrind/m_tooliface.c @@ -321,7 +321,8 @@ DEF(track_post_reg_write, CorePart, ThreadId, OffT, SizeT) DEF(track_post_reg_write_clientcall_return, ThreadId, OffT, SizeT, Addr) -DEF(track_thread_runstate, ThreadId, Bool, ULong) +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) diff --git a/coregrind/pub_core_tooliface.h b/coregrind/pub_core_tooliface.h index f74f24e32a..a8151cdadd 100644 --- a/coregrind/pub_core_tooliface.h +++ b/coregrind/pub_core_tooliface.h @@ -200,7 +200,8 @@ typedef struct { void (*track_post_reg_write)(CorePart, ThreadId, OffT, SizeT); void (*track_post_reg_write_clientcall_return)(ThreadId, OffT, SizeT, Addr); - void (*track_thread_runstate)(ThreadId, Bool, ULong); + 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); diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h index 664a19dde9..f2f7c84534 100644 --- a/include/pub_tool_tooliface.h +++ b/include/pub_tool_tooliface.h @@ -539,16 +539,19 @@ void VG_(track_post_reg_write_clientcall_return)( /* Scheduler events (not exhaustive) */ /* Called when 'tid' starts or stops running client code blocks. - Gives the total dispatched block count at that event. Note, this - is not the same as 'tid' holding the BigLock: a thread can hold the - lock for other purposes (making translations, etc) yet not be - running client blocks. Obviously though, a thread must hold the - lock in order to run client code blocks, so the times bracketed by - thread_runstate(tid, True, ..) .. thread_runstate(tid, False, ..) - are a subset of the times when 'tid' holds the cpu lock. + Gives the total dispatched block count at that event. Note, this is + not the same as 'tid' holding the BigLock (the lock that ensures that + only one thread runs at a time): a thread can hold the lock for other + purposes (making translations, etc) yet not be running client blocks. + Obviously though, a thread must hold the lock in order to run client + code blocks, so the times bracketed by 'thread_run'..'thread_runstate' + are a subset of the times when thread 'tid' holds the cpu lock. */ -void VG_(track_thread_runstate)( - void(*f)(ThreadId tid, Bool running, ULong blocks_dispatched) +void VG_(track_start_client_code)( + void(*f)(ThreadId tid, ULong blocks_dispatched) + ); +void VG_(track_stop_client_code)( + void(*f)(ThreadId tid, ULong blocks_dispatched) ); @@ -560,6 +563,7 @@ void VG_(track_thread_runstate)( void VG_(track_post_thread_create)(void(*f)(ThreadId tid, ThreadId child)); void VG_(track_post_thread_join) (void(*f)(ThreadId joiner, ThreadId joinee)); + /* Mutex events (not exhaustive) "void *mutex" is really a pthread_mutex * @@ -587,10 +591,6 @@ void VG_(track_pre_deliver_signal) (void(*f)(ThreadId tid, Int sigNo, handler longjmps, this won't be called. */ void VG_(track_post_deliver_signal)(void(*f)(ThreadId tid, Int sigNo)); -/* Others... condition variables... - ... - */ - #endif // __PUB_TOOL_TOOLIFACE_H /*--------------------------------------------------------------------*/ -- 2.47.2