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/Symbol/ObjectContainer.h"
18 #include "lldb/Host/FileSpec.h"
19 #include "lldb/Utility/SafeMachO.h"
20 
21 class ObjectContainerUniversalMachO :
22     public lldb_private::ObjectContainer
23 {
24 public:
25     ObjectContainerUniversalMachO(const lldb::ModuleSP &module_sp,
26                                   lldb::DataBufferSP& data_sp,
27                                   lldb::offset_t data_offset,
28                                   const lldb_private::FileSpec *file,
29                                   lldb::offset_t offset,
30                                   lldb::offset_t length);
31 
32     ~ObjectContainerUniversalMachO() override;
33 
34     //------------------------------------------------------------------
35     // Static Functions
36     //------------------------------------------------------------------
37     static void
38     Initialize();
39 
40     static void
41     Terminate();
42 
43     static lldb_private::ConstString
44     GetPluginNameStatic();
45 
46     static const char *
47     GetPluginDescriptionStatic();
48 
49     static lldb_private::ObjectContainer *
50     CreateInstance (const lldb::ModuleSP &module_sp,
51                     lldb::DataBufferSP& data_sp,
52                     lldb::offset_t data_offset,
53                     const lldb_private::FileSpec *file,
54                     lldb::offset_t offset,
55                     lldb::offset_t length);
56 
57     static size_t
58     GetModuleSpecifications (const lldb_private::FileSpec& file,
59                              lldb::DataBufferSP& data_sp,
60                              lldb::offset_t data_offset,
61                              lldb::offset_t file_offset,
62                              lldb::offset_t length,
63                              lldb_private::ModuleSpecList &specs);
64 
65     static bool
66     MagicBytesMatch (const lldb_private::DataExtractor &data);
67 
68     //------------------------------------------------------------------
69     // Member Functions
70     //------------------------------------------------------------------
71     bool
72     ParseHeader() override;
73 
74     void
75     Dump(lldb_private::Stream *s) const override;
76 
77     size_t
78     GetNumArchitectures() const override;
79 
80     bool
81     GetArchitectureAtIndex(uint32_t cpu_idx, lldb_private::ArchSpec& arch) const override;
82 
83     lldb::ObjectFileSP
84     GetObjectFile(const lldb_private::FileSpec *file) override;
85 
86     //------------------------------------------------------------------
87     // PluginInterface protocol
88     //------------------------------------------------------------------
89     lldb_private::ConstString
90     GetPluginName() override;
91 
92     uint32_t
93     GetPluginVersion() override;
94 
95 protected:
96     llvm::MachO::fat_header m_header;
97     std::vector<llvm::MachO::fat_arch> m_fat_archs;
98 
99     static bool
100     ParseHeader (lldb_private::DataExtractor &data,
101                  llvm::MachO::fat_header &header,
102                  std::vector<llvm::MachO::fat_arch> &fat_archs);
103 };
104 
105 #endif // liblldb_ObjectContainerUniversalMachO_h_
106