1 //===-- ThreadPlanCallFunctionUsingABI.cpp --------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
10 #include "lldb/Core/Address.h"
11 #include "lldb/Target/Process.h"
12 #include "lldb/Target/RegisterContext.h"
13 #include "lldb/Target/Target.h"
14 #include "lldb/Target/Thread.h"
15 #include "lldb/Utility/Log.h"
16 #include "lldb/Utility/Stream.h"
19 using namespace lldb_private
;
21 // ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI
23 ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI(
24 Thread
&thread
, const Address
&function
, llvm::Type
&prototype
,
25 llvm::Type
&return_type
, llvm::ArrayRef
<ABI::CallArgument
> args
,
26 const EvaluateExpressionOptions
&options
)
27 : ThreadPlanCallFunction(thread
, function
, options
),
28 m_return_type(return_type
) {
29 lldb::addr_t start_load_addr
= LLDB_INVALID_ADDRESS
;
30 lldb::addr_t function_load_addr
= LLDB_INVALID_ADDRESS
;
33 if (!ConstructorSetup(thread
, abi
, start_load_addr
, function_load_addr
))
36 if (!abi
->PrepareTrivialCall(thread
, m_function_sp
, function_load_addr
,
37 start_load_addr
, prototype
, args
))
40 ReportRegisterState("ABI Function call was set up. Register state was:");
45 ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default;
47 void ThreadPlanCallFunctionUsingABI::GetDescription(Stream
*s
,
48 DescriptionLevel level
) {
49 if (level
== eDescriptionLevelBrief
) {
50 s
->Printf("Function call thread plan using ABI instead of JIT");
52 s
->Printf("Thread plan to call 0x%" PRIx64
" using ABI instead of JIT",
53 m_function_addr
.GetLoadAddress(&GetTarget()));
57 void ThreadPlanCallFunctionUsingABI::SetReturnValue() {
58 const ABI
*abi
= m_process
.GetABI().get();
60 // Ask the abi for the return value
62 const bool persistent
= false;
64 abi
->GetReturnValueObject(GetThread(), m_return_type
, persistent
);