зеркало из https://github.com/mozilla/gecko-dev.git
Bug 778979 - Part 5: Expose the line number in the JSON output of SPS. r=ehsan
This commit is contained in:
Родитель
b4ee1d6c18
Коммит
3482931144
|
@ -30,6 +30,9 @@
|
||||||
#include "nsDirectoryServiceUtils.h"
|
#include "nsDirectoryServiceUtils.h"
|
||||||
#include "nsDirectoryServiceDefs.h"
|
#include "nsDirectoryServiceDefs.h"
|
||||||
|
|
||||||
|
// JS
|
||||||
|
#include "jsdbgapi.h"
|
||||||
|
|
||||||
// we eventually want to make this runtime switchable
|
// we eventually want to make this runtime switchable
|
||||||
#if defined(MOZ_PROFILING) && (defined(XP_UNIX) && !defined(XP_MACOSX))
|
#if defined(MOZ_PROFILING) && (defined(XP_UNIX) && !defined(XP_MACOSX))
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
|
@ -129,6 +132,11 @@ public:
|
||||||
, mTagName(aTagName)
|
, mTagName(aTagName)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
ProfileEntry(char aTagName, int aTagLine)
|
||||||
|
: mTagLine(aTagLine)
|
||||||
|
, mTagName(aTagName)
|
||||||
|
{ }
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& stream, const ProfileEntry& entry);
|
friend std::ostream& operator<<(std::ostream& stream, const ProfileEntry& entry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -140,6 +148,7 @@ private:
|
||||||
double mTagFloat;
|
double mTagFloat;
|
||||||
Address mTagAddress;
|
Address mTagAddress;
|
||||||
uintptr_t mTagOffset;
|
uintptr_t mTagOffset;
|
||||||
|
int mTagLine;
|
||||||
};
|
};
|
||||||
char mTagName;
|
char mTagName;
|
||||||
};
|
};
|
||||||
|
@ -331,6 +340,13 @@ public:
|
||||||
b.DefineProperty(frame, "location", tagBuff);
|
b.DefineProperty(frame, "location", tagBuff);
|
||||||
} else {
|
} else {
|
||||||
b.DefineProperty(frame, "location", tagStringData);
|
b.DefineProperty(frame, "location", tagStringData);
|
||||||
|
readAheadPos = (readPos + incBy) % mEntrySize;
|
||||||
|
if (readAheadPos != mLastFlushPos &&
|
||||||
|
mEntries[readAheadPos].mTagName == 'n') {
|
||||||
|
b.DefineProperty(frame, "line",
|
||||||
|
mEntries[readAheadPos].mTagLine);
|
||||||
|
incBy++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b.ArrayPush(frames, frame);
|
b.ArrayPush(frames, frame);
|
||||||
}
|
}
|
||||||
|
@ -624,8 +640,11 @@ JSObject* TableTicker::ToJSObject(JSContext *aCx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void addProfileEntry(volatile StackEntry &entry, ThreadProfile &aProfile)
|
void addProfileEntry(volatile StackEntry &entry, ThreadProfile &aProfile,
|
||||||
|
ProfileStack *stack, void *lastpc)
|
||||||
{
|
{
|
||||||
|
int lineno = -1;
|
||||||
|
|
||||||
// First entry has tagName 's' (start)
|
// First entry has tagName 's' (start)
|
||||||
// Check for magic pointer bit 1 to indicate copy
|
// Check for magic pointer bit 1 to indicate copy
|
||||||
const char* sampleLabel = entry.label();
|
const char* sampleLabel = entry.label();
|
||||||
|
@ -646,8 +665,30 @@ void addProfileEntry(volatile StackEntry &entry, ThreadProfile &aProfile)
|
||||||
// Cast to *((void**) to pass the text data to a void*
|
// Cast to *((void**) to pass the text data to a void*
|
||||||
aProfile.addTag(ProfileEntry('d', *((void**)(&text[0]))));
|
aProfile.addTag(ProfileEntry('d', *((void**)(&text[0]))));
|
||||||
}
|
}
|
||||||
|
if (entry.js()) {
|
||||||
|
if (!entry.pc()) {
|
||||||
|
// The JIT only allows the top-most entry to have a NULL pc
|
||||||
|
MOZ_ASSERT(&entry == &stack->mStack[stack->stackSize() - 1]);
|
||||||
|
// If stack-walking was disabled, then that's just unfortunate
|
||||||
|
if (lastpc) {
|
||||||
|
jsbytecode *jspc = js::ProfilingGetPC(stack->mRuntime, entry.script(),
|
||||||
|
lastpc);
|
||||||
|
if (jspc) {
|
||||||
|
lineno = JS_PCToLineNumber(NULL, entry.script(), jspc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lineno = JS_PCToLineNumber(NULL, entry.script(), entry.pc());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lineno = entry.line();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
aProfile.addTag(ProfileEntry('c', sampleLabel));
|
aProfile.addTag(ProfileEntry('c', sampleLabel));
|
||||||
|
lineno = entry.line();
|
||||||
|
}
|
||||||
|
if (lineno != -1) {
|
||||||
|
aProfile.addTag(ProfileEntry('n', lineno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,7 +787,7 @@ void TableTicker::doBacktrace(ThreadProfile &aProfile, TickSample* aSample)
|
||||||
if (entry.stackAddress() < array.sp_array[i-1] && entry.stackAddress())
|
if (entry.stackAddress() < array.sp_array[i-1] && entry.stackAddress())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
addProfileEntry(entry, aProfile);
|
addProfileEntry(entry, aProfile, stack, array.array[0]);
|
||||||
pseudoStackPos++;
|
pseudoStackPos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +853,7 @@ void doSampleStackTrace(ProfileStack *aStack, ThreadProfile &aProfile, TickSampl
|
||||||
// followed by 0 or more 'c' tags.
|
// followed by 0 or more 'c' tags.
|
||||||
aProfile.addTag(ProfileEntry('s', "(root)"));
|
aProfile.addTag(ProfileEntry('s', "(root)"));
|
||||||
for (uint32_t i = 0; i < aStack->stackSize(); i++) {
|
for (uint32_t i = 0; i < aStack->stackSize(); i++) {
|
||||||
addProfileEntry(aStack->mStack[i], aProfile);
|
addProfileEntry(aStack->mStack[i], aProfile, aStack, nullptr);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_SPS_LEAF_DATA
|
#ifdef ENABLE_SPS_LEAF_DATA
|
||||||
if (sample) {
|
if (sample) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче