Bug 1329114 - Put profiles from other processes into a 'processes' array, not into the threads array, and don't stringify them. r?njn
MozReview-Commit-ID: Ccl6JIbRMyX
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -1200,17 +1200,17 @@ StreamTaskTracer(PS::LockRef aLock, Spli
#endif
}
static void
StreamMetaJSCustomObject(PS::LockRef aLock, SpliceableJSONWriter& aWriter)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
- aWriter.IntProperty("version", 4);
+ aWriter.IntProperty("version", 5);
aWriter.DoubleProperty("interval", gPS->Interval(aLock));
aWriter.IntProperty("stackwalk", gPS->FeatureStackWalk(aLock));
#ifdef DEBUG
aWriter.IntProperty("debug", 1);
#else
aWriter.IntProperty("debug", 0);
#endif
@@ -1287,18 +1287,19 @@ struct SubprocessClosure
};
static void
SubProcessCallback(const char* aProfile, void* aClosure)
{
// Called by the observer to get their profile data included as a sub profile.
SubprocessClosure* closure = (SubprocessClosure*)aClosure;
- // Add the string profile into the profile.
- closure->mWriter->StringElement(aProfile);
+ // Add the subprocess profile into the profile, as an element in the
+ // "processes" array.
+ closure->mWriter->Splice(aProfile);
}
#if defined(PROFILE_JAVA)
static void
BuildJavaThreadJSObject(SpliceableJSONWriter& aWriter)
{
aWriter.StringProperty("name", "Java Main Thread");
@@ -1397,33 +1398,16 @@ StreamJSON(PS::LockRef aLock, Spliceable
// Note that we intentionally include thread profiles which
// have been marked for pending delete.
info->StreamJSON(gPS->Buffer(aLock), aWriter, gPS->StartTime(aLock),
aSinceTime);
}
}
- // When notifying observers in other places in this file we are careful
- // to do it when gPSMutex is unlocked, to avoid deadlocks. But that's not
- // necessary here, because "profiler-subprocess" observers just call back
- // into SubprocessCallback, which is simple and doesn't lock gPSMutex.
- if (CanNotifyObservers()) {
- // Send a event asking any subprocesses (plugins) to
- // give us their information
- SubprocessClosure closure(&aWriter);
- nsCOMPtr<nsIObserverService> os =
- mozilla::services::GetObserverService();
- if (os) {
- RefPtr<ProfileSaveEvent> pse =
- new ProfileSaveEvent(SubProcessCallback, &closure);
- os->NotifyObservers(pse, "profiler-subprocess", nullptr);
- }
- }
-
#if defined(PROFILE_JAVA)
if (gPS->FeatureJava(aLock)) {
java::GeckoJavaSampler::Pause();
aWriter.Start();
{
BuildJavaThreadJSObject(aWriter);
}
@@ -1431,16 +1415,35 @@ StreamJSON(PS::LockRef aLock, Spliceable
java::GeckoJavaSampler::Unpause();
}
#endif
gPS->SetIsPaused(aLock, false);
}
aWriter.EndArray();
+
+ aWriter.StartArrayProperty("processes");
+ // When notifying observers in other places in this file we are careful
+ // to do it when gPSMutex is unlocked, to avoid deadlocks. But that's not
+ // necessary here, because "profiler-subprocess" observers just call back
+ // into SubprocessCallback, which is simple and doesn't lock gPSMutex.
+ if (CanNotifyObservers()) {
+ // Send a event asking any subprocesses (plugins) to
+ // give us their information
+ SubprocessClosure closure(&aWriter);
+ nsCOMPtr<nsIObserverService> os =
+ mozilla::services::GetObserverService();
+ if (os) {
+ RefPtr<ProfileSaveEvent> pse =
+ new ProfileSaveEvent(SubProcessCallback, &closure);
+ os->NotifyObservers(pse, "profiler-subprocess", nullptr);
+ }
+ }
+ aWriter.EndArray();
}
aWriter.End();
}
// END saving/streaming code
////////////////////////////////////////////////////////////////////////
ProfilerMarker::ProfilerMarker(const char* aMarkerName,