LLDB mainline
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
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 ()
 
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 FindIndexForPath (llvm::StringRef path) const
 
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

iterator FindIteratorForPath (ConstString path)
 
const_iterator FindIteratorForPath (ConstString path) const
 

Protected Attributes

std::recursive_mutex m_mutex
 
collection m_pairs
 
ChangedCallback m_callback = nullptr
 
void * m_callback_baton = nullptr
 
uint32_t m_mod_id = 0
 

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 147 of file PathMappingList.h.

◆ const_iterator

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

Definition at line 149 of file PathMappingList.h.

◆ iterator

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

Definition at line 148 of file PathMappingList.h.

◆ pair

Definition at line 146 of file PathMappingList.h.

Constructor & Destructor Documentation

◆ PathMappingList() [1/3]

PathMappingList::PathMappingList ( )

Definition at line 41 of file PathMappingList.cpp.

◆ PathMappingList() [2/3]

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

Definition at line 43 of file PathMappingList.cpp.

◆ PathMappingList() [3/3]

PathMappingList::PathMappingList ( const PathMappingList rhs)

Definition at line 46 of file PathMappingList.cpp.

◆ ~PathMappingList()

PathMappingList::~PathMappingList ( )
default

Member Function Documentation

◆ Append() [1/2]

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

Definition at line 71 of file PathMappingList.cpp.

References m_callback, m_callback_baton, m_mod_id, m_mutex, and m_pairs.

◆ Append() [2/2]

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

◆ 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 83 of file PathMappingList.cpp.

References Append(), m_mutex, and m_pairs.

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 254 of file PathMappingList.cpp.

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

Referenced by lldb_private::Module::FindSourceFile().

◆ FindIndexForPath()

uint32_t PathMappingList::FindIndexForPath ( llvm::StringRef  path) const

Definition at line 331 of file PathMappingList.cpp.

References m_mutex, m_pairs, and UINT32_MAX.

Referenced by Replace().

◆ FindIteratorForPath() [1/2]

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

Definition at line 307 of file PathMappingList.cpp.

References m_mutex, and m_pairs.

Referenced by Remove().

◆ FindIteratorForPath() [2/2]

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

Definition at line 293 of file PathMappingList.cpp.

References m_mutex, and m_pairs.

◆ GetModificationID()

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

Definition at line 139 of file PathMappingList.h.

References m_mod_id, and m_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 55 of file PathMappingList.h.

References m_mutex, and m_pairs.

◆ operator=()

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

Definition at line 49 of file PathMappingList.cpp.

References m_callback, m_callback_baton, m_mod_id, m_mutex, and m_pairs.

◆ RemapPath() [1/3]

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

◆ RemapPath() [2/3]

bool PathMappingList::RemapPath ( ConstString  path,
ConstString new_path 
) const

◆ 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 197 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_mutex, and m_pairs.

◆ Remove() [1/2]

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

◆ Remove() [2/2]

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

◆ Replace() [1/2]

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

◆ Replace() [2/2]

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

Definition at line 112 of file PathMappingList.cpp.

References m_callback, m_callback_baton, m_mod_id, m_mutex, and m_pairs.

◆ 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 235 of file PathMappingList.cpp.

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

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

◆ ToJSON()

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

Definition at line 156 of file PathMappingList.cpp.

References m_mutex, and m_pairs.

Referenced by lldb_private::OptionValuePathMappings::ToJSON().

Member Data Documentation

◆ m_callback

ChangedCallback lldb_private::PathMappingList::m_callback = nullptr
protected

Definition at line 156 of file PathMappingList.h.

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

◆ m_callback_baton

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

Definition at line 157 of file PathMappingList.h.

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

◆ m_mod_id

uint32_t lldb_private::PathMappingList::m_mod_id = 0
protected

Definition at line 158 of file PathMappingList.h.

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

◆ m_mutex

std::recursive_mutex lldb_private::PathMappingList::m_mutex
mutableprotected

◆ m_pairs

collection lldb_private::PathMappingList::m_pairs
protected

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