Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
39648 views
//===-- ArchitecturePPC64.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 "Plugins/Architecture/PPC64/ArchitecturePPC64.h"9#include "lldb/Core/PluginManager.h"10#include "lldb/Symbol/Function.h"11#include "lldb/Symbol/Symbol.h"12#include "lldb/Target/RegisterContext.h"13#include "lldb/Target/Target.h"14#include "lldb/Target/Thread.h"15#include "lldb/Utility/ArchSpec.h"1617#include "llvm/BinaryFormat/ELF.h"1819using namespace lldb_private;20using namespace lldb;2122LLDB_PLUGIN_DEFINE(ArchitecturePPC64)2324void ArchitecturePPC64::Initialize() {25PluginManager::RegisterPlugin(GetPluginNameStatic(),26"PPC64-specific algorithms",27&ArchitecturePPC64::Create);28}2930void ArchitecturePPC64::Terminate() {31PluginManager::UnregisterPlugin(&ArchitecturePPC64::Create);32}3334std::unique_ptr<Architecture> ArchitecturePPC64::Create(const ArchSpec &arch) {35if (arch.GetTriple().isPPC64() &&36arch.GetTriple().getObjectFormat() == llvm::Triple::ObjectFormatType::ELF)37return std::unique_ptr<Architecture>(new ArchitecturePPC64());38return nullptr;39}4041static int32_t GetLocalEntryOffset(const Symbol &sym) {42unsigned char other = sym.GetFlags() >> 8 & 0xFF;43return llvm::ELF::decodePPC64LocalEntryOffset(other);44}4546size_t ArchitecturePPC64::GetBytesToSkip(Symbol &func,47const Address &curr_addr) const {48if (curr_addr.GetFileAddress() ==49func.GetFileAddress() + GetLocalEntryOffset(func))50return func.GetPrologueByteSize();51return 0;52}5354void ArchitecturePPC64::AdjustBreakpointAddress(const Symbol &func,55Address &addr) const {56int32_t loffs = GetLocalEntryOffset(func);57if (!loffs)58return;5960addr.SetOffset(addr.GetOffset() + loffs);61}626364