LLDB mainline
lldb_private::PathMappingList Class Reference

#include <PathMappingList.h>

Public Types

typedef void(* ChangedCallback) (const PathMappingList &path_list, void *baton)

Public Member Functions

 PathMappingList ()
 PathMappingList (ChangedCallback callback, void *callback_baton)
 PathMappingList (const PathMappingList &rhs)
 ~PathMappingList ()
const PathMappingListoperator= (const PathMappingList &rhs)
void Append (llvm::StringRef path, llvm::StringRef replacement, bool notify)
void Append (const PathMappingList &rhs, bool notify)
bool AppendUnique (llvm::StringRef path, llvm::StringRef replacement, bool notify)
 Append <path, replacement> pair without duplication.
void Clear (bool notify)
void Dump (Stream *s, int pair_index=-1)
llvm::json::Value ToJSON () const
bool IsEmpty () const
size_t GetSize () const
bool GetPathsAtIndex (uint32_t idx, ConstString &path, ConstString &new_path) const
void Insert (llvm::StringRef path, llvm::StringRef replacement, uint32_t insert_idx, bool notify)
bool Remove (size_t index, bool notify)
bool Remove (ConstString path, bool notify)
bool Replace (llvm::StringRef path, llvm::StringRef replacement, bool notify)
bool Replace (llvm::StringRef path, llvm::StringRef replacement, uint32_t index, bool notify)
bool RemapPath (ConstString path, ConstString &new_path) const
std::optional< FileSpecRemapPath (llvm::StringRef path, bool only_if_exists=false) const
 Remaps a source file given path into new_path.
bool RemapPath (const char *, std::string &) const =delete
std::optional< llvm::StringRef > ReverseRemapPath (const FileSpec &file, FileSpec &fixed) const
 Perform reverse source path remap for input file.
std::optional< FileSpecFindFile (const FileSpec &orig_spec) const
 Finds a source file given a file spec using the path remappings.
uint32_t GetModificationID () const

Protected Types

typedef std::pair< ConstString, ConstStringpair
typedef std::vector< paircollection
typedef collection::iterator iterator
typedef collection::const_iterator const_iterator

Protected Member Functions

void AppendNoLock (llvm::StringRef path, llvm::StringRef replacement)
uint32_t FindIndexForPathNoLock (llvm::StringRef path) const
void Notify (bool notify) const
iterator FindIteratorForPath (ConstString path)
const_iterator FindIteratorForPath (ConstString path) const

Protected Attributes

collection m_pairs
std::mutex m_pairs_mutex
ChangedCallback m_callback = nullptr
void * m_callback_baton = nullptr
std::mutex m_callback_mutex
uint32_t m_mod_id = 0
 Incremented anytime anything is added to or removed from m_pairs.

Detailed Description

Definition at line 23 of file PathMappingList.h.

Member Typedef Documentation

◆ ChangedCallback

typedef void(* lldb_private::PathMappingList::ChangedCallback) (const PathMappingList &path_list, void *baton)

Definition at line 25 of file PathMappingList.h.

◆ collection

typedef std::vector<pair> lldb_private::PathMappingList::collection
protected

Definition at line 143 of file PathMappingList.h.

◆ const_iterator

typedef collection::const_iterator lldb_private::PathMappingList::const_iterator
protected

Definition at line 145 of file PathMappingList.h.

◆ iterator

typedef collection::iterator lldb_private::PathMappingList::iterator
protected

Definition at line 144 of file PathMappingList.h.

◆ pair

Definition at line 142 of file PathMappingList.h.

Constructor & Destructor Documentation

◆ PathMappingList() [1/3]

PathMappingList::PathMappingList ( )

Definition at line 41 of file PathMappingList.cpp.

References m_pairs.

Referenced by Append(), operator=(), PathMappingList(), and ~PathMappingList().

◆ PathMappingList() [2/3]

PathMappingList::PathMappingList ( ChangedCallback callback,
void * callback_baton )

Definition at line 43 of file PathMappingList.cpp.

References m_callback, m_callback_baton, and m_pairs.

◆ PathMappingList() [3/3]

PathMappingList::PathMappingList ( const PathMappingList & rhs)

Definition at line 46 of file PathMappingList.cpp.

References m_pairs, and PathMappingList().

◆ ~PathMappingList()

PathMappingList::~PathMappingList ( )
default

References PathMappingList().

Member Function Documentation

◆ Append() [1/2]

void PathMappingList::Append ( const PathMappingList & rhs,
bool notify )

Definition at line 90 of file PathMappingList.cpp.

References m_mod_id, m_pairs, m_pairs_mutex, Notify(), and PathMappingList().

◆ Append() [2/2]

void PathMappingList::Append ( llvm::StringRef path,
llvm::StringRef replacement,
bool notify )

◆ AppendNoLock()

void PathMappingList::AppendNoLock ( llvm::StringRef path,
llvm::StringRef replacement )
protected

Definition at line 63 of file PathMappingList.cpp.

References m_mod_id, and m_pairs.

Referenced by Append(), and AppendUnique().

◆ AppendUnique()

bool PathMappingList::AppendUnique ( llvm::StringRef path,
llvm::StringRef replacement,
bool notify )

Append <path, replacement> pair without duplication.

Returns
whether appending suceeds without duplication or not.

Definition at line 104 of file PathMappingList.cpp.

References AppendNoLock(), m_pairs, m_pairs_mutex, and Notify().

Referenced by lldb_private::BreakpointResolverFileLine::DeduceSourceMapping().

◆ Clear()

void PathMappingList::Clear ( bool notify)

◆ Dump()

void PathMappingList::Dump ( Stream * s,
int pair_index = -1 )

◆ FindFile()

std::optional< FileSpec > PathMappingList::FindFile ( const FileSpec & orig_spec) const

Finds a source file given a file spec using the path remappings.

Tries to resolve orig_spec by checking the path remappings. It makes sure the file exists by checking with the file system, so this call can be expensive if the remappings are on a network or are even on the local file system, so use this function sparingly (not in a tight debug info parsing loop).

Parameters
[in]orig_specThe original source file path to try and remap.
Returns
The newly remapped filespec that is guaranteed to exist.

Definition at line 282 of file PathMappingList.cpp.

References lldb_private::FileSpec::GetPath(), and RemapPath().

◆ FindIndexForPathNoLock()

uint32_t PathMappingList::FindIndexForPathNoLock ( llvm::StringRef path) const
protected

Definition at line 361 of file PathMappingList.cpp.

References m_pairs, and UINT32_MAX.

Referenced by Replace().

◆ FindIteratorForPath() [1/2]

PathMappingList::iterator PathMappingList::FindIteratorForPath ( ConstString path)
protected

Definition at line 336 of file PathMappingList.cpp.

References m_pairs, and m_pairs_mutex.

Referenced by Remove().

◆ FindIteratorForPath() [2/2]

PathMappingList::const_iterator PathMappingList::FindIteratorForPath ( ConstString path) const
protected

Definition at line 322 of file PathMappingList.cpp.

References m_pairs, and m_pairs_mutex.

◆ GetModificationID()

uint32_t lldb_private::PathMappingList::GetModificationID ( ) const
inline

Definition at line 136 of file PathMappingList.h.

References m_mod_id, and m_pairs_mutex.

◆ GetPathsAtIndex()

bool PathMappingList::GetPathsAtIndex ( uint32_t idx,
ConstString & path,
ConstString & new_path ) const

◆ GetSize()

size_t lldb_private::PathMappingList::GetSize ( ) const
inline

◆ Insert()

void PathMappingList::Insert ( llvm::StringRef path,
llvm::StringRef replacement,
uint32_t insert_idx,
bool notify )

◆ IsEmpty()

bool lldb_private::PathMappingList::IsEmpty ( ) const
inline

Definition at line 54 of file PathMappingList.h.

References m_pairs, and m_pairs_mutex.

◆ Notify()

void PathMappingList::Notify ( bool notify) const
protected

◆ operator=()

const PathMappingList & PathMappingList::operator= ( const PathMappingList & rhs)

◆ RemapPath() [1/3]

bool lldb_private::PathMappingList::RemapPath ( const char * ,
std::string &  ) const
delete

◆ RemapPath() [2/3]

◆ RemapPath() [3/3]

std::optional< FileSpec > PathMappingList::RemapPath ( llvm::StringRef path,
bool only_if_exists = false ) const

Remaps a source file given path into new_path.

Remaps path if any source remappings match. This function does NOT stat the file system so it can be used in tight loops where debug info is being parsed.

Parameters
[in]pathThe original source file path to try and remap.
[in]only_if_existsIf true, besides matching path with the remapping rules, this tries to check with the filesystem that the remapped file exists. If no valid file is found, std::nullopt is returned. This might be expensive, specially on a network.

If false, then the existence of the returned remapping is not checked.

Returns
The remapped filespec that may or may not exist on disk.

Definition at line 225 of file PathMappingList.cpp.

References AppendPathComponents(), lldb_private::eLazyBoolCalculate, lldb_private::eLazyBoolNo, lldb_private::eLazyBoolYes, lldb_private::FileSpec::GuessPathStyle(), lldb_private::FileSystem::Instance(), lldb_private::FileSpec::IsRelative(), m_pairs, and m_pairs_mutex.

◆ Remove() [1/2]

bool PathMappingList::Remove ( ConstString path,
bool notify )

Definition at line 307 of file PathMappingList.cpp.

References FindIteratorForPath(), m_mod_id, m_pairs, m_pairs_mutex, and Notify().

◆ Remove() [2/2]

bool PathMappingList::Remove ( size_t index,
bool notify )

Definition at line 150 of file PathMappingList.cpp.

References m_mod_id, m_pairs, m_pairs_mutex, and Notify().

◆ Replace() [1/2]

bool PathMappingList::Replace ( llvm::StringRef path,
llvm::StringRef replacement,
bool notify )

Definition at line 293 of file PathMappingList.cpp.

References FindIndexForPathNoLock(), m_mod_id, m_pairs, m_pairs_mutex, and Notify().

◆ Replace() [2/2]

bool PathMappingList::Replace ( llvm::StringRef path,
llvm::StringRef replacement,
uint32_t index,
bool notify )

Definition at line 137 of file PathMappingList.cpp.

References m_mod_id, m_pairs, m_pairs_mutex, and Notify().

◆ ReverseRemapPath()

std::optional< llvm::StringRef > PathMappingList::ReverseRemapPath ( const FileSpec & file,
FileSpec & fixed ) const

Perform reverse source path remap for input file.

Source maps contains a list of <from_original_path, to_new_path> mappings. Reverse remap means locating a matching entry prefix using "to_new_path" part and replacing it with "from_original_path" part if found.

Parameters
[in]fileThe source path to reverse remap.
[in]fixedThe reversed mapped new path.
Returns
std::nullopt if no remapping happens, otherwise, the matching source map entry's ""to_new_pathto"" part (which is the prefix of file) is returned.

Definition at line 263 of file PathMappingList.cpp.

References AppendPathComponents(), lldb_private::FileSpec::GetPath(), lldb_private::FileSpec::GuessPathStyle(), m_pairs, m_pairs_mutex, and lldb_private::FileSpec::SetFile().

Referenced by lldb_private::Target::CreateBreakpoint().

◆ ToJSON()

llvm::json::Value PathMappingList::ToJSON ( ) const

Definition at line 183 of file PathMappingList.cpp.

References m_pairs, and m_pairs_mutex.

Member Data Documentation

◆ m_callback

ChangedCallback lldb_private::PathMappingList::m_callback = nullptr
protected

Definition at line 158 of file PathMappingList.h.

Referenced by Notify(), operator=(), and PathMappingList().

◆ m_callback_baton

void* lldb_private::PathMappingList::m_callback_baton = nullptr
protected

Definition at line 159 of file PathMappingList.h.

Referenced by Notify(), operator=(), and PathMappingList().

◆ m_callback_mutex

std::mutex lldb_private::PathMappingList::m_callback_mutex
mutableprotected

Definition at line 160 of file PathMappingList.h.

Referenced by Notify(), and operator=().

◆ m_mod_id

uint32_t lldb_private::PathMappingList::m_mod_id = 0
protected

Incremented anytime anything is added to or removed from m_pairs.

Also protected by m_pairs_mutex.

Definition at line 164 of file PathMappingList.h.

Referenced by Append(), AppendNoLock(), Clear(), GetModificationID(), Insert(), operator=(), Remove(), Remove(), Replace(), and Replace().

◆ m_pairs

◆ m_pairs_mutex


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