Moved VG_(first_matching_thread_stack), removing m_threadstate's dependency
on m_machine.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3983 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c
index 71c41b5..a92d15d 100644
--- a/coregrind/m_machine.c
+++ b/coregrind/m_machine.c
@@ -178,7 +178,23 @@
}
}
+// 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 b38642b..6c426bd 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 @@
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 46ff9d6..a707b5f 100644
--- a/include/pub_tool_machine.h
+++ b/include/pub_tool_machine.h
@@ -74,6 +74,12 @@
// 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 439fec0..4dcb8de 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 16f387d..48090be 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