LLDB mainline
ObjectContainerBigArchive.h
Go to the documentation of this file.
1//===-- ObjectContainerBigArchive.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_BIG_ARCHIVE_OBJECTCONTAINERBIGARCHIVE_H
10#define LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_BIG_ARCHIVE_OBJECTCONTAINERBIGARCHIVE_H
11
16
17// This file represents an AIX Big Archive and combines several files into one.
18// It is the default library archive format for the AIX operating system.
19// Ref: https://www.ibm.com/docs/en/aix/7.3.0?topic=formats-ar-file-format-big
20
22public:
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
30
31 // Static Functions
32 static void Initialize();
33
34 static void Terminate();
35
36 static llvm::StringRef GetPluginNameStatic() { return "big-archive"; }
37
38 static llvm::StringRef GetPluginDescriptionStatic() {
39 return "Big Archive object container reader.";
40 }
41
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
49 lldb::DataExtractorSP &extractor_sp,
50 lldb::offset_t file_offset, lldb::offset_t length);
51
52 // Member Functions
53 bool ParseHeader() override;
54
55 size_t GetNumObjects() const override {
56 if (m_archive_sp)
57 return m_archive_sp->GetNumObjects();
58 return 0;
59 }
60
62
63 // PluginInterface protocol
64 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
65
66protected:
67 struct Object {
69
70 void Clear();
71
73 lldb::offset_t offset);
74 /// Object name in the archive.
76
77 /// Object modification time in the archive.
78 uint32_t modification_time = 0;
79
80 /// Object user id in the archive.
81 uint16_t uid = 0;
82
83 /// Object group id in the archive.
84 uint16_t gid = 0;
85
86 /// Object octal file permissions in the archive.
87 uint16_t mode = 0;
88
89 /// Object size in bytes in the archive.
90 uint32_t size = 0;
91
92 /// File offset in bytes from the beginning of the file of the object data.
94
95 /// Length of the object data in bytes.
97
98 void Dump(lldb_private::Stream *s) const;
99 };
100
101 class Archive {
102 public:
103 typedef std::shared_ptr<Archive> shared_ptr;
104 typedef std::multimap<lldb_private::FileSpec, shared_ptr> Map;
105
107 const llvm::sys::TimePoint<> &mod_time, lldb::offset_t file_offset,
108 lldb::DataExtractorSP extractor_sp);
109
111
112 size_t GetNumObjects() const { return m_objects.size(); }
113
115
117
118 void SetArchitecture(const lldb_private::ArchSpec &arch) { m_arch = arch; }
119
122
123 protected:
124 // Member Variables
126 llvm::sys::TimePoint<> m_modification_time;
128 std::vector<Object> m_objects;
129 ///< The data extractor for this object container
130 /// so we don't lose data if the .a files
131 /// gets modified
133 };
134
135 void SetArchive(Archive::shared_ptr &archive_sp);
136
138};
139
140#endif // LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_BIG_ARCHIVE_OBJECTCONTAINERBIGARCHIVE_H
std::vector< Object > m_objects
The data extractor for this object container so we don't lose data if the .a files gets modified.
void SetArchitecture(const lldb_private::ArchSpec &arch)
Archive(const lldb_private::ArchSpec &arch, const llvm::sys::TimePoint<> &mod_time, lldb::offset_t file_offset, lldb::DataExtractorSP extractor_sp)
lldb_private::DataExtractor & GetData()
std::multimap< lldb_private::FileSpec, shared_ptr > Map
const lldb_private::ArchSpec & GetArchitecture() const
static llvm::StringRef GetPluginNameStatic()
static lldb_private::ModuleSpecList GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataExtractorSP &extractor_sp, lldb::offset_t file_offset, lldb::offset_t length)
void SetArchive(Archive::shared_ptr &archive_sp)
size_t GetNumObjects() const override
Get the number of objects within this object file (archives).
~ObjectContainerBigArchive() override
llvm::StringRef GetPluginName() override
lldb::ObjectFileSP GetObjectFile(const lldb_private::FileSpec *file) override
Selects an architecture in an object file.
static llvm::StringRef GetPluginDescriptionStatic()
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)
ObjectContainerBigArchive(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)
bool ParseHeader() override
Attempts to parse the object header.
An architecture specification class.
Definition ArchSpec.h:32
A uniqued constant string class.
Definition ConstString.h:40
An data extractor class.
A file utility class.
Definition FileSpec.h:57
A plug-in interface definition class for object containers.
A stream class that can stream formatted output to a file.
Definition Stream.h:28
uint64_t offset_t
Definition lldb-types.h:85
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP
void Dump(lldb_private::Stream *s) const
uint16_t uid
Object user id in the archive.
lldb::offset_t file_size
Length of the object data in bytes.
lldb::offset_t Extract(const lldb_private::DataExtractor &data, lldb::offset_t offset)
uint32_t size
Object size in bytes in the archive.
lldb_private::ConstString ar_name
Object name in the archive.
uint16_t gid
Object group id in the archive.
uint32_t modification_time
Object modification time in the archive.
lldb::offset_t file_offset
File offset in bytes from the beginning of the file of the object data.
uint16_t mode
Object octal file permissions in the archive.