[sanitizer] Move FindThreadByOSIdLocked from lsan to sanitizer_common.
llvm-svn: 182728
This commit is contained in:
parent
9c2bcf8c15
commit
9cda3df8bd
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -180,6 +180,17 @@ ThreadRegistry::FindThreadContextLocked(FindThreadCallback cb, void *arg) {
|
|||
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_);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue