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
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,
53
54 // Member Functions
55 bool ParseHeader() override;
56
57 size_t GetNumObjects() const override {
58 if (m_archive_sp)
59 return m_archive_sp->GetNumObjects();
60 return 0;
61 }
62
64
65 // PluginInterface protocol
66 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
67
68protected:
69 struct Object {
71
72 void Clear();
73
75 lldb::offset_t offset);
76 /// Object name in the archive.
78
79 /// Object modification time in the archive.
80 uint32_t modification_time = 0;
81
82 /// Object user id in the archive.
83 uint16_t uid = 0;
84
85 /// Object group id in the archive.
86 uint16_t gid = 0;
87
88 /// Object octal file permissions in the archive.
89 uint16_t mode = 0;
90
91 /// Object size in bytes in the archive.
92 uint32_t size = 0;
93
94 /// File offset in bytes from the beginning of the file of the object data.
96
97 /// Length of the object data in bytes.
99
101 };
102
103 class Archive {
104 public:
105 typedef std::shared_ptr<Archive> shared_ptr;
106 typedef std::multimap<lldb_private::FileSpec, shared_ptr> Map;
107
109 const llvm::sys::TimePoint<> &mod_time, lldb::offset_t file_offset,
110 lldb::DataExtractorSP extractor_sp);
111
113
114 size_t GetNumObjects() const { return m_objects.size(); }
115
117
119
120 void SetArchitecture(const lldb_private::ArchSpec &arch) { m_arch = arch; }
121
124
125 protected:
126 // Member Variables
128 llvm::sys::TimePoint<> m_modification_time;
130 std::vector<Object> m_objects;
131 ///< The data extractor for this object container
132 /// so we don't lose data if the .a files
133 /// gets modified
135 };
136
137 void SetArchive(Archive::shared_ptr &archive_sp);
138
140};
141
142#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()
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)
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)
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:31
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.