1 //===-- ObjectContainerUniversalMachO.h -------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_ObjectContainerUniversalMachO_h_
11 #define liblldb_ObjectContainerUniversalMachO_h_
12 
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Host/FileSpec.h"
18 #include "lldb/Symbol/ObjectContainer.h"
19 #include "lldb/Utility/SafeMachO.h"
20 
21 class ObjectContainerUniversalMachO : public lldb_private::ObjectContainer {
22 public:
23   ObjectContainerUniversalMachO(const lldb::ModuleSP &module_sp,
24                                 lldb::DataBufferSP &data_sp,
25                                 lldb::offset_t data_offset,
26                                 const lldb_private::FileSpec *file,
27                                 lldb::offset_t offset, lldb::offset_t length);
28 
29   ~ObjectContainerUniversalMachO() override;
30 
31   //------------------------------------------------------------------
32   // Static Functions
33   //------------------------------------------------------------------
34   static void Initialize();
35 
36   static void Terminate();
37 
38   static lldb_private::ConstString GetPluginNameStatic();
39 
40   static const char *GetPluginDescriptionStatic();
41 
42   static lldb_private::ObjectContainer *
43   CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
44                  lldb::offset_t data_offset, const lldb_private::FileSpec *file,
45                  lldb::offset_t offset, lldb::offset_t length);
46 
47   static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
48                                         lldb::DataBufferSP &data_sp,
49                                         lldb::offset_t data_offset,
50                                         lldb::offset_t file_offset,
51                                         lldb::offset_t length,
52                                         lldb_private::ModuleSpecList &specs);
53 
54   static bool MagicBytesMatch(const lldb_private::DataExtractor &data);
55 
56   //------------------------------------------------------------------
57   // Member Functions
58   //------------------------------------------------------------------
59   bool ParseHeader() override;
60 
61   void Dump(lldb_private::Stream *s) const override;
62 
63   size_t GetNumArchitectures() const override;
64 
65   bool GetArchitectureAtIndex(uint32_t cpu_idx,
66                               lldb_private::ArchSpec &arch) const override;
67 
68   lldb::ObjectFileSP GetObjectFile(const lldb_private::FileSpec *file) override;
69 
70   //------------------------------------------------------------------
71   // PluginInterface protocol
72   //------------------------------------------------------------------
73   lldb_private::ConstString GetPluginName() override;
74 
75   uint32_t GetPluginVersion() override;
76 
77 protected:
78   llvm::MachO::fat_header m_header;
79   std::vector<llvm::MachO::fat_arch> m_fat_archs;
80 
81   static bool ParseHeader(lldb_private::DataExtractor &data,
82                           llvm::MachO::fat_header &header,
83                           std::vector<llvm::MachO::fat_arch> &fat_archs);
84 };
85 
86 #endif // liblldb_ObjectContainerUniversalMachO_h_
87