diff options
author | Jim Ingham <jingham@apple.com> | 2018-03-12 21:17:04 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2018-03-12 21:17:04 +0000 |
commit | 08581263dcff5c5fa6fa2e8d674a809554a35d1d (patch) | |
tree | afd587267fa1abe76476a4d70ae68dbefbca63d1 /lldb/source/Plugins/Architecture | |
parent | 1cc1c5f2983affb3707b3baca00d54deda3566c6 (diff) | |
download | bcm5719-llvm-08581263dcff5c5fa6fa2e8d674a809554a35d1d.tar.gz bcm5719-llvm-08581263dcff5c5fa6fa2e8d674a809554a35d1d.zip |
Re-add change for https://reviews.llvm.org/D42582 with added directories.
llvm-svn: 327331
Diffstat (limited to 'lldb/source/Plugins/Architecture')
4 files changed, 125 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Architecture/CMakeLists.txt b/lldb/source/Plugins/Architecture/CMakeLists.txt index 5abaa8e6823..01365a64cf9 100644 --- a/lldb/source/Plugins/Architecture/CMakeLists.txt +++ b/lldb/source/Plugins/Architecture/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(Arm) +add_subdirectory(PPC64) diff --git a/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp new file mode 100644 index 00000000000..619de093aac --- /dev/null +++ b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp @@ -0,0 +1,69 @@ +//===-- ArchitecturePPC64.cpp -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/Symbol.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Utility/ArchSpec.h" + +#include "llvm/BinaryFormat/ELF.h" + +using namespace lldb_private; +using namespace lldb; + +ConstString ArchitecturePPC64::GetPluginNameStatic() { + return ConstString("ppc64"); +} + +void ArchitecturePPC64::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + "PPC64-specific algorithms", + &ArchitecturePPC64::Create); +} + +void ArchitecturePPC64::Terminate() { + PluginManager::UnregisterPlugin(&ArchitecturePPC64::Create); +} + +std::unique_ptr<Architecture> ArchitecturePPC64::Create(const ArchSpec &arch) { + if ((arch.GetMachine() != llvm::Triple::ppc64 && + arch.GetMachine() != llvm::Triple::ppc64le) || + arch.GetTriple().getObjectFormat() != llvm::Triple::ObjectFormatType::ELF) + return nullptr; + return std::unique_ptr<Architecture>(new ArchitecturePPC64()); +} + +ConstString ArchitecturePPC64::GetPluginName() { return GetPluginNameStatic(); } +uint32_t ArchitecturePPC64::GetPluginVersion() { return 1; } + +static int32_t GetLocalEntryOffset(const Symbol &sym) { + unsigned char other = sym.GetFlags() >> 8 & 0xFF; + return llvm::ELF::decodePPC64LocalEntryOffset(other); +} + +size_t ArchitecturePPC64::GetBytesToSkip(Symbol &func, + const Address &curr_addr) const { + if (curr_addr.GetFileAddress() == + func.GetFileAddress() + GetLocalEntryOffset(func)) + return func.GetPrologueByteSize(); + return 0; +} + +void ArchitecturePPC64::AdjustBreakpointAddress(const Symbol &func, + Address &addr) const { + int32_t loffs = GetLocalEntryOffset(func); + if (!loffs) + return; + + addr.SetOffset(addr.GetOffset() + loffs); +} diff --git a/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h new file mode 100644 index 00000000000..6c87471b548 --- /dev/null +++ b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h @@ -0,0 +1,44 @@ +//===-- ArchitecturePPC64.h -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_PLUGIN_ARCHITECTURE_PPC64_H +#define LLDB_PLUGIN_ARCHITECTURE_PPC64_H + +#include "lldb/Core/Architecture.h" + +namespace lldb_private { + +class ArchitecturePPC64 : public Architecture { +public: + static ConstString GetPluginNameStatic(); + static void Initialize(); + static void Terminate(); + + ConstString GetPluginName() override; + uint32_t GetPluginVersion() override; + + void OverrideStopInfo(Thread &thread) override {} + + //------------------------------------------------------------------ + /// This method compares current address with current function's + /// local entry point, returning the bytes to skip if they match. + //------------------------------------------------------------------ + size_t GetBytesToSkip(Symbol &func, const Address &curr_addr) const override; + + void AdjustBreakpointAddress(const Symbol &func, + Address &addr) const override; + +private: + static std::unique_ptr<Architecture> Create(const ArchSpec &arch); + ArchitecturePPC64() = default; +}; + +} // namespace lldb_private + +#endif // LLDB_PLUGIN_ARCHITECTURE_PPC64_H diff --git a/lldb/source/Plugins/Architecture/PPC64/CMakeLists.txt b/lldb/source/Plugins/Architecture/PPC64/CMakeLists.txt new file mode 100644 index 00000000000..2cba112cf88 --- /dev/null +++ b/lldb/source/Plugins/Architecture/PPC64/CMakeLists.txt @@ -0,0 +1,11 @@ +add_lldb_library(lldbPluginArchitecturePPC64 PLUGIN + ArchitecturePPC64.cpp + + LINK_LIBS + lldbPluginProcessUtility + lldbCore + lldbTarget + lldbUtility + LINK_COMPONENTS + Support + ) |