Path: blob/main/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp
39587 views
//===-- ThreadPlanCallFunctionUsingABI.cpp --------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"9#include "lldb/Core/Address.h"10#include "lldb/Target/Process.h"11#include "lldb/Target/RegisterContext.h"12#include "lldb/Target/Target.h"13#include "lldb/Target/Thread.h"14#include "lldb/Utility/Log.h"15#include "lldb/Utility/Stream.h"1617using namespace lldb;18using namespace lldb_private;1920// ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI21// instead of JIT22ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI(23Thread &thread, const Address &function, llvm::Type &prototype,24llvm::Type &return_type, llvm::ArrayRef<ABI::CallArgument> args,25const EvaluateExpressionOptions &options)26: ThreadPlanCallFunction(thread, function, options),27m_return_type(return_type) {28lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;29lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;30ABI *abi = nullptr;3132if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))33return;3435if (!abi->PrepareTrivialCall(thread, m_function_sp, function_load_addr,36start_load_addr, prototype, args))37return;3839ReportRegisterState("ABI Function call was set up. Register state was:");4041m_valid = true;42}4344ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI() = default;4546void ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s,47DescriptionLevel level) {48if (level == eDescriptionLevelBrief) {49s->Printf("Function call thread plan using ABI instead of JIT");50} else {51s->Printf("Thread plan to call 0x%" PRIx64 " using ABI instead of JIT",52m_function_addr.GetLoadAddress(&GetTarget()));53}54}5556void ThreadPlanCallFunctionUsingABI::SetReturnValue() {57const ABI *abi = m_process.GetABI().get();5859// Ask the abi for the return value60if (abi) {61const bool persistent = false;62m_return_valobj_sp =63abi->GetReturnValueObject(GetThread(), m_return_type, persistent);64}65}666768