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

#include <LLVMUserExpression.h>

Inheritance diagram for lldb_private::LLVMUserExpression:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::LLVMUserExpression:
Collaboration 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, lldb::LanguageType 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. More...
 
bool CanInterpret () override
 
MaterializerGetMaterializer () override
 Return the Materializer that the parser should use when registering external values. More...
 
const char * Text () override
 Return the string that the parser should parse. More...
 
- 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, lldb::LanguageType language, ResultType desired_type, const EvaluateExpressionOptions &options)
 Constructor. More...
 
 ~UserExpression () override
 Destructor. More...
 
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. More...
 
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. More...
 
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. More...
 
const char * Text () override
 Return the string that the parser should parse. More...
 
const char * GetUserText ()
 Return the string that the user typed. More...
 
const char * FunctionName () override
 Return the function name that should be used for executing the expression. More...
 
lldb::LanguageType Language () const override
 Return the language that should be used when parsing. More...
 
ResultType DesiredResultType () override
 Return the desired result type of the function, or eResultTypeAny if indifferent. More...
 
bool NeedsValidation () override
 Return true if validation code should be inserted into the expression. More...
 
bool NeedsVariableResolution () override
 Return true if external variables in the expression should be resolved. More...
 
EvaluateExpressionOptionsGetOptions () override
 
virtual lldb::ExpressionVariableSP GetResultAfterDematerialization (ExecutionContextScope *exe_scope)
 
const char * GetFixedText ()
 
- Public Member Functions inherited from lldb_private::Expression
 Expression (Target &target)
 
 Expression (ExecutionContextScope &exe_scope)
 
virtual ~Expression ()=default
 Destructor. More...
 
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. More...
 
virtual void WillStartExecuting ()
 Called to notify the expression that it is about to be executed. More...
 
virtual void DidFinishExecuting ()
 Called to notify the expression that its execution has finished. More...
 
virtual ExpressionTypeSystemHelperGetTypeSystemHelper ()
 

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. More...
 

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
void InstallContext (ExecutionContext &exe_ctx)
 Populate m_in_cplusplus_method and m_in_objectivec_method based on the environment. More...
 
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. More...
 
lldb::addr_t m_stack_frame_top
 The top of the allocated stack frame. More...
 
bool m_allow_cxx
 True if the language allows C++. More...
 
bool m_allow_objc
 True if the language allows Objective-C. More...
 
std::string m_transformed_text
 The text of the expression, as send to the parser. More...
 
std::shared_ptr< IRExecutionUnitm_execution_unit_sp
 The execution unit the expression is stored in. More...
 
std::unique_ptr< Materializerm_materializer_up
 The materializer to use when running the expression. More...
 
lldb::ModuleWP m_jit_module_wp
 
Targetm_target
 The target for storing persistent data like types and variables. More...
 
bool m_can_interpret
 True if the expression could be evaluated statically; false otherwise. More...
 
lldb::addr_t m_materialized_address
 The address at which the arguments to the expression have been materialized. More...
 
Materializer::DematerializerSP m_dematerializer_sp
 The dematerializer. More...
 
- Protected Attributes inherited from lldb_private::UserExpression
Address m_address
 The address the process is stopped in. More...
 
std::string m_expr_text
 The text of the expression, as typed by the user. More...
 
std::string m_expr_prefix
 The text of the translation-level definitions, as provided by the user. More...
 
std::string m_fixed_text
 The text of the expression with fix-its applied. More...
 
lldb::LanguageType m_language
 The language to use when parsing (eLanguageTypeUnknown means use defaults) More...
 
ResultType m_desired_type
 The type to coerce the expression's result to. More...
 
EvaluateExpressionOptions m_options
 Additional options provided by the user. More...
 
- 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... More...
 
lldb::addr_t m_jit_start_addr
 An expression might have a process, but it doesn't need to (e.g. More...
 
lldb::addr_t m_jit_end_addr
 The address of the JITted function within the JIT allocation. More...
 

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. More...
 
- Static Protected Member Functions inherited from lldb_private::UserExpression
static lldb::addr_t GetObjectPointer (lldb::StackFrameSP frame_sp, ConstString &object_name, Status &err)
 

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,
lldb::LanguageType  language,
ResultType  desired_type,
const EvaluateExpressionOptions options 
)

Definition at line 40 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 62 of file LLVMUserExpression.cpp.

References AddArguments(), lldb_private::DiagnosticManager::AppendMessageToDiagnostic(), lldb_private::Status::AsCString(), lldb_private::EvaluateExpressionOptions::DoesIgnoreBreakpoints(), lldb_private::EvaluateExpressionOptions::DoesUnwindOnError(), lldb_private::eDiagnosticSeverityError, lldb_private::eDiagnosticSeverityRemark, lldb::eExpressionCompleted, lldb::eExpressionDiscarded, lldb::eExpressionHitBreakpoint, lldb::eExpressionInterrupted, lldb::eExpressionResultUnavailable, lldb::eExpressionSetupError, lldb::eExpressionStoppedForDebug, lldb::eExpressionThreadVanished, lldb_private::Process::ExecutionResultAsCString(), FinalizeJITExecution(), lldb_private::ThreadPlanCallFunction::GetFunctionStackPointer(), lldb_private::UserID::GetID(), lldb_private::GetLogIfAnyCategoriesSet(), lldb_private::ExecutionContext::GetProcessPtr(), lldb_private::ExecutionContext::GetProcessRef(), lldb_private::ThreadPlanCallUserExpression::GetRealStopInfo(), lldb_private::StreamString::GetString(), lldb_private::ExecutionContext::GetThreadRef(), lldb_private::ExecutionContext::HasThreadScope(), IRInterpreter::Interpret(), LIBLLDB_LOG_EXPRESSIONS, LIBLLDB_LOG_STEP, 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::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_private::eDiagnosticSeverityError, lldb_private::ExecutionContext::GetBestExecutionContextScope(), lldb_private::GetLogIfAllCategoriesSet(), lldb_private::UserExpression::GetResultAfterDematerialization(), LIBLLDB_LOG_EXPRESSIONS, 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: