1 //===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // Other libraries and framework includes
14 #include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
15 #include "lldb/Core/Address.h"
16 #include "lldb/Target/Process.h"
17 #include "lldb/Target/RegisterContext.h"
18 #include "lldb/Target/Target.h"
19 #include "lldb/Target/Thread.h"
20 #include "lldb/Utility/Log.h"
21 #include "lldb/Utility/Stream.h"
24 using namespace lldb_private;
26 //--------------------------------------------------------------------------------------------
27 // ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI
29 //-------------------------------------------------------------------------------------------
30 ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI(
31 Thread &thread, const Address &function, llvm::Type &prototype,
32 llvm::Type &return_type, llvm::ArrayRef<ABI::CallArgument> args,
33 const EvaluateExpressionOptions &options)
34 : ThreadPlanCallFunction(thread, function, options),
35 m_return_type(return_type) {
36 lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
37 lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
40 if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))
43 if (!abi->PrepareTrivialCall(thread, m_function_sp, function_load_addr,
44 start_load_addr, prototype, args))
47 ReportRegisterState("ABI Function call was set up. Register state was:");
52 ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default;
54 void ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s,
55 DescriptionLevel level) {
56 if (level == eDescriptionLevelBrief) {
57 s->Printf("Function call thread plan using ABI instead of JIT");
59 TargetSP target_sp(m_thread.CalculateTarget());
60 s->Printf("Thread plan to call 0x%" PRIx64 " using ABI instead of JIT",
61 m_function_addr.GetLoadAddress(target_sp.get()));
65 void ThreadPlanCallFunctionUsingABI::SetReturnValue() {
66 ProcessSP process_sp(m_thread.GetProcess());
67 const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
69 // Ask the abi for the return value
71 const bool persistent = false;
73 abi->GetReturnValueObject(m_thread, m_return_type, persistent);