Bug 810526 - Add stack top to Thread{Info,Profile}. r=bgirard

This commit is contained in:
Jed Davis 2013-09-11 14:50:46 -04:00
parent fc1b087589
commit d24d6515c1
8 changed files with 21 additions and 9 deletions

View File

@ -138,7 +138,7 @@ std::ostream& operator<<(std::ostream& stream, const ProfileEntry& entry)
ThreadProfile::ThreadProfile(const char* aName, int aEntrySize,
PseudoStack *aStack, int aThreadId,
PlatformData* aPlatform,
bool aIsMainThread)
bool aIsMainThread, void *aStackTop)
: mWritePos(0)
, mLastFlushPos(0)
, mReadPos(0)
@ -149,6 +149,7 @@ ThreadProfile::ThreadProfile(const char* aName, int aEntrySize,
, mThreadId(aThreadId)
, mIsMainThread(aIsMainThread)
, mPlatformData(aPlatform)
, mStackTop(aStackTop)
{
mEntries = new ProfileEntry[mEntrySize];
}

View File

@ -58,7 +58,7 @@ class ThreadProfile
public:
ThreadProfile(const char* aName, int aEntrySize, PseudoStack *aStack,
int aThreadId, PlatformData* aPlatformData,
bool aIsMainThread);
bool aIsMainThread, void *aStackTop);
~ThreadProfile();
void addTag(ProfileEntry aTag);
void flush();
@ -78,6 +78,7 @@ public:
int ThreadId() const { return mThreadId; }
PlatformData* GetPlatformData() { return mPlatformData; }
void* GetStackTop() const { return mStackTop; }
private:
// Circular buffer 'Keep One Slot Open' implementation
// for simplicity
@ -92,6 +93,7 @@ private:
int mThreadId;
bool mIsMainThread;
PlatformData* mPlatformData; // Platform specific data.
void* const mStackTop;
};
std::ostream& operator<<(std::ostream& stream, const ThreadProfile& profile);

View File

@ -544,8 +544,13 @@ void mozilla_sampler_print_location1()
return;
}
// This won't allow unwinding past this function, but it will be safe.
void *stackTop = &stack;
ThreadProfile threadProfile("Temp", PROFILE_DEFAULT_ENTRY, stack,
0, Sampler::AllocPlatformData(0), false);
0, Sampler::AllocPlatformData(0), false,
stackTop);
doSampleStackTrace(stack, threadProfile, NULL);
threadProfile.flush();

View File

@ -120,7 +120,8 @@ class TableTicker: public Sampler {
aInfo->Stack(),
aInfo->ThreadId(),
aInfo->GetPlatformData(),
aInfo->IsMainThread());
aInfo->IsMainThread(),
aInfo->StackTop());
profile->addTag(ProfileEntry('m', "Start"));
aInfo->SetProfile(profile);

View File

@ -383,7 +383,7 @@ bool Sampler::RegisterCurrentThread(const char* aName,
mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex);
ThreadInfo* info = new ThreadInfo(aName, gettid(),
aIsMainThread, aPseudoStack);
aIsMainThread, aPseudoStack, stackTop);
if (sActiveSampler) {
sActiveSampler->RegisterThread(info);

View File

@ -359,7 +359,7 @@ bool Sampler::RegisterCurrentThread(const char* aName,
mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex);
ThreadInfo* info = new ThreadInfo(aName, gettid(),
aIsMainThread, aPseudoStack);
aIsMainThread, aPseudoStack, stackTop);
if (sActiveSampler) {
sActiveSampler->RegisterThread(info);

View File

@ -278,7 +278,7 @@ bool Sampler::RegisterCurrentThread(const char* aName,
mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex);
ThreadInfo* info = new ThreadInfo(aName, GetCurrentThreadId(),
aIsMainThread, aPseudoStack);
aIsMainThread, aPseudoStack, stackTop);
if (sActiveSampler) {
sActiveSampler->RegisterThread(info);

View File

@ -378,13 +378,14 @@ class Sampler {
class ThreadInfo {
public:
ThreadInfo(const char* aName, int aThreadId, bool aIsMainThread, PseudoStack* aPseudoStack)
ThreadInfo(const char* aName, int aThreadId, bool aIsMainThread, PseudoStack* aPseudoStack, void* aStackTop)
: mName(strdup(aName))
, mThreadId(aThreadId)
, mIsMainThread(aIsMainThread)
, mPseudoStack(aPseudoStack)
, mPlatformData(Sampler::AllocPlatformData(aThreadId))
, mProfile(NULL) {}
, mProfile(NULL)
, mStackTop(aStackTop) {}
virtual ~ThreadInfo();
@ -398,6 +399,7 @@ class ThreadInfo {
ThreadProfile* Profile() const { return mProfile; }
PlatformData* GetPlatformData() const { return mPlatformData; }
void* StackTop() const { return mStackTop; }
private:
char* mName;
int mThreadId;
@ -405,6 +407,7 @@ class ThreadInfo {
PseudoStack* mPseudoStack;
PlatformData* mPlatformData;
ThreadProfile* mProfile;
void* const mStackTop;
};
#endif /* ndef TOOLS_PLATFORM_H_ */