From 7458de657b0ae9ed7e0b738a77c5e20e8583c5ad Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 6 Mar 2018 22:54:50 -0800 Subject: [PATCH] Add command to run commands in sequence --- commands/FBDebugCommands.py | 21 +++++++++++++++++++++ fblldb.py | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/commands/FBDebugCommands.py b/commands/FBDebugCommands.py index cd4faf3..a72104e 100644 --- a/commands/FBDebugCommands.py +++ b/commands/FBDebugCommands.py @@ -15,6 +15,7 @@ def lldbcommands(): FBMethodBreakpointCommand(), FBMemoryWarningCommand(), FBFindInstancesCommand(), + FBSequenceCommand(), ] class FBWatchInstanceVariableCommand(fb.FBCommand): @@ -298,3 +299,23 @@ def chiselLibraryPath(self): source_dir = os.path.dirname(source_path) # ugh: ../.. is to back out of commands/, then back out of libexec/ return os.path.join(source_dir, '..', '..', 'lib', 'Chisel.framework', 'Chisel') + + +class FBSequenceCommand(fb.FBCommand): + def name(self): + return 'sequence' + + def description(self): + return 'Run commands in sequence, stopping on any error.' + + def lex(self, commandLine): + return commandLine.split(';') + + def run(self, arguments, options): + interpreter = lldb.debugger.GetCommandInterpreter() + # The full unsplit command is in position 0. + sequence = arguments[1:] + for command in sequence: + interpreter.HandleCommand(command.strip(), self.context, self.result) + if not self.result.Succeeded(): + break diff --git a/fblldb.py b/fblldb.py index 67332d7..31bc0ab 100755 --- a/fblldb.py +++ b/fblldb.py @@ -55,7 +55,9 @@ def loadCommand(module, command, directory, filename, extension): name=name)) def makeRunCommand(command, filename): - def runCommand(debugger, input, result, dict): + def runCommand(debugger, input, exe_ctx, result, _): + command.result = result + command.context = exe_ctx splitInput = command.lex(input) # OptionParser will throw in the case where you want just one big long argument and no