LLDB  mainline
Public Member Functions | Public Attributes | List of all members
lldb_private::CacheSignature Struct Reference

A signature for a given file on disk. More...

#include <DataFileCache.h>

Collaboration diagram for lldb_private::CacheSignature:
Collaboration graph
[legend]

Public Member Functions

 CacheSignature ()=default
 
 CacheSignature (lldb_private::Module *module)
 Create a signature from a module. More...
 
 CacheSignature (lldb_private::ObjectFile *objfile)
 Create a signature from an object file. More...
 
void Clear ()
 
bool IsValid () const
 Return true only if the CacheSignature is valid. More...
 
bool operator== (const CacheSignature &rhs) const
 Check if two signatures are the same. More...
 
bool operator!= (const CacheSignature &rhs) const
 Check if two signatures differ. More...
 
bool Encode (DataEncoder &encoder) const
 Encode this object into a data encoder object. More...
 
bool Decode (const DataExtractor &data, lldb::offset_t *offset_ptr)
 Decode a serialized version of this object from data. More...
 

Public Attributes

llvm::Optional< UUIDm_uuid = llvm::None
 UUID of object file or module. More...
 
llvm::Optional< std::time_t > m_mod_time = llvm::None
 Modification time of file on disk. More...
 
llvm::Optional< std::time_t > m_obj_mod_time = llvm::None
 If this describes a .o file with a BSD archive, the BSD archive's modification time will be in m_mod_time, and the .o file's modification time will be in this m_obj_mod_time. More...
 

Detailed Description

A signature for a given file on disk.

Any files that are cached in the LLDB index cached need some data that uniquely identifies a file on disk and this information should be written into each cache file so we can validate if the cache file still matches the file we are trying to load cached data for. Objects can fill out this signature and then encode and decode them to validate the signatures match. If they do not match, the cache file on disk should be removed as it is out of date.

Definition at line 98 of file DataFileCache.h.

Constructor & Destructor Documentation

◆ CacheSignature() [1/3]

lldb_private::CacheSignature::CacheSignature ( )
default

◆ CacheSignature() [2/3]

CacheSignature::CacheSignature ( lldb_private::Module module)

◆ CacheSignature() [3/3]

CacheSignature::CacheSignature ( lldb_private::ObjectFile objfile)

Member Function Documentation

◆ Clear()

void lldb_private::CacheSignature::Clear ( )
inline

Definition at line 116 of file DataFileCache.h.

References m_mod_time, m_obj_mod_time, and m_uuid.

Referenced by CacheSignature(), and Decode().

◆ Decode()

bool CacheSignature::Decode ( const DataExtractor data,
lldb::offset_t offset_ptr 
)

Decode a serialized version of this object from data.

Parameters
dataThe decoder object that references the serialized data.
offset_ptrA pointer that contains the offset from which the data will be decoded from that gets updated as data gets decoded.
Returns
True if the signature was successfully decoded, false otherwise.

Definition at line 224 of file DataFileCache.cpp.

References Clear(), eSignatureEnd, eSignatureModTime, eSignatureObjectModTime, eSignatureUUID, lldb_private::UUID::fromData(), lldb_private::DataExtractor::GetData(), lldb_private::DataExtractor::GetU32(), lldb_private::DataExtractor::GetU8(), IsValid(), m_mod_time, m_obj_mod_time, and m_uuid.

Referenced by lldb_private::ManualDWARFIndex::Decode(), and lldb_private::Symtab::Decode().

◆ Encode()

bool CacheSignature::Encode ( DataEncoder &  encoder) const

Encode this object into a data encoder object.

This allows this object to be serialized to disk. The CacheSignature object must have at least one member variable that has a value in order to be serialized so that we can match this data to when the cached file is loaded at a later time.

Parameters
encoderA data encoder object that serialized bytes will be encoded into.
Returns
True if a signature was encoded, and false if there were no member variables that had value. False indicates this data should not be cached to disk because we were unable to encode a valid signature.

Definition at line 202 of file DataFileCache.cpp.

References eSignatureEnd, eSignatureModTime, eSignatureObjectModTime, eSignatureUUID, IsValid(), m_mod_time, m_obj_mod_time, and m_uuid.

Referenced by lldb_private::ManualDWARFIndex::Encode(), and lldb_private::Symtab::Encode().

◆ IsValid()

bool lldb_private::CacheSignature::IsValid ( ) const
inline

Return true only if the CacheSignature is valid.

Cache signatures are considered valid only if there is a UUID in the file that can uniquely identify the file. Some build systems play with modification times of file so we can not trust them without using valid unique idenifier like the UUID being valid.

Definition at line 128 of file DataFileCache.h.

References m_uuid.

Referenced by Decode(), and Encode().

◆ operator!=()

bool lldb_private::CacheSignature::operator!= ( const CacheSignature rhs) const
inline

Check if two signatures differ.

Definition at line 137 of file DataFileCache.h.

◆ operator==()

bool lldb_private::CacheSignature::operator== ( const CacheSignature rhs) const
inline

Check if two signatures are the same.

Definition at line 131 of file DataFileCache.h.

References m_mod_time, m_obj_mod_time, and m_uuid.

Member Data Documentation

◆ m_mod_time

llvm::Optional<std::time_t> lldb_private::CacheSignature::m_mod_time = llvm::None

Modification time of file on disk.

Definition at line 102 of file DataFileCache.h.

Referenced by CacheSignature(), Clear(), Decode(), Encode(), and operator==().

◆ m_obj_mod_time

llvm::Optional<std::time_t> lldb_private::CacheSignature::m_obj_mod_time = llvm::None

If this describes a .o file with a BSD archive, the BSD archive's modification time will be in m_mod_time, and the .o file's modification time will be in this m_obj_mod_time.

Definition at line 106 of file DataFileCache.h.

Referenced by CacheSignature(), Clear(), Decode(), Encode(), and operator==().

◆ m_uuid

llvm::Optional<UUID> lldb_private::CacheSignature::m_uuid = llvm::None

UUID of object file or module.

Definition at line 100 of file DataFileCache.h.

Referenced by CacheSignature(), Clear(), Decode(), Encode(), IsValid(), and operator==().


The documentation for this struct was generated from the following files: