[compiler-rt] r182728 - [sanitizer] Move FindThreadByOSIdLocked from lsan to sanitizer_common.
Sergey Matveev
earthdok at google.com
Mon May 27 03:35:51 PDT 2013
Author: smatveev
Date: Mon May 27 05:35:51 2013
New Revision: 182728
URL: http://llvm.org/viewvc/llvm-project?rev=182728&view=rev
Log:
[sanitizer] Move FindThreadByOSIdLocked from lsan to sanitizer_common.
Modified:
compiler-rt/trunk/lib/lsan/lsan_thread.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h
Modified: compiler-rt/trunk/lib/lsan/lsan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_thread.cc?rev=182728&r1=182727&r2=182728&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_thread.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_thread.cc Mon May 27 05:35:51 2013
@@ -106,18 +106,6 @@ ThreadContext *CurrentThreadContext() {
return (ThreadContext *)thread_registry->GetThreadLocked(GetCurrentThread());
}
-bool FindThreadByOsIdCallback(ThreadContextBase *tctx, void *arg) {
- return (tctx->os_id == (uptr)arg && tctx->status != ThreadStatusInvalid &&
- tctx->status != ThreadStatusDead);
-}
-
-ThreadContext *FindThreadByOsIDLocked(uptr os_id) {
- ThreadContextBase *tctx =
- thread_registry->FindThreadContextLocked(FindThreadByOsIdCallback,
- (void*)os_id);
- return static_cast<ThreadContext *>(tctx);
-}
-
static bool FindThreadByUid(ThreadContextBase *tctx, void *arg) {
uptr uid = (uptr)arg;
if (tctx->user_id == uid && tctx->status != ThreadStatusInvalid) {
@@ -140,9 +128,9 @@ void ThreadJoin(u32 tid) {
bool GetThreadRangesLocked(uptr os_id, uptr *stack_begin, uptr *stack_end,
uptr *tls_begin, uptr *tls_end,
uptr *cache_begin, uptr *cache_end) {
- ThreadContext *context = FindThreadByOsIDLocked(os_id);
- if (!context)
- return false;
+ ThreadContext *context = static_cast<ThreadContext *>(
+ thread_registry->FindThreadContextByOsIDLocked(os_id));
+ if (!context) return false;
*stack_begin = context->stack_begin();
*stack_end = context->stack_end();
*tls_begin = context->tls_begin();
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.cc?rev=182728&r1=182727&r2=182728&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.cc Mon May 27 05:35:51 2013
@@ -180,6 +180,17 @@ ThreadRegistry::FindThreadContextLocked(
return 0;
}
+static bool FindThreadContextByOsIdCallback(ThreadContextBase *tctx,
+ void *arg) {
+ return (tctx->os_id == (uptr)arg && tctx->status != ThreadStatusInvalid &&
+ tctx->status != ThreadStatusDead);
+}
+
+ThreadContextBase *ThreadRegistry::FindThreadContextByOsIDLocked(uptr os_id) {
+ return FindThreadContextLocked(FindThreadContextByOsIdCallback,
+ (void *)os_id);
+}
+
void ThreadRegistry::SetThreadName(u32 tid, const char *name) {
BlockingMutexLock l(&mtx_);
CHECK_LT(tid, n_contexts_);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h?rev=182728&r1=182727&r2=182728&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h Mon May 27 05:35:51 2013
@@ -102,10 +102,11 @@ class ThreadRegistry {
// Finds a thread using the provided callback. Returns kUnknownTid if no
// thread is found.
u32 FindThread(FindThreadCallback cb, void *arg);
- // Should be guarded by ThreadRegistryLock. Returns 0 if no thread
+ // Should be guarded by ThreadRegistryLock. Return 0 if no thread
// is found.
ThreadContextBase *FindThreadContextLocked(FindThreadCallback cb,
void *arg);
+ ThreadContextBase *FindThreadContextByOsIDLocked(uptr os_id);
void SetThreadName(u32 tid, const char *name);
void DetachThread(u32 tid);
More information about the llvm-commits
mailing list