Bug 1346776 - Add the process id in the Gecko Profiler; r?mstange
I also tweaked the int type of the JSON writer to match the IntProperty
method.
MozReview-Commit-ID: rtxLDKtJQZ
--- a/tools/profiler/core/ThreadInfo.cpp
+++ b/tools/profiler/core/ThreadInfo.cpp
@@ -7,16 +7,23 @@
#include "ThreadInfo.h"
#include "mozilla/DebugOnly.h"
#if defined(GP_OS_darwin)
#include <pthread.h>
#endif
+#ifdef XP_WIN
+#include <process.h>
+#define getpid _getpid
+#else
+#include <unistd.h> // for getpid()
+#endif
+
ThreadInfo::ThreadInfo(const char* aName, int aThreadId, bool aIsMainThread,
mozilla::NotNull<PseudoStack*> aPseudoStack,
void* aStackTop)
: mName(strdup(aName))
, mThreadId(aThreadId)
, mIsMainThread(aIsMainThread)
, mPseudoStack(aPseudoStack)
, mPlatformData(AllocPlatformData(aThreadId))
@@ -132,17 +139,18 @@ ThreadInfo::StreamSamplesAndMarkers(Prof
const TimeStamp& aStartTime,
double aSinceTime,
UniqueStacks& aUniqueStacks)
{
aWriter.StringProperty("processType",
XRE_ChildProcessTypeToString(XRE_GetProcessType()));
aWriter.StringProperty("name", Name());
- aWriter.IntProperty("tid", static_cast<int>(mThreadId));
+ aWriter.IntProperty("tid", static_cast<int64_t>(mThreadId));
+ aWriter.IntProperty("pid", static_cast<int64_t>(getpid()));
aWriter.StartObjectProperty("samples");
{
{
JSONSchemaWriter schema(aWriter);
schema.WriteField("stack");
schema.WriteField("time");
schema.WriteField("responsiveness");
@@ -254,9 +262,8 @@ ThreadInfo::SizeOfIncludingThis(mozilla:
// - mSavedStreamedMarkers
// - mUniqueStacks
//
// The following members are not measured:
// - mThread: because it is non-owning
return n;
}
-