Bug 1000621 - Check if DMD is enabled before dumping. r=njn. DONTBUILD
authorEric Rahm <erahm@mozilla.com>
Thu, 24 Apr 2014 12:43:11 -0700
changeset 180071 031b49af61a68658a27cf1a5e76bb4081210ad8d
parent 180070 a38d0ab6d6b844c65448f601bd7b668f5f2d7cd5
child 180072 347ecbf31a6a06e838fefa3992ddab8ef1655e3a
push id26653
push usercbook@mozilla.com
push dateFri, 25 Apr 2014 10:50:28 +0000
treeherdermozilla-central@2b02d933c39a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1000621
milestone31.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 1000621 - Check if DMD is enabled before dumping. r=njn. DONTBUILD
memory/replace/dmd/DMD.cpp
memory/replace/dmd/DMD.h
xpcom/base/nsMemoryInfoDumper.cpp
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -2090,16 +2090,22 @@ ClearReports()
   if (!gIsDMDRunning) {
     return;
   }
 
   AutoLockState lock;
   ClearReportsInternal();
 }
 
+MOZ_EXPORT bool
+IsEnabled()
+{
+  return gIsDMDRunning;
+}
+
 MOZ_EXPORT void
 Dump(Writer aWriter)
 {
   if (!gIsDMDRunning) {
     const char* msg = "cannot Dump();  DMD was not enabled at startup\n";
     StatusMsg("%s", msg);
     W("%s", msg);
     return;
--- a/memory/replace/dmd/DMD.h
+++ b/memory/replace/dmd/DMD.h
@@ -73,12 +73,16 @@ struct Sizes
   void Clear() { memset(this, 0, sizeof(Sizes)); }
 };
 
 // Gets the size of various data structures.  Used to implement a memory
 // reporter for DMD.
 MOZ_EXPORT void
 SizeOf(Sizes* aSizes);
 
+// Indicates whether or not DMD is enabled.
+MOZ_EXPORT bool
+IsEnabled();
+
 } // namespace mozilla
 } // namespace dmd
 
 #endif /* DMD_h___ */
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -511,16 +511,20 @@ nsMemoryInfoDumper::DumpMemoryInfoToTemp
                                identifier);
   return rv;
 }
 
 #ifdef MOZ_DMD
 nsresult
 nsMemoryInfoDumper::DumpDMD(const nsAString &aIdentifier)
 {
+  if (!dmd::IsEnabled()) {
+    return NS_OK;
+  }
+
   nsresult rv;
 
   // Create a filename like dmd-<identifier>-<pid>.txt.gz, which will be used
   // if DMD is enabled.
   nsCString dmdFilename;
   MakeFilename("dmd", aIdentifier, "txt.gz", dmdFilename);
 
   // Open a new DMD file named |dmdFilename| in NS_OS_TEMP_DIR for writing,