Bug 731853 - Add way to easily log CC with AllTraces at shutdown. r=smaug
authorAndrew McCreight <amccreight@mozilla.com>
Fri, 28 Sep 2012 10:11:33 -0700
changeset 116545 4fcba9b6e0f8770cf9615e89c8b7de6f27f88b1b
parent 116544 851fd44eeb42b81c822a40e6baf60d16056b90cd
child 116546 473bd0eee23b08e61961ca8de6c35990439a118b
push id19990
push useramccreight@mozilla.com
push dateWed, 19 Dec 2012 21:10:36 +0000
treeherdermozilla-inbound@4fcba9b6e0f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs731853
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 731853 - Add way to easily log CC with AllTraces at shutdown. r=smaug
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -165,16 +165,22 @@ extern DWORD gTLSThreadIDIndex;
 extern NS_TLS mozilla::threads::ID gTLSThreadID;
 #else
 PRThread* gCycleCollectorThread = nullptr;
 #endif
 
 // If true, always log cycle collector graphs.
 const bool gAlwaysLogCCGraphs = false;
 
+// If true, log the cycle collector graphs during shutdown.
+const bool gLogShutdown = false;
+
+// If true, any logging done at shutdown will be AllTraces.
+const bool gAllTracesAtShutdown = false;
+
 MOZ_NEVER_INLINE void
 CC_AbortIfNull(void *ptr)
 {
     if (!ptr)
         MOZ_CRASH();
 }
 
 // Various parameters of this collector can be tuned using environment
@@ -1288,19 +1294,24 @@ public:
     ~nsCycleCollectorLogger()
     {
         if (mStream) {
             fclose(mStream);
         }
     }
     NS_DECL_ISUPPORTS
 
+    void SetAllTraces()
+    {
+        mWantAllTraces = true;
+    }
+
     NS_IMETHOD AllTraces(nsICycleCollectorListener** aListener)
     {
-        mWantAllTraces = true;
+        SetAllTraces();
         NS_ADDREF(*aListener = this);
         return NS_OK;
     }
 
     NS_IMETHOD GetWantAllTraces(bool* aAllTraces)
     {
         *aAllTraces = mWantAllTraces;
         return NS_OK;
@@ -2957,18 +2968,21 @@ nsCycleCollector::Shutdown()
 {
 #ifndef DEBUG
 #ifndef DEBUG_CC
     if (PR_GetEnv("XPCOM_CC_RUN_DURING_SHUTDOWN"))
 #endif
 #endif
     {
         nsCOMPtr<nsCycleCollectorLogger> listener;
-        if (mParams.mLogGraphs) {
+        if (mParams.mLogGraphs || gLogShutdown) {
             listener = new nsCycleCollectorLogger();
+            if (gAllTracesAtShutdown) {
+                listener->SetAllTraces();
+            }
         }
         Collect(false, nullptr,  SHUTDOWN_COLLECTIONS(mParams), listener);
     }
 
 #ifdef DEBUG_CC
     GCGraphBuilder builder(mGraph, mJSRuntime, nullptr, false);
     mScanInProgress = true;
     SelectPurple(builder);