diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2013-10-29 10:30:39 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2013-10-29 10:30:39 +0000 |
commit | 5cf2c460e96e593b1c772f1b02d3a217f4837fdc (patch) | |
tree | e7cef32475ecf17e6d2a47f6a0f3d38286294ef1 /lib/sanitizer_common/sanitizer_thread_registry.cc | |
parent | 7996a2e2a1c461743c9216f13429c04d75050230 (diff) |
tsan/asan: support pthread_setname_np to set thread names
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_thread_registry.cc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_thread_registry.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_thread_registry.cc b/lib/sanitizer_common/sanitizer_thread_registry.cc index ff7c9de5c..bfa29a19c 100644 --- a/lib/sanitizer_common/sanitizer_thread_registry.cc +++ b/lib/sanitizer_common/sanitizer_thread_registry.cc @@ -200,6 +200,18 @@ void ThreadRegistry::SetThreadName(u32 tid, const char *name) { tctx->SetName(name); } +void ThreadRegistry::SetThreadNameByUserId(uptr user_id, const char *name) { + BlockingMutexLock l(&mtx_); + for (u32 tid = 0; tid < n_contexts_; tid++) { + ThreadContextBase *tctx = threads_[tid]; + if (tctx != 0 && tctx->user_id == user_id && + tctx->status != ThreadStatusInvalid) { + tctx->SetName(name); + return; + } + } +} + void ThreadRegistry::DetachThread(u32 tid) { BlockingMutexLock l(&mtx_); CHECK_LT(tid, n_contexts_); |