summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorrbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 19:40:03 +0000
committerrbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 19:40:03 +0000
commitf6fa051e3747f04245e3b28b041286c57235145b (patch)
tree709afe9ad39100e56683cbfd1e58a7d8c3dd2d53 /base
parentd030986aeece4dc8eaf8cb04ce3609a6437b3bff (diff)
downloadchromium_src-f6fa051e3747f04245e3b28b041286c57235145b.zip
chromium_src-f6fa051e3747f04245e3b28b041286c57235145b.tar.gz
chromium_src-f6fa051e3747f04245e3b28b041286c57235145b.tar.bz2
Enable setting thread names on Linux
BUG=107547 TEST=Manual Review URL: http://codereview.chromium.org/8936015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/threading/platform_thread_posix.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 872cb56..9b80af4 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -166,11 +166,7 @@ void PlatformThread::Sleep(int duration_ms) {
sleep_time = remaining;
}
-// Linux SetName is currently disabled, as we need to distinguish between
-// helper threads (where it's ok to make this call) and the main thread
-// (where making this call renames our process, causing tools like killall
-// to stop working).
-#if 0 && defined(OS_LINUX)
+#if defined(OS_LINUX)
// static
void PlatformThread::SetName(const char* name) {
// have to cast away const because ThreadLocalPointer does not support const
@@ -178,6 +174,13 @@ void PlatformThread::SetName(const char* name) {
current_thread_name.Pointer()->Set(const_cast<char*>(name));
tracked_objects::ThreadData::InitializeThreadContext(name);
+ // On linux 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;
+
// http://0pointer.de/blog/projects/name-your-threads.html
// glibc recently added support for pthread_setname_np, but it's not