1 //===-- ObjectContainerMachOFileset.h ---------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_MACH_O_FILESET_OBJECTCONTAINERMADCHOFILESET_H
10 #define LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_MACH_O_FILESET_OBJECTCONTAINERMADCHOFILESET_H
12 #include "lldb/Host/SafeMachO.h"
13 #include "lldb/Symbol/ObjectContainer.h"
14 #include "lldb/Utility/FileSpec.h"
16 namespace lldb_private
{
18 class ObjectContainerMachOFileset
: public lldb_private::ObjectContainer
{
20 ObjectContainerMachOFileset(const lldb::ModuleSP
&module_sp
,
21 lldb::DataBufferSP
&data_sp
,
22 lldb::offset_t data_offset
,
23 const lldb_private::FileSpec
*file
,
24 lldb::offset_t offset
, lldb::offset_t length
);
26 ObjectContainerMachOFileset(const lldb::ModuleSP
&module_sp
,
27 lldb::WritableDataBufferSP data_sp
,
28 const lldb::ProcessSP
&process_sp
,
29 lldb::addr_t header_addr
);
31 ~ObjectContainerMachOFileset() override
;
33 static void Initialize();
34 static void Terminate();
36 static llvm::StringRef
GetPluginNameStatic() { return "mach-o-fileset"; }
38 static llvm::StringRef
GetPluginDescriptionStatic() {
39 return "Mach-O Fileset container reader.";
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
);
47 static lldb_private::ObjectContainer
*CreateMemoryInstance(
48 const lldb::ModuleSP
&module_sp
, lldb::WritableDataBufferSP data_sp
,
49 const lldb::ProcessSP
&process_sp
, lldb::addr_t header_addr
);
51 static size_t GetModuleSpecifications(const lldb_private::FileSpec
&file
,
52 lldb::DataBufferSP
&data_sp
,
53 lldb::offset_t data_offset
,
54 lldb::offset_t file_offset
,
55 lldb::offset_t length
,
56 lldb_private::ModuleSpecList
&specs
);
58 static bool MagicBytesMatch(const lldb_private::DataExtractor
&data
);
59 static bool MagicBytesMatch(lldb::DataBufferSP data_sp
,
60 lldb::addr_t data_offset
,
61 lldb::addr_t data_length
);
63 bool ParseHeader() override
;
65 size_t GetNumObjects() const override
{ return m_entries
.size(); }
67 lldb::ObjectFileSP
GetObjectFile(const lldb_private::FileSpec
*file
) override
;
69 llvm::StringRef
GetPluginName() override
{ return GetPluginNameStatic(); }
72 Entry(uint64_t vmaddr
, uint64_t fileoff
, std::string id
)
73 : vmaddr(vmaddr
), fileoff(fileoff
), id(id
) {}
79 Entry
*FindEntry(llvm::StringRef id
);
82 static bool ParseHeader(lldb_private::DataExtractor
&data
,
83 const lldb_private::FileSpec
&file
,
84 lldb::offset_t file_offset
,
85 std::vector
<Entry
> &entries
);
87 std::vector
<Entry
> m_entries
;
88 lldb::ProcessWP m_process_wp
;
89 const lldb::addr_t m_memory_addr
;
92 } // namespace lldb_private
94 #endif // LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_MACH_O_FILESET_OBJECTCONTAINERMADCHOFILESET_H