@@ -36,14 +36,27 @@ def run(self, arguments, option):
3636 pass
3737
3838
39- def evaluateExpressionValue (expression , printErrors = True ):
39+ def evaluateExpressionValueWithLanguage (expression , language , printErrors ):
4040 # lldb.frame is supposed to contain the right frame, but it doesnt :/ so do the dance
4141 frame = lldb .debugger .GetSelectedTarget ().GetProcess ().GetSelectedThread ().GetSelectedFrame ()
42- value = frame .EvaluateExpression (expression )
42+ expr_options = lldb .SBExpressionOptions ()
43+ expr_options .SetLanguage (language ) # requires lldb r210874 (2014-06-13) / Xcode 6
44+ value = frame .EvaluateExpression (expression , expr_options )
4345 if printErrors and value .GetError () is not None and str (value .GetError ()) != 'success' :
4446 print value .GetError ()
4547 return value
4648
49+ def evaluateExpressionValueInFrameLanguage (expression , printErrors = True ):
50+ # lldb.frame is supposed to contain the right frame, but it doesnt :/ so do the dance
51+ frame = lldb .debugger .GetSelectedTarget ().GetProcess ().GetSelectedThread ().GetSelectedFrame ()
52+ language = frame .GetCompileUnit ().GetLanguage () # requires lldb r222189 (2014-11-17)
53+ return evaluateExpressionValueWithLanguage (expression , language , printErrors )
54+
55+ # evaluates expression in Objective-C++ context, so it will work even for
56+ # Swift projects
57+ def evaluateExpressionValue (expression , printErrors = True ):
58+ return evaluateExpressionValueWithLanguage (expression , lldb .eLanguageTypeObjC_plus_plus , printErrors )
59+
4760def evaluateIntegerExpression (expression , printErrors = True ):
4861 output = evaluateExpression ('(int)(' + expression + ')' , printErrors ).replace ('\' ' , '' )
4962 if output .startswith ('\\ x' ): # Booleans may display as \x01 (Hex)
0 commit comments