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/Core/Log.h"
17 #include "lldb/Core/Stream.h"
18 #include "lldb/Target/Process.h"
19 #include "lldb/Target/RegisterContext.h"
20 #include "lldb/Target/Target.h"
21 #include "lldb/Target/Thread.h"
24 using namespace lldb_private;
26 //--------------------------------------------------------------------------------------------
27 // ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI instead of JIT
28 //-------------------------------------------------------------------------------------------
29 ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI (Thread &thread,
30 const Address &function,
31 llvm::Type &prototype,
32 llvm::Type &return_type,
33 llvm::ArrayRef<ABI::CallArgument> args,
34 const EvaluateExpressionOptions &options) :
35 ThreadPlanCallFunction(thread,function,options),
36 m_return_type(return_type)
38 lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
39 lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
42 if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))
45 if (!abi->PrepareTrivialCall(thread,
53 ReportRegisterState("ABI Function call was set up. Register state was:");
58 ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default;
61 ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s, DescriptionLevel level)
63 if (level == eDescriptionLevelBrief)
65 s->Printf("Function call thread plan using ABI instead of JIT");
69 TargetSP target_sp(m_thread.CalculateTarget());
70 s->Printf("Thread plan to call 0x%" PRIx64" using ABI instead of JIT", m_function_addr.GetLoadAddress(target_sp.get()));
75 ThreadPlanCallFunctionUsingABI::SetReturnValue()
77 ProcessSP process_sp(m_thread.GetProcess());
78 const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
80 // Ask the abi for the return value
83 const bool persistent = false;
84 m_return_valobj_sp = abi->GetReturnValueObject(m_thread, m_return_type, persistent);