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>

Public Member Functions

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

Public Attributes

std::optional< UUIDm_uuid
 UUID of object file or module.
 
std::optional< std::time_t > m_mod_time
 Modification time of file on disk.
 
std::optional< std::time_t > m_obj_mod_time
 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.
 

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 109 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 127 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 232 of file DataFileCache.cpp.

References Clear(), eSignatureEnd, eSignatureModTime, eSignatureObjectModTime, eSignatureUUID, 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::plugin::dwarf::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 210 of file DataFileCache.cpp.

References lldb_private::DataEncoder::AppendData(), lldb_private::DataEncoder::AppendU32(), lldb_private::DataEncoder::AppendU8(), eSignatureEnd, eSignatureModTime, eSignatureObjectModTime, eSignatureUUID, IsValid(), m_mod_time, m_obj_mod_time, and m_uuid.

Referenced by lldb_private::Symtab::Encode(), and lldb_private::plugin::dwarf::ManualDWARFIndex::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 139 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 148 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 142 of file DataFileCache.h.

References m_mod_time, m_obj_mod_time, and m_uuid.

Member Data Documentation

◆ m_mod_time

std::optional<std::time_t> lldb_private::CacheSignature::m_mod_time

Modification time of file on disk.

Definition at line 113 of file DataFileCache.h.

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

◆ m_obj_mod_time

std::optional<std::time_t> lldb_private::CacheSignature::m_obj_mod_time

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 117 of file DataFileCache.h.

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

◆ m_uuid

std::optional<UUID> lldb_private::CacheSignature::m_uuid

UUID of object file or module.

Definition at line 111 of file DataFileCache.h.

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


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