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

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

#include <UtilityFunction.h>

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

Public Member Functions

 UtilityFunction (ExecutionContextScope &exe_scope, const char *text, const char *name, ExpressionKind kind)
 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 PC 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, ExpressionKind kind)
 
 Expression (ExecutionContextScope &exe_scope, ExpressionKind kind)
 
virtual ~Expression ()
 Destructor. More...
 
virtual lldb::LanguageType Language ()
 Return the language that should be used when parsing. 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 ()
 
ExpressionKind getKind () const
 LLVM-style RTTI support. More...
 

Static Public Member Functions

static bool classof (const Expression *E)
 LLVM-style RTTI support. More...
 

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

Additional Inherited Members

- Public Types inherited from lldb_private::Expression
enum  ExpressionKind {
  eKindFunctionCaller, eKindClangFunctionCaller, eKindUserExpression, eKindLLVMUserExpression,
  eKindClangUserExpression, eKindUtilityFunction, eKindClangUtilityFunction
}
 Discriminator for LLVM-style RTTI (dyn_cast<> et al.) More...
 
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,
const char *  text,
const char *  name,
ExpressionKind  kind 
)

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.

Definition at line 39 of file UtilityFunction.cpp.

Referenced by classof().

◆ ~UtilityFunction()

UtilityFunction::~UtilityFunction ( )
override

Definition at line 47 of file UtilityFunction.cpp.

References m_jit_module_wp, and lldb_private::Expression::m_jit_process_wp.

Referenced by classof().

Member Function Documentation

◆ classof()

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

◆ ContainsAddress()

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

Check whether the given PC is inside the function.

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

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

Definition at line 73 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 85 of file UtilityFunction.h.

References m_function_name.

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

◆ GetFunctionCaller()

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

Definition at line 107 of file UtilityFunction.h.

References m_caller_up.

Referenced by PlatformPOSIX::DoLoadImage().

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

Referenced by classof().

◆ 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 89 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 92 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 95 of file UtilityFunction.h.

References MakeFunctionCaller().

◆ 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 81 of file UtilityFunction.h.

References m_function_text.

Member Data Documentation

◆ m_caller_up

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

Definition at line 115 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 110 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 114 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 112 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: