From: Nicholas Nethercote Date: Tue, 21 Jun 2005 04:01:51 +0000 (+0000) Subject: Moved VG_(first_matching_thread_stack), removing m_threadstate's dependency X-Git-Tag: svn/VALGRIND_3_0_0~335 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c866712f82ad12c6f06f51125585fc686fd44151;p=thirdparty%2Fvalgrind.git Moved VG_(first_matching_thread_stack), removing m_threadstate's dependency on m_machine. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3983 --- diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index 71c41b5e5f..a92d15d18c 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -178,7 +178,23 @@ void VG_(apply_to_GP_regs)(void (*f)(UWord)) } } +// Try and identify a thread whose stack satisfies the predicate p, or +// return VG_INVALID_THREADID if none do. +ThreadId VG_(first_matching_thread_stack) + ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ), + void* d ) +{ + ThreadId tid; + + for (tid = 1; tid < VG_N_THREADS; tid++) { + if (VG_(threads)[tid].status == VgTs_Empty) continue; + if ( p ( VG_(get_SP)(tid), + VG_(threads)[tid].client_stack_highest_word, d ) ) + return tid; + } + return VG_INVALID_THREADID; +} /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_threadstate.c b/coregrind/m_threadstate.c index b38642bce3..6c426bdc2c 100644 --- a/coregrind/m_threadstate.c +++ b/coregrind/m_threadstate.c @@ -31,7 +31,6 @@ #include "pub_core_basics.h" #include "pub_core_threadstate.h" #include "pub_core_libcassert.h" -#include "pub_core_machine.h" // For VG_(get_SP) /*------------------------------------------------------------*/ /*--- Data structures. ---*/ @@ -123,26 +122,6 @@ ThreadId VG_(get_lwp_tid)(Int lwp) return VG_INVALID_THREADID; } -/* For constructing error messages only: try and identify a thread - whose stack satisfies the predicate p, or return VG_INVALID_THREADID - if none do. -*/ -ThreadId VG_(first_matching_thread_stack) - ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ), - void* d ) -{ - ThreadId tid; - - for (tid = 1; tid < VG_N_THREADS; tid++) { - if (VG_(threads)[tid].status == VgTs_Empty) continue; - - if ( p ( VG_(get_SP)(tid), - VG_(threads)[tid].client_stack_highest_word, d ) ) - return tid; - } - return VG_INVALID_THREADID; -} - /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/include/pub_tool_machine.h b/include/pub_tool_machine.h index 46ff9d66dd..a707b5faee 100644 --- a/include/pub_tool_machine.h +++ b/include/pub_tool_machine.h @@ -74,6 +74,12 @@ extern void VG_(set_shadow_regs_area) ( ThreadId tid, OffT guest_state_offset, // doing leak checking. extern void VG_(apply_to_GP_regs)(void (*f)(UWord val)); +// Searches through all thread stacks to see if any match. Returns +// VG_INVALID_THREADID if none match. +extern ThreadId VG_(first_matching_thread_stack) + ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ), + void* d ); + #endif // __PUB_TOOL_MACHINE_H /*--------------------------------------------------------------------*/ diff --git a/include/pub_tool_threadstate.h b/include/pub_tool_threadstate.h index 439fec0255..4dcb8dedba 100644 --- a/include/pub_tool_threadstate.h +++ b/include/pub_tool_threadstate.h @@ -46,12 +46,6 @@ /* Get the TID of the thread which currently has the CPU. */ extern ThreadId VG_(get_running_tid) ( void ); -/* Searches through all thread's stacks to see if any match. Returns - VG_INVALID_THREADID if none match. */ -extern ThreadId VG_(first_matching_thread_stack) - ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ), - void* d ); - #endif // __PUB_TOOL_THREADSTATE_H /*--------------------------------------------------------------------*/ diff --git a/massif/ms_main.c b/massif/ms_main.c index 16f387d470..48090be821 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -43,12 +43,12 @@ #include "pub_tool_libcmman.h" #include "pub_tool_libcprint.h" #include "pub_tool_libcproc.h" +#include "pub_tool_machine.h" #include "pub_tool_mallocfree.h" #include "pub_tool_options.h" #include "pub_tool_profile.h" #include "pub_tool_replacemalloc.h" #include "pub_tool_stacktrace.h" -#include "pub_tool_threadstate.h" #include "pub_tool_tooliface.h" #include "valgrind.h" // For {MALLOC,FREE}LIKE_BLOCK