|
|
|||
File indexing completed on 2026-05-10 08:42:51
0001 //===-- ObjectContainer.h ---------------------------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLDB_SYMBOL_OBJECTCONTAINER_H 0010 #define LLDB_SYMBOL_OBJECTCONTAINER_H 0011 0012 #include "lldb/Core/ModuleChild.h" 0013 #include "lldb/Core/PluginInterface.h" 0014 #include "lldb/Utility/DataExtractor.h" 0015 #include "lldb/Utility/Endian.h" 0016 #include "lldb/Utility/FileSpec.h" 0017 #include "lldb/lldb-private.h" 0018 0019 namespace lldb_private { 0020 0021 /// \class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h" 0022 /// A plug-in interface definition class for object containers. 0023 /// 0024 /// Object containers contain object files from one or more architectures, and 0025 /// also can contain one or more named objects. 0026 /// 0027 /// Typical object containers are static libraries (.a files) that contain 0028 /// multiple named object files, and universal files that contain multiple 0029 /// architectures. 0030 class ObjectContainer : public PluginInterface, public ModuleChild { 0031 public: 0032 /// Construct with a parent module, offset, and header data. 0033 /// 0034 /// Object files belong to modules and a valid module must be supplied upon 0035 /// construction. The at an offset within a file for objects that contain 0036 /// more than one architecture or object. 0037 ObjectContainer(const lldb::ModuleSP &module_sp, const FileSpec *file, 0038 lldb::offset_t file_offset, lldb::offset_t length, 0039 lldb::DataBufferSP data_sp, lldb::offset_t data_offset); 0040 0041 /// Destructor. 0042 /// 0043 /// The destructor is virtual since this class is designed to be inherited 0044 /// from by the plug-in instance. 0045 ~ObjectContainer() override = default; 0046 0047 /// Gets the architecture given an index. 0048 /// 0049 /// Copies the architecture specification for index \a idx. 0050 /// 0051 /// \param[in] idx 0052 /// The architecture index to extract. 0053 /// 0054 /// \param[out] arch 0055 /// A architecture object that will be filled in if \a idx is a 0056 /// architecture valid index. 0057 /// 0058 /// \return 0059 /// Returns \b true if \a idx is valid and \a arch has been 0060 /// filled in, \b false otherwise. 0061 /// 0062 /// \see ObjectContainer::GetNumArchitectures() const 0063 virtual bool GetArchitectureAtIndex(uint32_t idx, ArchSpec &arch) const { 0064 return false; 0065 } 0066 0067 /// Returns the offset into a file at which this object resides. 0068 /// 0069 /// Some files contain many object files, and this function allows access to 0070 /// an object's offset within the file. 0071 /// 0072 /// \return 0073 /// The offset in bytes into the file. Defaults to zero for 0074 /// simple object files that a represented by an entire file. 0075 virtual lldb::addr_t GetOffset() const { return m_offset; } 0076 0077 virtual lldb::addr_t GetByteSize() const { return m_length; } 0078 0079 /// Get the number of objects within this object file (archives). 0080 /// 0081 /// \return 0082 /// Zero for object files that are not archives, or the number 0083 /// of objects contained in the archive. 0084 virtual size_t GetNumObjects() const { return 0; } 0085 0086 /// Get the number of architectures in this object file. 0087 /// 0088 /// The default implementation returns 1 as for object files that contain a 0089 /// single architecture. ObjectContainer instances that contain more than 0090 /// one architecture should override this function and return an appropriate 0091 /// value. 0092 /// 0093 /// \return 0094 /// The number of architectures contained in this object file. 0095 virtual size_t GetNumArchitectures() const { return 0; } 0096 0097 /// Attempts to parse the object header. 0098 /// 0099 /// This function is used as a test to see if a given plug-in instance can 0100 /// parse the header data already contained in ObjectContainer::m_data. If 0101 /// an object file parser does not recognize that magic bytes in a header, 0102 /// false should be returned and the next plug-in can attempt to parse an 0103 /// object file. 0104 /// 0105 /// \return 0106 /// Returns \b true if the header was parsed successfully, \b 0107 /// false otherwise. 0108 virtual bool ParseHeader() = 0; 0109 0110 /// Selects an architecture in an object file. 0111 /// 0112 /// Object files that contain a single architecture should verify that the 0113 /// specified \a arch matches the architecture in the object file and return 0114 /// \b true or \b false accordingly. 0115 /// 0116 /// Object files that contain more than one architecture should attempt to 0117 /// select that architecture, and if successful, clear out any previous 0118 /// state from any previously selected architecture and prepare to return 0119 /// information for the new architecture. 0120 /// 0121 /// \return 0122 /// Returns a pointer to the object file of the requested \a 0123 /// arch and optional \a name. Returns nullptr of no such object 0124 /// file exists in the container. 0125 virtual lldb::ObjectFileSP GetObjectFile(const FileSpec *file) = 0; 0126 0127 static lldb::ObjectContainerSP 0128 FindPlugin(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, 0129 lldb::addr_t header_addr, lldb::WritableDataBufferSP file_data_sp); 0130 0131 protected: 0132 /// The file that represents this container objects (which can be different 0133 /// from the module's file). 0134 FileSpec m_file; 0135 0136 /// The offset in bytes into the file, or the address in memory 0137 lldb::addr_t m_offset; 0138 0139 /// The size in bytes if known (can be zero). 0140 lldb::addr_t m_length; 0141 0142 /// The data for this object file so things can be parsed lazily. 0143 DataExtractor m_data; 0144 0145 private: 0146 ObjectContainer(const ObjectContainer &) = delete; 0147 const ObjectContainer &operator=(const ObjectContainer &) = delete; 0148 }; 0149 0150 } // namespace lldb_private 0151 0152 #endif // LLDB_SYMBOL_OBJECTCONTAINER_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|