diff options
author | apatole@nvidia.com <apatole@nvidia.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 14:17:25 +0000 |
---|---|---|
committer | apatole@nvidia.com <apatole@nvidia.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 14:17:25 +0000 |
commit | 7a59071263a540d6bc94df8eb09a3e8541414307 (patch) | |
tree | f7044cf5cb55df2d216a18804a279b706da0ce93 /base/threading | |
parent | 0c74c1f5431aeaa41acd263053a627aec8055e0c (diff) | |
download | chromium_src-7a59071263a540d6bc94df8eb09a3e8541414307.zip chromium_src-7a59071263a540d6bc94df8eb09a3e8541414307.tar.gz chromium_src-7a59071263a540d6bc94df8eb09a3e8541414307.tar.bz2 |
Set thread names to be visible in debuggers
Like linux, on android we can get the thread names to show up in the
debugger by setting the process name for the LWP.
This change sets the name of the calling thread using prctl.
BUG=332881
R=jam@chromium.org
R=torne@chromium.org
Review URL: https://codereview.chromium.org/144943004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250981 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading')
-rw-r--r-- | base/threading/platform_thread_android.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/base/threading/platform_thread_android.cc b/base/threading/platform_thread_android.cc index 0dbb191..bd0b4b3 100644 --- a/base/threading/platform_thread_android.cc +++ b/base/threading/platform_thread_android.cc @@ -5,6 +5,7 @@ #include "base/threading/platform_thread.h" #include <errno.h> +#include <sys/prctl.h> #include <sys/resource.h> #include "base/android/jni_android.h" @@ -77,6 +78,18 @@ void PlatformThread::SetThreadPriority(PlatformThreadHandle handle, void PlatformThread::SetName(const char* name) { ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); tracked_objects::ThreadData::InitializeThreadContext(name); + + // Like linux, on android we can get the thread names to show up in the + // debugger by setting the process name for the LWP. + // We don't want to do this for the main thread because that would rename + // the process, causing tools like killall to stop working. + if (PlatformThread::CurrentId() == getpid()) + return; + + // Set the name for the LWP (which gets truncated to 15 characters). + int err = prctl(PR_SET_NAME, name); + if (err < 0 && errno != EPERM) + DPLOG(ERROR) << "prctl(PR_SET_NAME)"; } |