Search code examples
swiftlldb

LLDB for Swift: Access computed property or perform function call in type summary Python script


When I create a custom type summary using a Python script, it is possible to access ivars using value.GetChildMemberByName("<child-name>"). However, this does not work for computed properties or functions.

With the frame variable command, the script that generates the summary can evaluate expressions in the current frame (e.g. value.GetFrame().EvaluateExpression(value.GetName() + ".description"))

However, this will not work when using p <some-expression>/expression -- <some-expression> as there is no frame, so the above statement will fail to produce any results.

Is there a way to call functions or evaluate computed properties in a type summary when using p (expression --)?


Solution

  • The EvaluateExpression function is available on the target as well as on frames. Try value.GetTarget().EvaluateExpression(...).