Bug 1395540 - Part 4: Fix the DMD stacks. r=njn
authorEric Rahm <erahm@mozilla.com>
Thu, 21 Sep 2017 14:41:44 -0700
changeset 426820 1d4a667909cc526489cccd8860fd2b1ca2d55581
parent 426819 2884a55d2b762bc7ff4dfc7db36747ca47ef1321
child 426821 992cd5f41ca223535bde16f691cd997d54107e7b
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
Bug 1395540 - Part 4: Fix the DMD stacks. r=njn This runs the DMD files through the DMD stack fixer so that we end up with usable stacks instead of just offsets into libxul.
--- a/testing/awsy/awsy/test_memory_usage.py
+++ b/testing/awsy/awsy/test_memory_usage.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 import fnmatch
 import glob
+import gzip
 import json
 import os
 import sys
 import time
 import shutil
 import tempfile
 from marionette_harness import MarionetteTestCase
@@ -111,21 +112,26 @@ class TestMemoryUsage(MarionetteTestCase
                     shutil.copy2(file, os.environ["MOZ_UPLOAD_DIR"])
         self.logger.info("done tearing down!")
     def cleanup_dmd(self):
         Handles moving DMD reports from the temp dir to our resultsDir.
+        from dmd import fixStackTraces
         # Move DMD files from temp dir to resultsDir.
         tmpdir = tempfile.gettempdir()
         tmp_files = os.listdir(tmpdir)
         for f in fnmatch.filter(tmp_files, "dmd-*.json.gz"):
             f = os.path.join(tmpdir, f)
+            self.logger.info("Fixing stacks for %s, this may take a while" % f)
+            isZipped = True
+            fixStackTraces(f, isZipped, gzip.open)
             shutil.move(f, self._resultsDir)
         # Also attempt to cleanup the unified memory reports.
         for f in fnmatch.filter(tmp_files, "unified-memory-report-*.json.gz"):
             except OSError:
                 self.logger.info("Unable to remove %s" % f)
--- a/testing/awsy/mach_commands.py
+++ b/testing/awsy/mach_commands.py
@@ -166,16 +166,20 @@ class MachCommands(MachCommandBase):
                     "MOZ_REPLACE_MALLOC_LIB": dmd_lib,
             arch = self.substs['OS_ARCH']
             for k, v in env_vars[arch].iteritems():
                 os.environ[k] = v
+            # Also add the bin dir to the python path so we can use dmd.py
+            if bin_dir not in sys.path:
+                sys.path.append(bin_dir)
         for k, v in kwargs.iteritems():
             setattr(args, k, v)
         args.logger = commandline.setup_logging('Are We Slim Yet Tests',
                                                 {'mach': sys.stdout})