Bug 1533282 - Restore the debugging options in wrench/script/headless.py. r=kvark
☠☠ backed out by 6490553fc843 ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Thu, 07 Mar 2019 14:16:44 +0000
changeset 520844 664fd8f4cc02b58208f2e49b7c8aac0aac9a1e09
parent 520843 da9a99c4896c2576a72d6ef9798ea11d9153dddc
child 520845 4dc7ad52faf227101331c22f1ce4babb475661f0
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1533282
milestone67.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 1533282 - Restore the debugging options in wrench/script/headless.py. r=kvark Differential Revision: https://phabricator.services.mozilla.com/D22458
gfx/wr/wrench/script/headless.py
--- a/gfx/wr/wrench/script/headless.py
+++ b/gfx/wr/wrench/script/headless.py
@@ -43,16 +43,35 @@ def is_windows():
 
 def is_macos():
     return sys.platform == 'darwin'
 
 
 def is_linux():
     return sys.platform.startswith('linux')
 
+def debugger():
+    if "DEBUGGER" in os.environ:
+        return os.environ["DEBUGGER"]
+    return None
+
+
+def use_gdb():
+    return debugger() in ['gdb', 'cgdb', 'rust-gdb']
+
+
+def use_rr():
+    return debugger() == 'rr'
+
+
+def optimized_build():
+    if "OPTIMIZED" in os.environ:
+        opt = os.environ["OPTIMIZED"]
+        return opt not in ["0", "false"]
+    return True
 
 def set_osmesa_env(bin_path):
     """Set proper LD_LIBRARY_PATH and DRIVE for software rendering on Linux and OSX"""
     if is_linux():
         osmesa_path = path.join(find_dep_path_newest('osmesa-src', bin_path), "out", "lib", "gallium")
         print(osmesa_path)
         os.environ["LD_LIBRARY_PATH"] = osmesa_path
         os.environ["GALLIUM_DRIVER"] = "softpipe"
@@ -67,15 +86,38 @@ def set_osmesa_env(bin_path):
 
 target_folder = os.getenv('WRENCH_HEADLESS_TARGET', None)
 if not target_folder:
     extra_flags = os.getenv('CARGOFLAGS', None)
     extra_flags = extra_flags.split(' ') if extra_flags else []
     subprocess.check_call(['cargo', 'build'] + extra_flags + ['--release', '--verbose', '--features', 'headless'])
     target_folder = '../target/'
 
-set_osmesa_env(target_folder + 'release/')
+build_cmd = ['cargo', 'build'] + extra_flags + ['--verbose', '--features', 'headless']
+if optimized_build():
+    build_cmd += ['--release']
+
+if optimized_build():
+    target_folder += 'release/'
+else:
+    target_folder += 'debug/'
+
+subprocess.check_call(build_cmd)
+
+dbg_cmd = []
+if use_rr():
+    dbg_cmd = ['rr', 'record']
+elif use_gdb():
+    dbg_cmd = [debugger(), '--args']
+elif debugger():
+    print("Unknown debugger: " + debugger())
+    sys.exit(1)
+
+set_osmesa_env(target_folder)
 # TODO(gw): We have an occasional accuracy issue or bug (could be WR or OSMesa)
 #           where the output of a previous test that uses intermediate targets can
 #           cause 1.0 / 255.0 pixel differences in a subsequent test. For now, we
 #           run tests with no-scissor mode, which ensures a complete target clear
 #           between test runs. But we should investigate this further...
-subprocess.check_call([target_folder + 'release/wrench', '--no-scissor', '-h'] + sys.argv[1:])
+cmd = dbg_cmd + [target_folder + 'wrench', '--no-scissor', '-h'] + sys.argv[1:]
+print('Running: `' + ' '.join(cmd) + '`')
+subprocess.check_call(cmd)
+