MCPcopy Create free account
hub / github.com/facebook/chisel / evaluateExpressionValue

Function evaluateExpressionValue

fbchisellldbbase.py:65–107  ·  view source on GitHub ↗
(
    expression,
    printErrors=True,
    language=lldb.eLanguageTypeObjC_plus_plus,
    tryAllThreads=False,
)

Source from the content-addressed store, hash-verified

63# evaluates expression in Objective-C++ context, so it will work even for
64# Swift projects
65def evaluateExpressionValue(
66 expression,
67 printErrors=True,
68 language=lldb.eLanguageTypeObjC_plus_plus,
69 tryAllThreads=False,
70):
71 frame = (
72 lldb.debugger.GetSelectedTarget()
73 .GetProcess()
74 .GetSelectedThread()
75 .GetSelectedFrame()
76 )
77 options = lldb.SBExpressionOptions()
78 options.SetLanguage(language)
79
80 # Allow evaluation that contains a @throw/@catch.
81 # By default, ObjC @throw will cause evaluation to be aborted. At the time
82 # of a @throw, it's not known if the exception will be handled by a @catch.
83 # An exception that's caught, should not cause evaluation to fail.
84 options.SetTrapExceptions(False)
85
86 # Give evaluation more time.
87 options.SetTimeoutInMicroSeconds(5000000) # 5s
88
89 # Most Chisel commands are not multithreaded.
90 options.SetTryAllThreads(tryAllThreads)
91
92 value = frame.EvaluateExpression(expression, options)
93 error = value.GetError()
94
95 # Retry if the error could be resolved by first importing UIKit.
96 if (
97 error.type == lldb.eErrorTypeExpression
98 and error.value == lldb.eExpressionParseError
99 and importModule(frame, "UIKit")
100 ):
101 value = frame.EvaluateExpression(expression, options)
102 error = value.GetError()
103
104 if printErrors and not isSuccess(error):
105 print(error)
106
107 return value
108
109
110def evaluateInputExpression(expression, printErrors=True):

Callers 5

evaluateInputExpressionFunction · 0.85
evaluateExpressionFunction · 0.85
describeObjectFunction · 0.85
evaluateEffectFunction · 0.85
evaluateFunction · 0.85

Calls 2

importModuleFunction · 0.85
isSuccessFunction · 0.85

Tested by

no test coverage detected