[LoongArch][Clang] Make the parameters and return value of {x,}vorn.v builti ns ...
[llvm-project.git] / lldb / source / Plugins / ObjectContainer / Universal-Mach-O / ObjectContainerUniversalMachO.h
blob20f1f051e07a0d63f254389a4719171f4bb831b8
1 //===-- ObjectContainerUniversalMachO.h -------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_UNIVERSAL_MACH_O_OBJECTCONTAINERUNIVERSALMACHO_H
10 #define LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_UNIVERSAL_MACH_O_OBJECTCONTAINERUNIVERSALMACHO_H
12 #include "lldb/Host/SafeMachO.h"
13 #include "lldb/Symbol/ObjectContainer.h"
14 #include "lldb/Utility/FileSpec.h"
16 class ObjectContainerUniversalMachO : public lldb_private::ObjectContainer {
17 public:
18 ObjectContainerUniversalMachO(const lldb::ModuleSP &module_sp,
19 lldb::DataBufferSP &data_sp,
20 lldb::offset_t data_offset,
21 const lldb_private::FileSpec *file,
22 lldb::offset_t offset, lldb::offset_t length);
24 ~ObjectContainerUniversalMachO() override;
26 // Static Functions
27 static void Initialize();
29 static void Terminate();
31 static llvm::StringRef GetPluginNameStatic() { return "mach-o"; }
33 static llvm::StringRef GetPluginDescriptionStatic() {
34 return "Universal mach-o object container reader.";
37 static lldb_private::ObjectContainer *
38 CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
39 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
40 lldb::offset_t offset, lldb::offset_t length);
42 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
43 lldb::DataBufferSP &data_sp,
44 lldb::offset_t data_offset,
45 lldb::offset_t file_offset,
46 lldb::offset_t length,
47 lldb_private::ModuleSpecList &specs);
49 static bool MagicBytesMatch(const lldb_private::DataExtractor &data);
51 // Member Functions
52 bool ParseHeader() override;
54 size_t GetNumArchitectures() const override;
56 bool GetArchitectureAtIndex(uint32_t cpu_idx,
57 lldb_private::ArchSpec &arch) const override;
59 lldb::ObjectFileSP GetObjectFile(const lldb_private::FileSpec *file) override;
61 // PluginInterface protocol
62 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
64 protected:
65 llvm::MachO::fat_header m_header;
67 struct FatArch {
68 FatArch(llvm::MachO::fat_arch arch) : m_arch(arch), m_is_fat64(false) {}
69 FatArch(llvm::MachO::fat_arch_64 arch) : m_arch(arch), m_is_fat64(true) {}
71 uint32_t GetCPUType() const {
72 return m_is_fat64 ? m_arch.fat_arch_64.cputype : m_arch.fat_arch.cputype;
75 uint32_t GetCPUSubType() const {
76 return m_is_fat64 ? m_arch.fat_arch_64.cpusubtype
77 : m_arch.fat_arch.cpusubtype;
80 uint64_t GetOffset() const {
81 return m_is_fat64 ? m_arch.fat_arch_64.offset : m_arch.fat_arch.offset;
84 uint64_t GetSize() const {
85 return m_is_fat64 ? m_arch.fat_arch_64.size : m_arch.fat_arch.size;
88 uint32_t GetAlign() const {
89 return m_is_fat64 ? m_arch.fat_arch_64.align : m_arch.fat_arch.align;
92 private:
93 const union Arch {
94 Arch(llvm::MachO::fat_arch arch) : fat_arch(arch) {}
95 Arch(llvm::MachO::fat_arch_64 arch) : fat_arch_64(arch) {}
96 llvm::MachO::fat_arch fat_arch;
97 llvm::MachO::fat_arch_64 fat_arch_64;
98 } m_arch;
99 const bool m_is_fat64;
101 std::vector<FatArch> m_fat_archs;
103 static bool ParseHeader(lldb_private::DataExtractor &data,
104 llvm::MachO::fat_header &header,
105 std::vector<FatArch> &fat_archs);
108 #endif // LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_UNIVERSAL_MACH_O_OBJECTCONTAINERUNIVERSALMACHO_H