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
17
18// This file represents an AIX Big Archive and combines several files into one.
19// It is the default library archive format for the AIX operating system.
20// Ref: https://www.ibm.com/docs/en/aix/7.3.0?topic=formats-ar-file-format-big
21
23public:
25 lldb::DataBufferSP &data_sp,
26 lldb::offset_t data_offset,
27 const lldb_private::FileSpec *file,
28 lldb::offset_t offset, lldb::offset_t length);
29
31
32 // Static Functions
33 static void Initialize();
34
35 static void Terminate();
36
37 static llvm::StringRef GetPluginNameStatic() { return "big-archive"; }
38
39 static llvm::StringRef GetPluginDescriptionStatic() {
40 return "Big Archive object container reader.";
41 }
42
44 CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
45 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
46 lldb::offset_t offset, lldb::offset_t length);
47
50 lldb::DataExtractorSP &extractor_sp,
51 lldb::offset_t file_offset, lldb::offset_t length);
52
53 // Member Functions
54 bool ParseHeader() override;
55
56 size_t GetNumObjects() const override {
57 if (m_archive_sp)
58 return m_archive_sp->GetNumObjects();
59 return 0;
60 }
61
63
64 // PluginInterface protocol
65 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
66
67protected:
68 struct Object {
70
71 void Clear();
72
74 lldb::offset_t offset);
75 /// Object name in the archive.
77
78 /// Object modification time in the archive.
79 uint32_t modification_time = 0;
80
81 /// Object user id in the archive.
82 uint16_t uid = 0;
83
84 /// Object group id in the archive.
85 uint16_t gid = 0;
86
87 /// Object octal file permissions in the archive.
88 uint16_t mode = 0;
89
90 /// Object size in bytes in the archive.
91 uint32_t size = 0;
92
93 /// File offset in bytes from the beginning of the file of the object data.
95
96 /// Length of the object data in bytes.
98
99 void Dump(lldb_private::Stream *s) const;
100 };
101
102 class Archive {
103 public:
104 typedef std::shared_ptr<Archive> shared_ptr;
105 typedef std::multimap<lldb_private::FileSpec, shared_ptr> Map;
106
108 const llvm::sys::TimePoint<> &mod_time, lldb::offset_t file_offset,
109 lldb::DataExtractorSP extractor_sp);
110
112
113 size_t GetNumObjects() const { return m_objects.size(); }
114
116
118
119 void SetArchitecture(const lldb_private::ArchSpec &arch) { m_arch = arch; }
120
123
124 protected:
125 // Member Variables
127 llvm::sys::TimePoint<> m_modification_time;
129 std::vector<Object> m_objects;
130 ///< The data extractor for this object container
131 /// so we don't lose data if the .a files
132 /// gets modified
134 };
135
136 void SetArchive(Archive::shared_ptr &archive_sp);
137
139};
140
141#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:56
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:86
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.