Skip to content

Commit

Permalink
[LLDB][Expression] Allow instantiation of IR Entity from ValueObject
Browse files Browse the repository at this point in the history
This is required in preparation for the follow-up patch which adds
support for evaluating expressions from within C++ lambdas. In such
cases we need to materialize variables which are not part of the
current frame but instead are ivars on a 'this' pointer of the current
frame.
  • Loading branch information
Michael137 committed Jul 22, 2022
1 parent fcf4e25 commit 317c8bf
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 37 deletions.
22 changes: 22 additions & 0 deletions lldb/include/lldb/Expression/Materializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ class Materializer {
AddPersistentVariable(lldb::ExpressionVariableSP &persistent_variable_sp,
PersistentVariableDelegate *delegate, Status &err);
uint32_t AddVariable(lldb::VariableSP &variable_sp, Status &err);

/// Create entity from supplied ValueObject and count it as a member
/// of the materialized struct.
///
/// Behaviour is undefined if 'valobj_provider' is empty.
///
/// \param[in] name Name of variable to materialize
///
/// \param[in] valobj_provider When materializing values multiple
/// times, this callback gets used to fetch a fresh
/// ValueObject corresponding to the supplied frame.
/// This is mainly used for conditional breakpoints
/// that re-apply an expression whatever the frame
/// happens to be when the breakpoint got hit.
///
/// \param[out] err Error status that gets set on error.
///
/// \returns Offset in bytes of the member we just added to the
/// materialized struct.
uint32_t AddValueObject(ConstString name,
ValueObjectProviderTy valobj_provider, Status &err);

uint32_t AddResultVariable(const CompilerType &type, bool is_lvalue,
bool keep_in_memory,
PersistentVariableDelegate *delegate, Status &err);
Expand Down
6 changes: 6 additions & 0 deletions lldb/include/lldb/lldb-private-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ struct OptionValidator {
typedef struct type128 { uint64_t x[2]; } type128;
typedef struct type256 { uint64_t x[4]; } type256;

/// Functor that returns a ValueObjectSP for a variable given its name
/// and the StackFrame of interest. Used primarily in the Materializer
/// to refetch a ValueObject when the ExecutionContextScope changes.
using ValueObjectProviderTy =
std::function<lldb::ValueObjectSP(ConstString, StackFrame *)>;

} // namespace lldb_private

#endif // #if defined(__cplusplus)
Expand Down
Loading

0 comments on commit 317c8bf

Please sign in to comment.