LLDB  mainline
ObjectContainerUniversalMachO.h
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_UNIVERSAL_MACH_O_OBJECTCONTAINERUNIVERSALMACHO_H
10 #define LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_UNIVERSAL_MACH_O_OBJECTCONTAINERUNIVERSALMACHO_H
11 
12 #include "lldb/Host/SafeMachO.h"
14 #include "lldb/Utility/FileSpec.h"
15 
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);
23 
25 
26  // Static Functions
27  static void Initialize();
28 
29  static void Terminate();
30 
32 
33  static const char *GetPluginDescriptionStatic();
34 
36  CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
37  lldb::offset_t data_offset, const lldb_private::FileSpec *file,
38  lldb::offset_t offset, lldb::offset_t length);
39 
40  static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
41  lldb::DataBufferSP &data_sp,
42  lldb::offset_t data_offset,
43  lldb::offset_t file_offset,
44  lldb::offset_t length,
46 
47  static bool MagicBytesMatch(const lldb_private::DataExtractor &data);
48 
49  // Member Functions
50  bool ParseHeader() override;
51 
52  void Dump(lldb_private::Stream *s) const override;
53 
54  size_t GetNumArchitectures() const override;
55 
56  bool GetArchitectureAtIndex(uint32_t cpu_idx,
57  lldb_private::ArchSpec &arch) const override;
58 
59  lldb::ObjectFileSP GetObjectFile(const lldb_private::FileSpec *file) override;
60 
61  // PluginInterface protocol
63 
64  uint32_t GetPluginVersion() override;
65 
66 protected:
67  llvm::MachO::fat_header m_header;
68  std::vector<llvm::MachO::fat_arch> m_fat_archs;
69 
70  static bool ParseHeader(lldb_private::DataExtractor &data,
71  llvm::MachO::fat_header &header,
72  std::vector<llvm::MachO::fat_arch> &fat_archs);
73 };
74 
75 #endif // LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_UNIVERSAL_MACH_O_OBJECTCONTAINERUNIVERSALMACHO_H
ObjectContainerUniversalMachO::Initialize
static void Initialize()
ObjectContainerUniversalMachO::m_header
llvm::MachO::fat_header m_header
Definition: ObjectContainerUniversalMachO.h:67
ObjectContainerUniversalMachO::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: ObjectContainerUniversalMachO.cpp:36
ObjectContainerUniversalMachO::GetPluginName
lldb_private::ConstString GetPluginName() override
Definition: ObjectContainerUniversalMachO.cpp:209
lldb_private::ArchSpec
Definition: ArchSpec.h:33
ObjectContainerUniversalMachO::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: ObjectContainerUniversalMachO.cpp:41
lldb_private::ModuleSpecList
Definition: ModuleSpec.h:281
lldb_private::ObjectContainer
Definition: ObjectContainer.h:30
ObjectContainerUniversalMachO::~ObjectContainerUniversalMachO
~ObjectContainerUniversalMachO() override
Definition: ObjectContainerUniversalMachO.cpp:82
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
ObjectContainerUniversalMachO::GetObjectFile
lldb::ObjectFileSP GetObjectFile(const lldb_private::FileSpec *file) override
Selects an architecture in an object file.
Definition: ObjectContainerUniversalMachO.cpp:166
lldb_private::Stream
Definition: Stream.h:28
ObjectContainerUniversalMachO
Definition: ObjectContainerUniversalMachO.h:16
SafeMachO.h
ObjectContainerUniversalMachO::ObjectContainerUniversalMachO
ObjectContainerUniversalMachO(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
Definition: ObjectContainerUniversalMachO.cpp:72
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ConstString
Definition: ConstString.h:40
ObjectContainerUniversalMachO::Terminate
static void Terminate()
Definition: ObjectContainerUniversalMachO.cpp:32
ObjectContainerUniversalMachO::MagicBytesMatch
static bool MagicBytesMatch(const lldb_private::DataExtractor &data)
Definition: ObjectContainerUniversalMachO.cpp:66
ObjectContainerUniversalMachO::GetPluginVersion
uint32_t GetPluginVersion() override
Definition: ObjectContainerUniversalMachO.cpp:213
uint32_t
ObjectContainerUniversalMachO::ParseHeader
bool ParseHeader() override
Attempts to parse the object header.
Definition: ObjectContainerUniversalMachO.cpp:84
ObjectContainerUniversalMachO::CreateInstance
static lldb_private::ObjectContainer * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
Definition: ObjectContainerUniversalMachO.cpp:45
ObjectContainerUniversalMachO::GetModuleSpecifications
static size_t GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, lldb::offset_t file_offset, lldb::offset_t length, lldb_private::ModuleSpecList &specs)
Definition: ObjectContainerUniversalMachO.cpp:215
ObjectContainerUniversalMachO::GetNumArchitectures
size_t GetNumArchitectures() const override
Get the number of architectures in this object file.
Definition: ObjectContainerUniversalMachO.cpp:151
FileSpec.h
ObjectContainer.h
ObjectContainerUniversalMachO::GetArchitectureAtIndex
bool GetArchitectureAtIndex(uint32_t cpu_idx, lldb_private::ArchSpec &arch) const override
Gets the architecture given an index.
Definition: ObjectContainerUniversalMachO.cpp:155
ObjectContainerUniversalMachO::Dump
void Dump(lldb_private::Stream *s) const override
Dump a description of this object to a Stream.
Definition: ObjectContainerUniversalMachO.cpp:128
ObjectContainerUniversalMachO::m_fat_archs
std::vector< llvm::MachO::fat_arch > m_fat_archs
Definition: ObjectContainerUniversalMachO.h:68