//===-- FunctionCaller.h ----------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLDB_EXPRESSION_FUNCTIONCALLER_H #define LLDB_EXPRESSION_FUNCTIONCALLER_H #include <list> #include <memory> #include <string> #include <vector> #include "lldb/Core/Address.h" #include "lldb/Core/Value.h" #include "lldb/Expression/Expression.h" #include "lldb/Expression/ExpressionParser.h" #include "lldb/Symbol/CompilerType.h" namespace lldb_private { /// \class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h" /// Encapsulates a function that can be called. /// /// A given FunctionCaller object can handle a single function signature. /// Once constructed, it can set up any number of concurrent calls to /// functions with that signature. /// /// It performs the call by synthesizing a structure that contains the pointer /// to the function and the arguments that should be passed to that function, /// and producing a special-purpose JIT-compiled function that accepts a void* /// pointing to this struct as its only argument and calls the function in the /// struct with the written arguments. This method lets Clang handle the /// vagaries of function calling conventions. /// /// The simplest use of the FunctionCaller is to construct it with a function /// representative of the signature you want to use, then call /// ExecuteFunction(ExecutionContext &, Stream &, Value &). /// /// If you need to reuse the arguments for several calls, you can call /// InsertFunction() followed by WriteFunctionArguments(), which will return /// the location of the args struct for the wrapper function in args_addr_ref. /// /// If you need to call the function on the thread plan stack, you can also /// call InsertFunction() followed by GetThreadPlanToCallFunction(). /// /// Any of the methods that take arg_addr_ptr or arg_addr_ref can be passed a /// pointer set to LLDB_INVALID_ADDRESS and new structure will be allocated /// and its address returned in that variable. /// /// Any of the methods that take arg_addr_ptr can be passed nullptr, and the /// argument space will be managed for you. class FunctionCaller : public Expression { … }; } // namespace lldb_private #endif // LLDB_EXPRESSION_FUNCTIONCALLER_H