LLDB  mainline
Public Member Functions | Protected Attributes | List of all members
lldb_private::ObjectContainer Class Referenceabstract

A plug-in interface definition class for object containers. More...

#include "lldb/Symbol/ObjectContainer.h"

Inheritance diagram for lldb_private::ObjectContainer:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::ObjectContainer:
Collaboration graph
[legend]

Public Member Functions

 ObjectContainer (const lldb::ModuleSP &module_sp, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset)
 Construct with a parent module, offset, and header data. More...
 
 ~ObjectContainer () override=default
 Destructor. More...
 
virtual void Dump (Stream *s) const =0
 Dump a description of this object to a Stream. More...
 
virtual bool GetArchitectureAtIndex (uint32_t idx, ArchSpec &arch) const
 Gets the architecture given an index. More...
 
virtual lldb::addr_t GetOffset () const
 Returns the offset into a file at which this object resides. More...
 
virtual lldb::addr_t GetByteSize () const
 
virtual size_t GetNumObjects () const
 Get the number of objects within this object file (archives). More...
 
virtual size_t GetNumArchitectures () const
 Get the number of architectures in this object file. More...
 
virtual bool ParseHeader ()=0
 Attempts to parse the object header. More...
 
virtual lldb::ObjectFileSP GetObjectFile (const FileSpec *file)=0
 Selects an architecture in an object file. More...
 
virtual bool ObjectAtIndexIsContainer (uint32_t object_idx)
 
virtual ObjectFileGetObjectFileAtIndex (uint32_t object_idx)
 
virtual ObjectContainerGetObjectContainerAtIndex (uint32_t object_idx)
 
virtual const char * GetObjectNameAtIndex (uint32_t object_idx) const
 
- Public Member Functions inherited from lldb_private::PluginInterface
virtual ~PluginInterface ()
 
virtual ConstString GetPluginName ()=0
 
virtual uint32_t GetPluginVersion ()=0
 
- Public Member Functions inherited from lldb_private::ModuleChild
 ModuleChild (const lldb::ModuleSP &module_sp)
 Construct with owning module. More...
 
 ModuleChild (const ModuleChild &rhs)
 Copy constructor. More...
 
 ~ModuleChild ()
 Destructor. More...
 
const ModuleChildoperator= (const ModuleChild &rhs)
 Assignment operator. More...
 
lldb::ModuleSP GetModule () const
 Get const accessor for the module pointer. More...
 
void SetModule (const lldb::ModuleSP &module_sp)
 Set accessor for the module pointer. More...
 

Protected Attributes

FileSpec m_file
 The file that represents this container objects (which can be different from the module's file). More...
 
lldb::addr_t m_offset
 The offset in bytes into the file, or the address in memory. More...
 
lldb::addr_t m_length
 The size in bytes if known (can be zero). More...
 
DataExtractor m_data
 The data for this object file so things can be parsed lazily. More...
 
- Protected Attributes inherited from lldb_private::ModuleChild
lldb::ModuleWP m_module_wp
 The Module that owns the object that inherits from this class. More...
 

Detailed Description

A plug-in interface definition class for object containers.

Object containers contain object files from one or more architectures, and also can contain one or more named objects.

Typical object containers are static libraries (.a files) that contain multiple named object files, and universal files that contain multiple architectures.

Definition at line 30 of file ObjectContainer.h.

Constructor & Destructor Documentation

◆ ObjectContainer()

lldb_private::ObjectContainer::ObjectContainer ( const lldb::ModuleSP &  module_sp,
const FileSpec file,
lldb::offset_t  file_offset,
lldb::offset_t  length,
lldb::DataBufferSP &  data_sp,
lldb::offset_t  data_offset 
)
inline

Construct with a parent module, offset, and header data.

Object files belong to modules and a valid module must be supplied upon construction. The at an offset within a file for objects that contain more than one architecture or object.

Definition at line 37 of file ObjectContainer.h.

References Dump(), m_data, m_file, lldb_private::DataExtractor::SetData(), and ~ObjectContainer().

◆ ~ObjectContainer()

lldb_private::ObjectContainer::~ObjectContainer ( )
overridedefault

Destructor.

The destructor is virtual since this class is designed to be inherited from by the plug-in instance.

Referenced by ObjectContainer().

Member Function Documentation

◆ Dump()

virtual void lldb_private::ObjectContainer::Dump ( Stream s) const
pure virtual

Dump a description of this object to a Stream.

Dump a description of the current contents of this object to the supplied stream s. The dumping should include the section list if it has been parsed, and the symbol table if it has been parsed.

Parameters
[in]sThe stream to which to dump the object description.

Implemented in ObjectContainerBSDArchive, and ObjectContainerUniversalMachO.

Referenced by ObjectContainer().

◆ GetArchitectureAtIndex()

virtual bool lldb_private::ObjectContainer::GetArchitectureAtIndex ( uint32_t  idx,
ArchSpec arch 
) const
inlinevirtual

Gets the architecture given an index.

Copies the architecture specification for index idx.

Parameters
[in]idxThe architecture index to extract.
[out]archA architecture object that will be filled in if idx is a architecture valid index.
Returns
Returns true if idx is valid and arch has been filled in, false otherwise.
See also
ObjectContainer::GetNumArchitectures() const

Reimplemented in ObjectContainerUniversalMachO.

Definition at line 81 of file ObjectContainer.h.

Referenced by ObjectContainerBSDArchive::Dump().

◆ GetByteSize()

virtual lldb::addr_t lldb_private::ObjectContainer::GetByteSize ( ) const
inlinevirtual

Definition at line 95 of file ObjectContainer.h.

References m_length.

◆ GetNumArchitectures()

virtual size_t lldb_private::ObjectContainer::GetNumArchitectures ( ) const
inlinevirtual

Get the number of architectures in this object file.

The default implementation returns 1 as for object files that contain a single architecture. ObjectContainer instances that contain more than one architecture should override this function and return an appropriate value.

Returns
The number of architectures contained in this object file.

Reimplemented in ObjectContainerUniversalMachO.

Definition at line 113 of file ObjectContainer.h.

References GetObjectFile(), and ParseHeader().

Referenced by ObjectContainerBSDArchive::Dump().

◆ GetNumObjects()

virtual size_t lldb_private::ObjectContainer::GetNumObjects ( ) const
inlinevirtual

Get the number of objects within this object file (archives).

Returns
Zero for object files that are not archives, or the number of objects contained in the archive.

Reimplemented in ObjectContainerBSDArchive.

Definition at line 102 of file ObjectContainer.h.

Referenced by ObjectContainerUniversalMachO::Dump().

◆ GetObjectContainerAtIndex()

virtual ObjectContainer* lldb_private::ObjectContainer::GetObjectContainerAtIndex ( uint32_t  object_idx)
inlinevirtual

Definition at line 151 of file ObjectContainer.h.

◆ GetObjectFile()

virtual lldb::ObjectFileSP lldb_private::ObjectContainer::GetObjectFile ( const FileSpec file)
pure virtual

Selects an architecture in an object file.

Object files that contain a single architecture should verify that the specified arch matches the architecture in in object file and return true or false accordingly.

Object files that contain more than one architecture should attempt to select that architecture, and if successful, clear out any previous state from any previously selected architecture and prepare to return information for the new architecture.

Returns
Returns a pointer to the object file of the requested arch and optional name. Returns nullptr of no such object file exists in the container.

Implemented in ObjectContainerBSDArchive, and ObjectContainerUniversalMachO.

Referenced by GetNumArchitectures().

◆ GetObjectFileAtIndex()

virtual ObjectFile* lldb_private::ObjectContainer::GetObjectFileAtIndex ( uint32_t  object_idx)
inlinevirtual

Definition at line 147 of file ObjectContainer.h.

◆ GetObjectNameAtIndex()

virtual const char* lldb_private::ObjectContainer::GetObjectNameAtIndex ( uint32_t  object_idx) const
inlinevirtual

◆ GetOffset()

virtual lldb::addr_t lldb_private::ObjectContainer::GetOffset ( ) const
inlinevirtual

Returns the offset into a file at which this object resides.

Some files contain many object files, and this function allows access to an object's offset within the file.

Returns
The offset in bytes into the file. Defaults to zero for simple object files that a represented by an entire file.

Definition at line 93 of file ObjectContainer.h.

References m_offset.

◆ ObjectAtIndexIsContainer()

virtual bool lldb_private::ObjectContainer::ObjectAtIndexIsContainer ( uint32_t  object_idx)
inlinevirtual

Definition at line 145 of file ObjectContainer.h.

◆ ParseHeader()

virtual bool lldb_private::ObjectContainer::ParseHeader ( )
pure virtual

Attempts to parse the object header.

This function is used as a test to see if a given plug-in instance can parse the header data already contained in ObjectContainer::m_data. If an object file parser does not recognize that magic bytes in a header, false should be returned and the next plug-in can attempt to parse an object file.

Returns
Returns true if the header was parsed successfully, false otherwise.

Implemented in ObjectContainerBSDArchive, and ObjectContainerUniversalMachO.

Referenced by GetNumArchitectures().

Member Data Documentation

◆ m_data

DataExtractor lldb_private::ObjectContainer::m_data
protected

The data for this object file so things can be parsed lazily.

Definition at line 167 of file ObjectContainer.h.

Referenced by ObjectContainerBSDArchive::Archive::GetData(), ObjectContainer(), ObjectContainerUniversalMachO::ParseHeader(), and ObjectContainerBSDArchive::ParseHeader().

◆ m_file

FileSpec lldb_private::ObjectContainer::m_file
protected

The file that represents this container objects (which can be different from the module's file).

Definition at line 161 of file ObjectContainer.h.

Referenced by ObjectContainer(), and ObjectContainerBSDArchive::ParseHeader().

◆ m_length

lldb::addr_t lldb_private::ObjectContainer::m_length
protected

The size in bytes if known (can be zero).

Definition at line 165 of file ObjectContainer.h.

Referenced by GetByteSize().

◆ m_offset

lldb::addr_t lldb_private::ObjectContainer::m_offset
protected

The offset in bytes into the file, or the address in memory.

Definition at line 164 of file ObjectContainer.h.

Referenced by ObjectContainerUniversalMachO::GetObjectFile(), ObjectContainerBSDArchive::GetObjectFile(), GetOffset(), and ObjectContainerBSDArchive::ParseHeader().


The documentation for this class was generated from the following file: