aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@gmail.com>2014-12-02 04:21:53 -0500
committerJosh Matthews <josh@joshmatthews.net>2015-02-23 23:05:41 -0500
commit894e58f714de0f3d65aeb943dbf8f569feb8c1d6 (patch)
treea284e4db639524fe73277d8ebbc3ac4e18f0a6a8 /python/servo
parent287f390c4a56dd8c5960df699d45653227b25d6f (diff)
downloadservo-894e58f714de0f3d65aeb943dbf8f569feb8c1d6.tar.gz
servo-894e58f714de0f3d65aeb943dbf8f569feb8c1d6.zip
add basic |mach rr-{record,replay}| commands
These are very basic commands for invoking Servo underneath rr. rr currently doesn't support all the syscalls that Servo requires, but that's easy to fix on the rr side. Fixes #4177.
Diffstat (limited to 'python/servo')
-rw-r--r--python/servo/post_build_commands.py46
1 files changed, 42 insertions, 4 deletions
diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py
index d427fe1181f..bfa679a795e 100644
--- a/python/servo/post_build_commands.py
+++ b/python/servo/post_build_commands.py
@@ -30,6 +30,13 @@ def read_file(filename, if_exists=False):
@CommandProvider
class MachCommands(CommandBase):
+
+ def get_binary_path(self, release):
+ base_path = path.join("components", "servo", "target")
+ if release:
+ return path.join(base_path, "release", "servo")
+ return path.join(base_path, "servo")
+
@Command('run',
description='Run Servo',
category='post-build')
@@ -49,10 +56,7 @@ class MachCommands(CommandBase):
env = self.build_env()
env["RUST_BACKTRACE"] = "1"
- if release:
- args = [path.join("components", "servo", "target", "release", "servo")]
- else:
- args = [path.join("components", "servo", "target", "servo")]
+ args = self.get_binary_path(release)
# Borrowed and modified from:
# http://hg.mozilla.org/mozilla-central/file/c9cfa9b91dea/python/mozbuild/mozbuild/mach_commands.py#l883
@@ -84,6 +88,40 @@ class MachCommands(CommandBase):
else:
raise e
+ @Command('rr-record',
+ description='Run Servo whilst recording execution with rr',
+ category='post-build')
+ @CommandArgument('--release', '-r', action='store_true',
+ help='Running release builds')
+ @CommandArgument(
+ 'params', nargs='...',
+ help="Command-line arguments to be passed through to Servo")
+ def rr_record(self, release=False, params=[]):
+ env = self.build_env()
+ env["RUST_BACKTRACE"] = "1"
+
+ servo_cmd = [self.get_binary_path(release)] + params
+ rr_cmd = ['rr', '--fatal-errors', 'record']
+ try:
+ subprocess.check_call(rr_cmd + servo_cmd)
+ except OSError as e:
+ if e.errno == 2:
+ print("rr binary can't be found!")
+ else:
+ raise e
+
+ @Command('rr-replay',
+ description='Replay the most recent execution of Servo that was recorded with rr',
+ category='post-build')
+ def rr_replay(self):
+ try:
+ subprocess.check_call(['rr', '--fatal-errors', 'replay'])
+ except OSError as e:
+ if e.errno == 2:
+ print("rr binary can't be found!")
+ else:
+ raise e
+
@Command('doc',
description='Generate documentation',
category='post-build')