Bug 1346776 - Add the process id in the Gecko Profiler; r?mstange draft
authorGreg Tatum <tatum.creative@gmail.com>
Mon, 13 Mar 2017 14:47:15 +0100
changeset 502965 2c0ceef4e4958839d23bbef30e5d3c1ebf3ba741
parent 502328 9fb5e850ab7ab0b2b90640c604f66038407b411d
child 550289 72f09e7521d4e85515e2464a33f15e9d9dccc2d8
push id50429
push userbmo:gtatum@mozilla.com
push dateWed, 22 Mar 2017 14:18:06 +0000
reviewersmstange
bugs1346776
milestone55.0a1
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
tools/profiler/core/ThreadInfo.cpp
--- 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;
 }
-