1//===-- ArchitecturePPC64.cpp ---------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
10#include "lldb/Core/PluginManager.h"
11#include "lldb/Symbol/Function.h"
12#include "lldb/Symbol/Symbol.h"
13#include "lldb/Target/RegisterContext.h"
14#include "lldb/Target/Target.h"
15#include "lldb/Target/Thread.h"
16#include "lldb/Utility/ArchSpec.h"
17
18#include "llvm/BinaryFormat/ELF.h"
19
20using namespace lldb_private;
21using namespace lldb;
22
23LLDB_PLUGIN_DEFINE(ArchitecturePPC64)
24
25void ArchitecturePPC64::Initialize() {
26 PluginManager::RegisterPlugin(name: GetPluginNameStatic(),
27 description: "PPC64-specific algorithms",
28 create_callback: &ArchitecturePPC64::Create);
29}
30
31void ArchitecturePPC64::Terminate() {
32 PluginManager::UnregisterPlugin(create_callback: &ArchitecturePPC64::Create);
33}
34
35std::unique_ptr<Architecture> ArchitecturePPC64::Create(const ArchSpec &arch) {
36 if (arch.GetTriple().isPPC64() &&
37 arch.GetTriple().getObjectFormat() == llvm::Triple::ObjectFormatType::ELF)
38 return std::unique_ptr<Architecture>(new ArchitecturePPC64());
39 return nullptr;
40}
41
42static int32_t GetLocalEntryOffset(const Symbol &sym) {
43 unsigned char other = sym.GetFlags() >> 8 & 0xFF;
44 return llvm::ELF::decodePPC64LocalEntryOffset(Other: other);
45}
46
47size_t ArchitecturePPC64::GetBytesToSkip(Symbol &func,
48 const Address &curr_addr) const {
49 if (curr_addr.GetFileAddress() ==
50 func.GetFileAddress() + GetLocalEntryOffset(sym: func))
51 return func.GetPrologueByteSize();
52 return 0;
53}
54
55void ArchitecturePPC64::AdjustBreakpointAddress(const Symbol &func,
56 Address &addr) const {
57 int32_t loffs = GetLocalEntryOffset(sym: func);
58 if (!loffs)
59 return;
60
61 addr.SetOffset(addr.GetOffset() + loffs);
62}
63

source code of lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp