Bug 1122721 - Don't call pthread_get_stackaddr_np during sampling. r=mstange

--HG--
extra : commitid : REhZnhBQ3J
extra : rebase_source : bf4bbc42cb75faa5d2028340396873b78210e52b
This commit is contained in:
Benoit Girard 2015-08-25 18:03:32 -04:00
parent f50d3758bc
commit fb86861381
4 changed files with 26 additions and 15 deletions

View File

@ -950,10 +950,7 @@ void GeckoSampler::doNativeBacktrace(ThreadProfile &aProfile, TickSample* aSampl
uint32_t maxFrames = uint32_t(nativeStack.size - nativeStack.count);
#ifdef XP_MACOSX
pthread_t pt = GetProfiledThread(aSample->threadProfile->GetPlatformData());
void *stackEnd = reinterpret_cast<void*>(-1);
if (pt)
stackEnd = static_cast<char*>(pthread_get_stackaddr_np(pt));
void *stackEnd = aSample->threadProfile->GetStackTop();
bool rv = true;
if (aSample->fp >= aSample->sp && aSample->fp <= stackEnd)
rv = FramePointerStackWalk(StackWalkCallback, /* skipFrames */ 0,

View File

@ -1,3 +1,11 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "ThreadInfo.h"
#include "ThreadProfile.h"
ThreadInfo::ThreadInfo(const char* aName, int aThreadId,
bool aIsMainThread, PseudoStack* aPseudoStack,
@ -14,6 +22,12 @@ ThreadInfo::ThreadInfo(const char* aName, int aThreadId,
#ifndef SPS_STANDALONE
mThread = NS_GetCurrentThread();
#endif
// We don't have to guess on mac
#ifdef XP_MACOSX
pthread_t self = pthread_self();
mStackTop = pthread_get_stackaddr_np(self);
#endif
}
ThreadInfo::~ThreadInfo() {

View File

@ -47,7 +47,7 @@ class ThreadInfo {
PseudoStack* mPseudoStack;
PlatformData* mPlatformData;
ThreadProfile* mProfile;
void* const mStackTop;
void* mStackTop;
#ifndef SPS_STANDALONE
nsCOMPtr<nsIThread> mThread;
#endif

View File

@ -281,18 +281,18 @@ class ThreadProfile;
class TickSample {
public:
TickSample()
:
pc(NULL),
sp(NULL),
fp(NULL),
: pc(NULL)
, sp(NULL)
, fp(NULL)
#ifdef ENABLE_ARM_LR_SAVING
lr(NULL),
, lr(NULL)
#endif
context(NULL),
isSamplingCurrentThread(false),
threadProfile(nullptr),
rssMemory(0),
ussMemory(0) {}
, context(NULL)
, isSamplingCurrentThread(false)
, threadProfile(nullptr)
, rssMemory(0)
, ussMemory(0)
{}
void PopulateContext(void* aContext);