Commit 579bf0d0 authored by Bill McCloskey's avatar Bill McCloskey
Browse files

Bug 765065 - Annotation for crash reports: "Are we GCing?" (r=bsmedberg)

parent 521cac21
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -662,6 +662,24 @@ XPCJSRuntime::ReleaseIncrementally(nsTArray<nsISupports *> &array)
        mReleaseRunnable->ReleaseNow(false);
}

/* static */ void
XPCJSRuntime::GCSliceCallback(JSRuntime *rt,
                              js::GCProgress progress,
                              const js::GCDescription &desc)
{
    XPCJSRuntime *self = nsXPConnect::GetRuntimeInstance();
    if (!self)
        return;

#ifdef MOZ_CRASHREPORTER
    CrashReporter::SetGarbageCollecting(progress == js::GC_CYCLE_BEGIN ||
                                        progress == js::GC_SLICE_BEGIN);
#endif

    if (self->mPrevGCSliceCallback)
        (*self->mPrevGCSliceCallback)(rt, progress, desc);
}

/* static */ void
XPCJSRuntime::GCCallback(JSRuntime *rt, JSGCStatus status)
{
@@ -1070,6 +1088,8 @@ XPCJSRuntime::~XPCJSRuntime()
{
    MOZ_ASSERT(!mReleaseRunnable);

    js::SetGCSliceCallback(mJSRuntime, mPrevGCSliceCallback);

    if (mWatchdogWakeup) {
        // If the watchdog thread is running, tell it to terminate waking it
        // up if necessary and wait until it signals that it finished. As we
@@ -2157,6 +2177,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
    JS_SetDestroyCompartmentCallback(mJSRuntime, CompartmentDestroyedCallback);
    JS_SetCompartmentNameCallback(mJSRuntime, CompartmentNameCallback);
    JS_SetGCCallback(mJSRuntime, GCCallback);
    mPrevGCSliceCallback = js::SetGCSliceCallback(mJSRuntime, GCSliceCallback);
    JS_SetFinalizeCallback(mJSRuntime, FinalizeCallback);
    JS_SetExtraGCRootsTracer(mJSRuntime, TraceBlackJS, this);
    JS_SetGrayGCRootsTracer(mJSRuntime, TraceGrayJS, this);
+4 −0
Original line number Diff line number Diff line
@@ -756,6 +756,9 @@ public:
    void UnmarkSkippableJSHolders();

    static void GCCallback(JSRuntime *rt, JSGCStatus status);
    static void GCSliceCallback(JSRuntime *rt,
                                js::GCProgress progress,
                                const js::GCDescription &desc);
    static void FinalizeCallback(JSFreeOp *fop, JSFinalizeStatus status, JSBool isCompartmentGC);

    inline void AddVariantRoot(XPCTraceableVariant* variant);
@@ -910,6 +913,7 @@ private:
    bool mWatchdogHibernating;
    PRTime mLastActiveTime; // -1 if active NOW
    XPCIncrementalReleaseRunnable *mReleaseRunnable;
    js::GCSliceCallback mPrevGCSliceCallback;

    nsCOMPtr<nsIException>   mPendingException;
    nsCOMPtr<nsIExceptionManager> mExceptionManager;
+26 −0
Original line number Diff line number Diff line
@@ -209,12 +209,17 @@ static const char kAvailablePhysicalMemoryParameter[] = "AvailablePhysicalMemory
static const int kAvailablePhysicalMemoryParameterLen =
  sizeof(kAvailablePhysicalMemoryParameter)-1;

static const char kIsGarbageCollectingParameter[] = "IsGarbageCollecting=";
static const int kIsGarbageCollectingParameterLen =
  sizeof(kIsGarbageCollectingParameter)-1;

// this holds additional data sent via the API
static Mutex* crashReporterAPILock;
static Mutex* notesFieldLock;
static AnnotationTable* crashReporterAPIData_Hash;
static nsCString* crashReporterAPIData = nullptr;
static nsCString* notesField = nullptr;
static bool isGarbageCollecting;

// OOP crash reporting
static CrashGenerationServer* crashServer; // chrome process has this
@@ -526,6 +531,12 @@ bool MinidumpCallback(const XP_CHAR* dump_path,
                  &nBytes, NULL);
        WriteFile(hFile, "\n", 1, &nBytes, NULL);
      }
      if (isGarbageCollecting) {
        WriteFile(hFile, kIsGarbageCollectingParameter, kIsGarbageCollectingParameterLen,
                  &nBytes, NULL);
        WriteFile(hFile, isGarbageCollecting ? "1" : "0", 1, &nBytes, NULL);
        WriteFile(hFile, "\n", 1, &nBytes, NULL);
      }

      // Try to get some information about memory.
      MEMORYSTATUSEX statex;
@@ -611,6 +622,11 @@ bool MinidumpCallback(const XP_CHAR* dump_path,
                        timeSinceLastCrashStringLen);
        ignored = sys_write(fd, "\n", 1);
      }
      if (isGarbageCollecting) {
        ignored = sys_write(fd, kIsGarbageCollectingParameter, kIsGarbageCollectingParameterLen);
        ignored = sys_write(fd, isGarbageCollecting ? "1" : "0", 1);
        ignored = sys_write(fd, "\n", 1);
      }
      if (oomAllocationSizeBufferLen) {
        sys_write(fd, kOOMAllocationSizeParameter,
                  kOOMAllocationSizeParameterLen);
@@ -1386,6 +1402,16 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
  return NS_OK;
}

nsresult SetGarbageCollecting(bool collecting)
{
  if (!GetEnabled())
    return NS_ERROR_NOT_INITIALIZED;

  isGarbageCollecting = collecting;

  return NS_OK;
}

nsresult AppendAppNotesToCrashReport(const nsACString& data)
{
  if (!GetEnabled())
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ nsresult SetMinidumpPath(const nsAString& aPath);
nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data);
nsresult AppendAppNotesToCrashReport(const nsACString& data);

nsresult SetGarbageCollecting(bool collecting);

nsresult SetRestartArgs(int argc, char** argv);
nsresult SetupExtraData(nsIFile* aAppDataDirectory,
                        const nsACString& aBuildID);