Skip to content

Commit

Permalink
Add eobjc and eswift commands for running expressions from a spec…
Browse files Browse the repository at this point in the history
…ific language context
  • Loading branch information
Chris Williams committed Oct 23, 2015
1 parent 598fb71 commit fbc20ef
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion commands/FBPrintCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def lldbcommands():
FBPrintJSON(),
FBPrintAsCurl(),
FBPrintInObjc(),
FBPrintInSwift()
FBPrintInSwift(),
FBExpressionInObjc(),
FBExpressionInSwift(),
]

class FBPrintViewHierarchyCommand(fb.FBCommand):
Expand Down Expand Up @@ -550,3 +552,45 @@ def args(self):
def run(self, arguments, options):
expression = arguments[0]
lldb.debugger.HandleCommand('expression -O -l Swift -- ' + expression)

class FBExpressionInObjc(fb.FBCommand):
def name(self):
return 'eobjc'

def description(self):
return 'Run expression run in an ObjC++ context. (Shortcut for "expression -l ObjC++" )'

def args(self):
return [
fb.FBCommandArgument(arg='expression', help='ObjC expression to evaluate and print.'),
]

def run(self, arguments, options):
values = arguments[0].split("--", 1)
if len(arguments) is 2:
(arguments, expression) = arguments
lldb.debugger.HandleCommand('expression -l ObjC++ ' + arguments + " -- " + expression)
else:
expression = arguments[0]
lldb.debugger.HandleCommand('expression -l ObjC++ -- ' + expression)

class FBExpressionInSwift(fb.FBCommand):
def name(self):
return 'eswift'

def description(self):
return 'Run expression run in a Swift context. (Shortcut for "expression -l Swift" )'

def args(self):
return [
fb.FBCommandArgument(arg='expression', help='Swift expression to evaluate and print.'),
]

def run(self, arguments, options):
values = arguments[0].split("--", 1)
if len(arguments) is 2:
(arguments, expression) = arguments
lldb.debugger.HandleCommand('expression -l Swift ' + arguments + " -- " + expression)
else:
expression = arguments[0]
lldb.debugger.HandleCommand('expression -l Swift -- ' + expression)

0 comments on commit fbc20ef

Please sign in to comment.