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

#include <UtilityFunction.h>

Inheritance diagram for lldb_private::UtilityFunction:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::UtilityFunction:
Collaboration graph
[legend]

Public Member Functions

bool isA (const void *ClassID) const override
 
 UtilityFunction (ExecutionContextScope &exe_scope, std::string text, std::string name, bool enable_debugging)
 Constructor. More...
 
 ~UtilityFunction () override
 
virtual bool Install (DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx)=0
 Install the utility function into a process. More...
 
bool ContainsAddress (lldb::addr_t address)
 Check whether the given address is inside the function. More...
 
const char * Text () override
 Return the string that the parser should parse. More...
 
const char * FunctionName () override
 Return the function name that should be used for executing the expression. More...
 
ExpressionVariableListLocalVariables ()
 Return the object that the parser should use when registering local variables. 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...
 
FunctionCallerMakeFunctionCaller (const CompilerType &return_type, const ValueList &arg_value_list, lldb::ThreadSP compilation_thread, Status &error)
 
FunctionCallerGetFunctionCaller ()
 
- Public Member Functions inherited from lldb_private::Expression
 Expression (Target &target)
 
 Expression (ExecutionContextScope &exe_scope)
 
virtual ~Expression ()=default
 Destructor. More...
 
virtual lldb::LanguageType Language () const
 Return the language that should be used when parsing. More...
 
virtual MaterializerGetMaterializer ()
 Return the Materializer that the parser should use when registering external values. More...
 
virtual ResultType DesiredResultType ()
 Return the desired result type of the function, or eResultTypeAny if indifferent. More...
 
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. 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)
 

Protected Attributes

std::shared_ptr< IRExecutionUnitm_execution_unit_sp
 
lldb::ModuleWP m_jit_module_wp
 
std::string m_function_text
 The text of the function. Must be a well-formed translation unit. More...
 
std::string m_function_name
 The name of the function. More...
 
std::unique_ptr< FunctionCallerm_caller_up
 
- 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::Expression
enum  ResultType { eResultTypeAny, eResultTypeId }
 

Detailed Description

"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that is callable

LLDB uses expressions for various purposes, notably to call functions and as a backend for the expr command. UtilityFunction encapsulates a self-contained function meant to be used from other code. Utility functions can perform error-checking for ClangUserExpressions,

Definition at line 30 of file UtilityFunction.h.

Constructor & Destructor Documentation

◆ UtilityFunction()

UtilityFunction::UtilityFunction ( ExecutionContextScope exe_scope,
std::string  text,
std::string  name,
bool  enable_debugging 
)

Constructor.

Parameters
[in]textThe text of the function. Must be a full translation unit.
[in]nameThe name of the function, as used in the text.
[in]enable_debuggingEnable debugging of this function.
[in]textThe text of the function. Must be a full translation unit.
[in]nameThe name of the function, as used in the text.

Definition at line 38 of file UtilityFunction.cpp.

◆ ~UtilityFunction()

UtilityFunction::~UtilityFunction ( )
override

Member Function Documentation

◆ classof()

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

Definition at line 36 of file UtilityFunction.h.

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

◆ ContainsAddress()

bool lldb_private::UtilityFunction::ContainsAddress ( lldb::addr_t  address)
inline

Check whether the given address is inside the function.

Especially useful if the function dereferences nullptr to indicate a failed assert.

Parameters
[in]addressThe address to check.
Returns
True if the address falls within the function's bounds; false if not (or the function is not JIT compiled)

Definition at line 77 of file UtilityFunction.h.

References lldb_private::Expression::m_jit_end_addr, and lldb_private::Expression::m_jit_start_addr.

◆ FunctionName()

const char* lldb_private::UtilityFunction::FunctionName ( )
inlineoverridevirtual

Return the function name that should be used for executing the expression.

Text() should contain the definition of this function.

Implements lldb_private::Expression.

Definition at line 89 of file UtilityFunction.h.

References m_function_name.

Referenced by lldb_private::ClangUtilityFunction::Install().

◆ GetFunctionCaller()

FunctionCaller* lldb_private::UtilityFunction::GetFunctionCaller ( )
inline

◆ Install()

virtual bool lldb_private::UtilityFunction::Install ( DiagnosticManager diagnostic_manager,
ExecutionContext exe_ctx 
)
pure virtual

Install the utility function into a process.

Parameters
[in]diagnostic_managerA diagnostic manager to print parse errors and warnings to.
[in]exe_ctxThe execution context to install the utility function to.
Returns
True on success (no errors); false otherwise.

Implemented in lldb_private::ClangUtilityFunction.

◆ isA()

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

Implements lldb_private::Expression.

Reimplemented in lldb_private::ClangUtilityFunction.

Definition at line 35 of file UtilityFunction.h.

References ID.

Referenced by lldb_private::ClangUtilityFunction::isA().

◆ LocalVariables()

ExpressionVariableList* lldb_private::UtilityFunction::LocalVariables ( )
inline

Return the object that the parser should use when registering local variables.

May be nullptr if the Expression doesn't care.

Definition at line 93 of file UtilityFunction.h.

◆ MakeFunctionCaller()

FunctionCaller * UtilityFunction::MakeFunctionCaller ( const CompilerType return_type,
const ValueList arg_value_list,
lldb::ThreadSP  compilation_thread,
Status error 
)

◆ NeedsValidation()

bool lldb_private::UtilityFunction::NeedsValidation ( )
inlineoverridevirtual

Return true if validation code should be inserted into the expression.

Implements lldb_private::Expression.

Definition at line 96 of file UtilityFunction.h.

◆ NeedsVariableResolution()

bool lldb_private::UtilityFunction::NeedsVariableResolution ( )
inlineoverridevirtual

Return true if external variables in the expression should be resolved.

Implements lldb_private::Expression.

Definition at line 99 of file UtilityFunction.h.

◆ Text()

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

Return the string that the parser should parse.

Must be a full translation unit.

Implements lldb_private::Expression.

Definition at line 85 of file UtilityFunction.h.

References m_function_text.

Member Data Documentation

◆ ID

char UtilityFunction::ID
staticprivate

Definition at line 32 of file UtilityFunction.h.

Referenced by classof(), and isA().

◆ m_caller_up

std::unique_ptr<FunctionCaller> lldb_private::UtilityFunction::m_caller_up
protected

Definition at line 120 of file UtilityFunction.h.

Referenced by GetFunctionCaller(), and MakeFunctionCaller().

◆ m_execution_unit_sp

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

Definition at line 114 of file UtilityFunction.h.

Referenced by lldb_private::ClangUtilityFunction::Install().

◆ m_function_name

std::string lldb_private::UtilityFunction::m_function_name
protected

The name of the function.

Definition at line 119 of file UtilityFunction.h.

Referenced by FunctionName(), and MakeFunctionCaller().

◆ m_function_text

std::string lldb_private::UtilityFunction::m_function_text
protected

The text of the function. Must be a well-formed translation unit.

Definition at line 117 of file UtilityFunction.h.

Referenced by lldb_private::ClangUtilityFunction::ClangUtilityFunction(), and Text().

◆ m_jit_module_wp

lldb::ModuleWP lldb_private::UtilityFunction::m_jit_module_wp
protected

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