LLDB mainline
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Attributes | List of all members
lldb_private::LLVMUserExpression Class Referenceabstract

"lldb/Expression/LLVMUserExpression.h" Encapsulates a one-time expression for use in lldb. More...

#include <LLVMUserExpression.h>

Inheritance diagram for lldb_private::LLVMUserExpression:
Inheritance graph
[legend]

Classes

struct  IRPasses
 

Public Member Functions

bool isA (const void *ClassID) const override
 
 LLVMUserExpression (ExecutionContextScope &exe_scope, llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, ResultType desired_type, const EvaluateExpressionOptions &options)
 
 ~LLVMUserExpression () override
 
bool FinalizeJITExecution (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result, lldb::addr_t function_stack_bottom=LLDB_INVALID_ADDRESS, lldb::addr_t function_stack_top=LLDB_INVALID_ADDRESS) override
 Apply the side effects of the function to program state.
 
bool CanInterpret () override
 
MaterializerGetMaterializer () override
 Return the Materializer that the parser should use when registering external values.
 
const char * Text () override
 Return the string that the parser should parse.
 
- Public Member Functions inherited from lldb_private::UserExpression
bool isA (const void *ClassID) const override
 
 UserExpression (ExecutionContextScope &exe_scope, llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, ResultType desired_type, const EvaluateExpressionOptions &options)
 Constructor.
 
 ~UserExpression () override
 Destructor.
 
virtual bool Parse (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory, bool generate_debug_info)=0
 Parse the expression.
 
virtual bool Complete (ExecutionContext &exe_ctx, CompletionRequest &request, unsigned complete_pos)
 Attempts to find possible command line completions for the given (possible incomplete) user expression.
 
virtual bool CanInterpret ()=0
 
bool MatchesContext (ExecutionContext &exe_ctx)
 
lldb::ExpressionResults Execute (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result)
 Execute the parsed expression by callinng the derived class's DoExecute method.
 
virtual bool FinalizeJITExecution (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result, lldb::addr_t function_stack_bottom=LLDB_INVALID_ADDRESS, lldb::addr_t function_stack_top=LLDB_INVALID_ADDRESS)=0
 Apply the side effects of the function to program state.
 
const char * Text () override
 Return the string that the parser should parse.
 
const char * GetUserText ()
 Return the string that the user typed.
 
const char * FunctionName () override
 Return the function name that should be used for executing the expression.
 
virtual bool IsParseCacheable ()
 Returns whether the call to Parse on this user expression is cacheable.
 
SourceLanguage Language () const override
 Return the language that should be used when parsing.
 
ResultType DesiredResultType () const override
 Return the desired result type of the function, or eResultTypeAny if indifferent.
 
bool NeedsValidation () override
 Return true if validation code should be inserted into the expression.
 
bool NeedsVariableResolution () override
 Return true if external variables in the expression should be resolved.
 
EvaluateExpressionOptionsGetOptions () override
 
virtual lldb::ExpressionVariableSP GetResultAfterDematerialization (ExecutionContextScope *exe_scope)
 
llvm::StringRef GetFixedText ()
 
- Public Member Functions inherited from lldb_private::Expression
 Expression (Target &target)
 
 Expression (ExecutionContextScope &exe_scope)
 
virtual ~Expression ()=default
 Destructor.
 
virtual const char * Text ()=0
 Return the string that the parser should parse.
 
virtual const char * FunctionName ()=0
 Return the function name that should be used for executing the expression.
 
virtual SourceLanguage Language () const
 Return the language that should be used when parsing.
 
virtual MaterializerGetMaterializer ()
 Return the Materializer that the parser should use when registering external values.
 
virtual ResultType DesiredResultType () const
 Return the desired result type of the function, or eResultTypeAny if indifferent.
 
virtual bool NeedsValidation ()=0
 Flags.
 
virtual bool NeedsVariableResolution ()=0
 Return true if external variables in the expression should be resolved.
 
virtual EvaluateExpressionOptionsGetOptions ()
 
lldb::addr_t StartAddress ()
 Return the address of the function's JIT-compiled code, or LLDB_INVALID_ADDRESS if the function is not JIT compiled.
 
virtual void WillStartExecuting ()
 Called to notify the expression that it is about to be executed.
 
virtual void DidFinishExecuting ()
 Called to notify the expression that its execution has finished.
 
virtual ExpressionTypeSystemHelperGetTypeSystemHelper ()
 
virtual bool isA (const void *ClassID) const =0
 

Static Public Member Functions

static bool classof (const Expression *obj)
 
- Static Public Member Functions inherited from lldb_private::UserExpression
static bool classof (const Expression *obj)
 
static lldb::ExpressionResults Evaluate (ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, Status &error, std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
 Evaluate one expression in the scratch context of the target passed in the exe_ctx and return its result.
 

Protected Member Functions

lldb::ExpressionResults DoExecute (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result) override
 
virtual void ScanContext (ExecutionContext &exe_ctx, lldb_private::Status &err)=0
 
bool PrepareToExecuteJITExpression (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb::addr_t &struct_address)
 
virtual bool AddArguments (ExecutionContext &exe_ctx, std::vector< lldb::addr_t > &args, lldb::addr_t struct_address, DiagnosticManager &diagnostic_manager)=0
 
- Protected Member Functions inherited from lldb_private::UserExpression
virtual lldb::ExpressionResults DoExecute (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me, lldb::ExpressionVariableSP &result)=0
 
void InstallContext (ExecutionContext &exe_ctx)
 Populate m_in_cplusplus_method and m_in_objectivec_method based on the environment.
 
bool LockAndCheckContext (ExecutionContext &exe_ctx, lldb::TargetSP &target_sp, lldb::ProcessSP &process_sp, lldb::StackFrameSP &frame_sp)
 

Protected Attributes

lldb::addr_t m_stack_frame_bottom
 The bottom of the allocated stack frame.
 
lldb::addr_t m_stack_frame_top
 The top of the allocated stack frame.
 
bool m_allow_cxx
 True if the language allows C++.
 
bool m_allow_objc
 True if the language allows Objective-C.
 
std::string m_transformed_text
 The text of the expression, as send to the parser.
 
std::shared_ptr< IRExecutionUnitm_execution_unit_sp
 The execution unit the expression is stored in.
 
std::unique_ptr< Materializerm_materializer_up
 The materializer to use when running the expression.
 
lldb::ModuleWP m_jit_module_wp
 
Targetm_target
 The target for storing persistent data like types and variables.
 
bool m_can_interpret
 True if the expression could be evaluated statically; false otherwise.
 
lldb::addr_t m_materialized_address
 The address at which the arguments to the expression have been materialized.
 
Materializer::DematerializerSP m_dematerializer_sp
 The dematerializer.
 
- Protected Attributes inherited from lldb_private::UserExpression
Address m_address
 The address the process is stopped in.
 
std::string m_expr_text
 The text of the expression, as typed by the user.
 
std::string m_expr_prefix
 The text of the translation-level definitions, as provided by the user.
 
std::string m_fixed_text
 The text of the expression with fix-its applied this won't be set if the fixed text doesn't parse.
 
SourceLanguage m_language
 The language to use when parsing (unknown means use defaults).
 
ResultType m_desired_type
 The type to coerce the expression's result to.
 
EvaluateExpressionOptions m_options
 Additional options provided by the user.
 
- Protected Attributes inherited from lldb_private::Expression
lldb::TargetWP m_target_wp
 
lldb::ProcessWP m_jit_process_wp
 Expression's always have to have a target...
 
lldb::addr_t m_jit_start_addr
 An expression might have a process, but it doesn't need to (e.g.
 
lldb::addr_t m_jit_end_addr
 The address of the JITted function within the JIT allocation.
 

Static Private Attributes

static char ID
 

Additional Inherited Members

- Public Types inherited from lldb_private::UserExpression
enum  { kDefaultTimeout = 500000u }
 
- Public Types inherited from lldb_private::Expression
enum  ResultType { eResultTypeAny , eResultTypeId }
 
- Static Public Attributes inherited from lldb_private::UserExpression
static const Status::ValueType kNoResult
 ValueObject::GetError() returns this if there is no result from the expression.
 
- Static Protected Member Functions inherited from lldb_private::UserExpression
static lldb::addr_t GetObjectPointer (lldb::StackFrameSP frame_sp, llvm::StringRef object_name, Status &err)
 
static lldb::ValueObjectSP GetObjectPointerValueObject (lldb::StackFrameSP frame, llvm::StringRef object_name, Status &err)
 Return ValueObject for a given variable name in the current stack frame.
 

Detailed Description

"lldb/Expression/LLVMUserExpression.h" Encapsulates a one-time expression for use in lldb.

LLDB uses expressions for various purposes, notably to call functions and as a backend for the expr command. LLVMUserExpression is a virtual base class that encapsulates the objects needed to parse and JIT an expression. The actual parsing part will be provided by the specific implementations of LLVMUserExpression - which will be vended through the appropriate TypeSystem.

Definition at line 32 of file LLVMUserExpression.h.

Constructor & Destructor Documentation

◆ LLVMUserExpression()

LLVMUserExpression::LLVMUserExpression ( ExecutionContextScope exe_scope,
llvm::StringRef  expr,
llvm::StringRef  prefix,
SourceLanguage  language,
ResultType  desired_type,
const EvaluateExpressionOptions options 
)

Definition at line 42 of file LLVMUserExpression.cpp.

◆ ~LLVMUserExpression()

LLVMUserExpression::~LLVMUserExpression ( )
override

Member Function Documentation

◆ AddArguments()

virtual bool lldb_private::LLVMUserExpression::AddArguments ( ExecutionContext exe_ctx,
std::vector< lldb::addr_t > &  args,
lldb::addr_t  struct_address,
DiagnosticManager diagnostic_manager 
)
protectedpure virtual

Implemented in lldb_private::ClangUserExpression.

Referenced by DoExecute().

◆ CanInterpret()

bool lldb_private::LLVMUserExpression::CanInterpret ( )
inlineoverridevirtual

Implements lldb_private::UserExpression.

Definition at line 66 of file LLVMUserExpression.h.

References m_can_interpret.

◆ classof()

static bool lldb_private::LLVMUserExpression::classof ( const Expression obj)
inlinestatic

Definition at line 40 of file LLVMUserExpression.h.

References ID, and lldb_private::Expression::isA().

◆ DoExecute()

lldb::ExpressionResults LLVMUserExpression::DoExecute ( DiagnosticManager diagnostic_manager,
ExecutionContext exe_ctx,
const EvaluateExpressionOptions options,
lldb::UserExpressionSP shared_ptr_to_me,
lldb::ExpressionVariableSP result 
)
overrideprotectedvirtual

Implements lldb_private::UserExpression.

Definition at line 64 of file LLVMUserExpression.cpp.

References AddArguments(), lldb_private::DiagnosticManager::AppendMessageToDiagnostic(), lldb_private::Status::AsCString(), lldb_private::EvaluateExpressionOptions::DoesIgnoreBreakpoints(), lldb_private::EvaluateExpressionOptions::DoesUnwindOnError(), lldb::eExpressionCompleted, lldb::eExpressionDiscarded, lldb::eExpressionHitBreakpoint, lldb::eExpressionInterrupted, lldb::eExpressionResultUnavailable, lldb::eExpressionSetupError, lldb::eExpressionStoppedForDebug, lldb::eExpressionThreadVanished, lldb::eSeverityError, lldb::eSeverityInfo, lldb_private::Process::ExecutionResultAsCString(), lldb_private::Expressions, FinalizeJITExecution(), lldb_private::ThreadPlanCallFunction::GetFunctionStackPointer(), lldb_private::UserID::GetID(), lldb_private::GetLog(), lldb_private::ExecutionContext::GetProcessPtr(), lldb_private::ExecutionContext::GetProcessRef(), lldb_private::ThreadPlanCallUserExpression::GetRealStopInfo(), lldb_private::StreamString::GetString(), lldb_private::ExecutionContext::GetThreadRef(), lldb_private::EvaluateExpressionOptions::GetTimeout(), lldb_private::ExecutionContext::HasThreadScope(), IRInterpreter::Interpret(), LLDB_INVALID_ADDRESS, LLDB_LOGF, m_can_interpret, m_execution_unit_sp, lldb_private::Expression::m_jit_start_addr, m_stack_frame_bottom, m_stack_frame_top, PrepareToExecuteJITExpression(), lldb_private::DiagnosticManager::Printf(), lldb_private::DiagnosticManager::PutString(), lldb_private::Process::RunThreadPlan(), lldb_private::Process::SetRunningUserExpression(), lldb_private::Step, lldb_private::Status::Success(), and lldb_private::ThreadPlanCallUserExpression::TransferExpressionOwnership().

◆ FinalizeJITExecution()

bool LLVMUserExpression::FinalizeJITExecution ( DiagnosticManager diagnostic_manager,
ExecutionContext exe_ctx,
lldb::ExpressionVariableSP result,
lldb::addr_t  function_stack_bottom = LLDB_INVALID_ADDRESS,
lldb::addr_t  function_stack_top = LLDB_INVALID_ADDRESS 
)
overridevirtual

Apply the side effects of the function to program state.

Parameters
[in]diagnostic_managerA diagnostic manager to report errors to.
[in]exe_ctxThe execution context to use when looking up entities that are needed for parsing (locations of variables, etc.)
[in]resultA pointer to direct at the persistent variable in which the expression's result is stored.
[in]function_stack_bottomA pointer to the bottom of the function's stack frame. This is used to determine whether the expression result resides in memory that will still be valid, or whether it needs to be treated as homeless for the purpose of future expressions.
[in]function_stack_topA pointer to the top of the function's stack frame. This is used to determine whether the expression result resides in memory that will still be valid, or whether it needs to be treated as homeless for the purpose of future expressions.
Returns
A Process::Execution results value.

Implements lldb_private::UserExpression.

Definition at line 253 of file LLVMUserExpression.cpp.

References lldb_private::Status::AsCString(), lldb::eSeverityError, lldb_private::Expressions, lldb_private::ExecutionContext::GetBestExecutionContextScope(), lldb_private::GetLog(), lldb_private::UserExpression::GetResultAfterDematerialization(), LLDB_LOGF, m_dematerializer_sp, lldb_private::DiagnosticManager::Printf(), and lldb_private::Status::Success().

Referenced by DoExecute().

◆ GetMaterializer()

Materializer * lldb_private::LLVMUserExpression::GetMaterializer ( )
inlineoverridevirtual

Return the Materializer that the parser should use when registering external values.

Reimplemented from lldb_private::Expression.

Definition at line 68 of file LLVMUserExpression.h.

References m_materializer_up.

Referenced by lldb_private::ClangUserExpression::Complete(), and lldb_private::ClangUserExpression::TryParse().

◆ isA()

bool lldb_private::LLVMUserExpression::isA ( const void *  ClassID) const
inlineoverridevirtual

◆ PrepareToExecuteJITExpression()

bool LLVMUserExpression::PrepareToExecuteJITExpression ( DiagnosticManager diagnostic_manager,
ExecutionContext exe_ctx,
lldb::addr_t struct_address 
)
protected

◆ ScanContext()

virtual void lldb_private::LLVMUserExpression::ScanContext ( ExecutionContext exe_ctx,
lldb_private::Status err 
)
protectedpure virtual

◆ Text()

const char * lldb_private::LLVMUserExpression::Text ( )
inlineoverridevirtual

Return the string that the parser should parse.

Must be a full translation unit.

Implements lldb_private::Expression.

Definition at line 72 of file LLVMUserExpression.h.

References m_transformed_text.

Member Data Documentation

◆ ID

char LLVMUserExpression::ID
staticprivate

Definition at line 34 of file LLVMUserExpression.h.

Referenced by classof(), and isA().

◆ m_allow_cxx

bool lldb_private::LLVMUserExpression::m_allow_cxx
protected

True if the language allows C++.

Definition at line 97 of file LLVMUserExpression.h.

Referenced by lldb_private::ClangUserExpression::ClangUserExpression(), and lldb_private::ClangUserExpression::ScanContext().

◆ m_allow_objc

bool lldb_private::LLVMUserExpression::m_allow_objc
protected

True if the language allows Objective-C.

Definition at line 98 of file LLVMUserExpression.h.

Referenced by lldb_private::ClangUserExpression::ClangUserExpression(), and lldb_private::ClangUserExpression::ScanContext().

◆ m_can_interpret

bool lldb_private::LLVMUserExpression::m_can_interpret
protected

True if the expression could be evaluated statically; false otherwise.

Definition at line 111 of file LLVMUserExpression.h.

Referenced by CanInterpret(), DoExecute(), PrepareToExecuteJITExpression(), and lldb_private::ClangUserExpression::TryParse().

◆ m_dematerializer_sp

Materializer::DematerializerSP lldb_private::LLVMUserExpression::m_dematerializer_sp
protected

The dematerializer.

Definition at line 116 of file LLVMUserExpression.h.

Referenced by FinalizeJITExecution(), and PrepareToExecuteJITExpression().

◆ m_execution_unit_sp

std::shared_ptr<IRExecutionUnit> lldb_private::LLVMUserExpression::m_execution_unit_sp
protected

The execution unit the expression is stored in.

Definition at line 103 of file LLVMUserExpression.h.

Referenced by DoExecute(), lldb_private::ClangUserExpression::Parse(), PrepareToExecuteJITExpression(), and lldb_private::ClangUserExpression::TryParse().

◆ m_jit_module_wp

lldb::ModuleWP lldb_private::LLVMUserExpression::m_jit_module_wp
protected

◆ m_materialized_address

lldb::addr_t lldb_private::LLVMUserExpression::m_materialized_address
protected

The address at which the arguments to the expression have been materialized.

Definition at line 113 of file LLVMUserExpression.h.

Referenced by PrepareToExecuteJITExpression().

◆ m_materializer_up

std::unique_ptr<Materializer> lldb_private::LLVMUserExpression::m_materializer_up
protected

The materializer to use when running the expression.

Definition at line 104 of file LLVMUserExpression.h.

Referenced by lldb_private::ClangUserExpression::Complete(), GetMaterializer(), PrepareToExecuteJITExpression(), and lldb_private::ClangUserExpression::TryParse().

◆ m_stack_frame_bottom

lldb::addr_t lldb_private::LLVMUserExpression::m_stack_frame_bottom
protected

The bottom of the allocated stack frame.

Definition at line 94 of file LLVMUserExpression.h.

Referenced by DoExecute(), and PrepareToExecuteJITExpression().

◆ m_stack_frame_top

lldb::addr_t lldb_private::LLVMUserExpression::m_stack_frame_top
protected

The top of the allocated stack frame.

Definition at line 95 of file LLVMUserExpression.h.

Referenced by DoExecute(), and PrepareToExecuteJITExpression().

◆ m_target

Target* lldb_private::LLVMUserExpression::m_target
protected

◆ m_transformed_text

std::string lldb_private::LLVMUserExpression::m_transformed_text
protected

The documentation for this class was generated from the following files: