Skip to content

Commit

Permalink
Bug 1360575: Use PR_SetCurrentThreadName to set the sampler thread's …
Browse files Browse the repository at this point in the history
…name on all platforms. r=mstange
  • Loading branch information
David Major committed May 2, 2017
1 parent facb121 commit f7b2b25
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
2 changes: 0 additions & 2 deletions tools/profiler/core/platform-linux-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/prctl.h> // set name
#include <stdlib.h>
#include <sched.h>
#include <ucontext.h>
Expand Down Expand Up @@ -273,7 +272,6 @@ static void*
ThreadEntry(void* aArg)
{
auto thread = static_cast<SamplerThread*>(aArg);
prctl(PR_SET_NAME, "SamplerThread", 0, 0, 0);
thread->mSamplerTid = gettid();
thread->Run();
return nullptr;
Expand Down
17 changes: 0 additions & 17 deletions tools/profiler/core/platform-macos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <dlfcn.h>
#include <unistd.h>
#include <sys/mman.h>
#include <mach/mach_init.h>
#include <mach-o/dyld.h>
#include <mach-o/getsect.h>

#include <AvailabilityMacros.h>
Expand Down Expand Up @@ -78,25 +76,10 @@ class PlatformData
////////////////////////////////////////////////////////////////////////
// BEGIN SamplerThread target specifics

static void
SetThreadName()
{
// pthread_setname_np is only available in 10.6 or later, so test
// for it at runtime.
int (*dynamic_pthread_setname_np)(const char*);
*reinterpret_cast<void**>(&dynamic_pthread_setname_np) =
dlsym(RTLD_DEFAULT, "pthread_setname_np");
if (!dynamic_pthread_setname_np)
return;

dynamic_pthread_setname_np("SamplerThread");
}

static void*
ThreadEntry(void* aArg)
{
auto thread = static_cast<SamplerThread*>(aArg);
SetThreadName();
thread->Run();
return nullptr;
}
Expand Down
2 changes: 2 additions & 0 deletions tools/profiler/core/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,8 @@ NewSamplerThread(PSLockRef aLock, uint32_t aGeneration, double aInterval)
void
SamplerThread::Run()
{
PR_SetCurrentThreadName("SamplerThread");

// This will be positive if we are running behind schedule (sampling less
// frequently than desired) and negative if we are ahead of schedule.
TimeDuration lastSleepOvershoot = 0;
Expand Down

0 comments on commit f7b2b25

Please sign in to comment.