Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Issue 2774001: posix: set thread names (Closed)

Created:
10 years, 6 months ago by Evan Martin
Modified:
9 years, 7 months ago
CC:
chromium-reviews, John Grabowski, pam+watch_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

posix: set thread names There's a non-portable function for doing this: pthread_setname_np. It's supported by OS X >= 10.6 and the Xcode debugger will show the thread names if they're provided. On Linux, support has just recently been added to glibc for the same function. Since OS coverage of the function is so spotty, we look for the symbol at runtime; on Linux we fall back to another implementation of the same functionality if the function isn't available. [reland of r49212, with Mac fixed and Linux disabled; see comments in code as to why Linux is disabled] Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=49465

Patch Set 1 #

Patch Set 2 : namespace #

Patch Set 3 : brakcet #

Patch Set 4 : better #

Total comments: 7

Patch Set 5 : errors #

Total comments: 5

Patch Set 6 : split #

Total comments: 2

Patch Set 7 : disable linux #

Unified diffs Side-by-side diffs Delta from patch set Stats (+71 lines, -8 lines) Patch
M base/platform_thread_mac.mm View 6 2 chunks +21 lines, -0 lines 0 comments Download
M base/platform_thread_posix.cc View 1 2 3 4 5 6 3 chunks +50 lines, -8 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Evan Martin
10 years, 6 months ago (2010-06-08 18:53:09 UTC) #1
Markus (顧孟勤)
LGTM Can you check what it does to the renderers? The mangling of the commandline ...
10 years, 6 months ago (2010-06-08 19:03:02 UTC) #2
Mark Mentovai
http://codereview.chromium.org/2774001/diff/2002/6001 File base/platform_thread_posix.cc (right): http://codereview.chromium.org/2774001/diff/2002/6001#newcode8 base/platform_thread_posix.cc:8: #include <dlfcn.h> dlfcn.h < errno.h http://codereview.chromium.org/2774001/diff/2002/6001#newcode16 base/platform_thread_posix.cc:16: #include <sys/syscall.h> ...
10 years, 6 months ago (2010-06-08 19:06:20 UTC) #3
Evan Martin
Ok, new patch up, still going through trybots. http://codereview.chromium.org/2774001/diff/2002/6001 File base/platform_thread_posix.cc (right): http://codereview.chromium.org/2774001/diff/2002/6001#newcode91 base/platform_thread_posix.cc:91: } ...
10 years, 6 months ago (2010-06-08 20:32:13 UTC) #4
Mark Mentovai
http://codereview.chromium.org/2774001/diff/11001/12001 File base/platform_thread_posix.cc (right): http://codereview.chromium.org/2774001/diff/11001/12001#newcode77 base/platform_thread_posix.cc:77: int (*dynamic_pthread_setname_np)(pthread_t, const char*); Uh-oh. On the Mac, this ...
10 years, 6 months ago (2010-06-08 20:38:10 UTC) #5
Evan Martin
http://codereview.chromium.org/2774001/diff/11001/12001 File base/platform_thread_posix.cc (right): http://codereview.chromium.org/2774001/diff/11001/12001#newcode77 base/platform_thread_posix.cc:77: int (*dynamic_pthread_setname_np)(pthread_t, const char*); On 2010/06/08 20:38:10, Mark Mentovai ...
10 years, 6 months ago (2010-06-08 20:46:12 UTC) #6
Evan Martin
The code paths now are more different than they're similar, so I split them into ...
10 years, 6 months ago (2010-06-08 21:09:50 UTC) #7
Mark Mentovai
10 years, 6 months ago (2010-06-08 22:15:42 UTC) #8
Finally. LGTM. Except you still need to provide a no-op implementation for the
non-Linux-non-Mac guys.

http://codereview.chromium.org/2774001/diff/16001/17002
File base/platform_thread_posix.cc (right):

http://codereview.chromium.org/2774001/diff/16001/17002#newcode94
base/platform_thread_posix.cc:94: // don't do the name length clipping as above
because empirically
When I read “empirical” in conjunction with something open-source like “Linux
kernel,” I think “why are you satisfied with that?”

I checked and the kernel is safe and will handle truncation for you.
2.6.34/kernel/sys.c, for example. The limit is 16 - 1 (for '\0'), TASK_COMM_LEN
from include/linux/sched.h. I hate how the world has all these definitions of
the same constant all over the place.

http://codereview.chromium.org/2774001/diff/16001/17002#newcode101
base/platform_thread_posix.cc:101: #endif  // defined(OS_LINUX)
If not Linux and not Mac, there should still be an empty definition of this
function.

Powered by Google App Engine
This is Rietveld 408576698