(
expression,
printErrors=True,
language=lldb.eLanguageTypeObjC_plus_plus,
tryAllThreads=False,
)
| 63 | # evaluates expression in Objective-C++ context, so it will work even for |
| 64 | # Swift projects |
| 65 | def 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 | |
| 110 | def evaluateInputExpression(expression, printErrors=True): |
no test coverage detected