42 :
Expression(exe_scope), m_execution_unit_sp(), m_parser(),
43 m_jit_module_wp(), m_name(name ? name :
"<unknown>"),
44 m_function_ptr(nullptr), m_function_addr(functionAddress),
45 m_function_return_type(return_type),
46 m_wrapper_function_name(
"__lldb_caller_function"),
47 m_wrapper_struct_name(
"__lldb_caller_struct"), m_wrapper_args_addrs(),
48 m_struct_valid(false), m_struct_size(0), m_return_size(0),
49 m_return_offset(0), m_arg_values(arg_value_list), m_compiled(false),
62 process_sp->GetTarget().GetImages().Remove(jit_module_sp);
77 if (process != jit_process_sp.get()) {
79 "process does not match the stored process.");
96 bool can_interpret =
false;
104 "Error in PrepareForExecution: %s.",
109 if (
m_parser->GetGenerateDebugInfo()) {
116 jit_module_sp->SetFileSpecAndObjectName(jit_file,
ConstString());
147 "Argument information was not correctly "
148 "parsed, so the function cannot be called.");
157 if (process ==
nullptr)
162 if (process != jit_process_sp.get())
167 m_struct_size, lldb::ePermissionsReadable | lldb::ePermissionsWritable,
191 size_t num_args = arg_values.
GetSize();
193 diagnostic_manager.
Printf(
195 "Wrong number of arguments - was: %" PRIu64
" should be: %" PRIu64
"",
200 for (
size_t i = 0; i < num_args; i++) {
248 LLDB_LOGF(log,
"Call Address: 0x%" PRIx64
" Struct Address: 0x%" PRIx64
".\n",
261 "-- [FunctionCaller::GetThreadPlanToCallFunction] Creating "
262 "thread plan to call function \"%s\" --",
267 if (thread ==
nullptr) {
280 *thread, wrapper_address,
CompilerType(), args, options));
281 new_plan_sp->SetIsControllingPlan(
true);
282 new_plan_sp->SetOkayToDiscard(
false);
299 "-- [FunctionCaller::FetchFunctionResults] Fetching function "
300 "results for \"%s\"--",
305 if (process ==
nullptr)
310 if (process != jit_process_sp.get())
327 std::list<lldb::addr_t>::iterator pos;
349 const bool enable_debugging =
360 if (args_addr_ptr !=
nullptr)
361 args_addr = *args_addr_ptr;
376 "== [FunctionCaller::ExecuteFunction] Executing function \"%s\" ==",
380 exe_ctx, args_addr, real_options, diagnostic_manager);
391 exe_ctx, call_plan_sp, real_options, diagnostic_manager);
396 "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
397 "completed abnormally: %s ==",
401 "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
402 "completed normally ==",
410 if (args_addr_ptr !=
nullptr)
411 *args_addr_ptr = args_addr;
418 if (args_addr_ptr ==
nullptr)
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
A section + offset based address class.
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
Generic representation of a type in a programming language.
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
A class to manage flag bits.
size_t void PutString(lldb::Severity severity, llvm::StringRef str)
size_t Printf(lldb::Severity severity, const char *format,...) __attribute__((format(printf
void SetUnwindOnError(bool unwind=false)
void SetIgnoreBreakpoints(bool ignore=false)
void SetGenerateDebugInfo(bool b)
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
virtual lldb::ProcessSP CalculateProcess()=0
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process & GetProcessRef() const
Returns a reference to the process object.
Target * GetTargetPtr() const
Returns a pointer to the target object.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
Encapsulates a single expression for use in lldb.
lldb::addr_t m_jit_end_addr
The address of the JITted function within the JIT allocation.
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.
void SetFilename(ConstString filename)
Filename string set accessor.
std::list< lldb::addr_t > m_wrapper_args_addrs
The addresses of the arguments to the wrapper function.
FunctionCaller(ExecutionContextScope &exe_scope, const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name)
Constructor.
~FunctionCaller() override
Destructor.
Address m_function_addr
If we don't have the FunctionSP, we at least need the address & return type.
size_t m_struct_size
These values are populated by the ASTStructExtractor.
void DeallocateFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr)
Deallocate the arguments structure.
uint64_t m_return_offset
The offset of the result variable in the struct, in bytes.
bool m_struct_valid
True if the ASTStructExtractor has populated the variables below.
bool InsertFunction(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager)
Insert the default function wrapper and its default argument struct.
ValueList m_arg_values
The default values of the arguments.
lldb::ExpressionResults ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager, Value &results)
Run the function this FunctionCaller was created with.
lldb::ThreadPlanSP GetThreadPlanToCallFunction(ExecutionContext &exe_ctx, lldb::addr_t args_addr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager)
Get a thread plan to run the function this FunctionCaller was created with.
virtual unsigned CompileFunction(lldb::ThreadSP thread_to_use_sp, DiagnosticManager &diagnostic_manager)=0
Compile the wrapper function.
bool FetchFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value)
Get the result of the function from its struct.
CompilerType m_function_return_type
The opaque clang qual type for the function return type.
bool WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager)
Insert the default function argument struct.
uint64_t m_return_size
The size of the result variable, in bytes.
bool m_compiled
True if the wrapper function has already been parsed.
std::string m_name
The name of this clang function - for debugging purposes.
bool m_JITted
True if the wrapper function has already been JIT-compiled.
std::shared_ptr< IRExecutionUnit > m_execution_unit_sp
lldb::ModuleWP m_jit_module_wp
std::unique_ptr< ExpressionParser > m_parser
The parser responsible for compiling the function.
const char * FunctionName() override
Return the function name that should be used for executing the expression.
std::vector< uint64_t > m_member_offsets
The offset of each member in the struct, in bytes.
bool WriteFunctionWrapper(ExecutionContext &exe_ctx, DiagnosticManager &diagnostic_manager)
Insert the default function wrapper (using the JIT)
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
A plug-in interface definition class for debugging a process.
lldb::ExpressionResults RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager)
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process.
lldb::StateType GetState()
Get accessor for the current process state.
void SetRunningUserExpression(bool on)
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
Status DeallocateMemory(lldb::addr_t ptr)
The public interface to deallocating memory in the process.
uint32_t GetAddressByteSize() const
size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar, size_t size, Status &error)
Write all or part of a scalar value to memory.
Target & GetTarget()
Get the target object pointer for this module.
A Progress indicator helper class.
size_t GetByteSize() const
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
bool Success() const
Test for success condition.
bool GetDebugUtilityExpression() const
const ModuleList & GetImages() const
Get accessor for the images for this process.
Value * GetValueAtIndex(size_t idx)
const Scalar & GetScalar() const
@ HostAddress
A host address value (for memory in the process that < A is using liblldb).
@ Scalar
A raw scalar value.
ValueType GetValueType() const
void SetCompilerType(const CompilerType &compiler_type)
Scalar & ResolveValue(ExecutionContext *exe_ctx, Module *module=nullptr)
void SetValueType(ValueType value_type)
ContextType GetContextType() const
const CompilerType & GetCompilerType()
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
const char * toString(AppleArm64ExceptionClass EC)
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
@ eStateStopped
Process or thread is stopped and can be examined.
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Process > ProcessSP
std::weak_ptr< lldb_private::Process > ProcessWP
std::shared_ptr< lldb_private::Module > ModuleSP