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>

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

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. More...
 
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
 
llvm::Optional< FileSpecRemapPath (llvm::StringRef path, bool only_if_exists=false) const
 Remaps a source file given path into new_path. More...
 
bool RemapPath (const char *, std::string &) const =delete
 
llvm::Optional< llvm::StringRef > ReverseRemapPath (const FileSpec &file, FileSpec &fixed) const
 Perform reverse source path remap for input file. More...
 
llvm::Optional< FileSpecFindFile (const FileSpec &orig_spec) const
 Finds a source file given a file spec using the path remappings. More...
 
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

collection m_pairs
 
ChangedCallback m_callback = nullptr
 
void * m_callback_baton = nullptr
 
uint32_t m_mod_id = 0
 

Detailed Description

Definition at line 20 of file PathMappingList.h.

Member Typedef Documentation

◆ ChangedCallback

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

Definition at line 22 of file PathMappingList.h.

◆ collection

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

Definition at line 134 of file PathMappingList.h.

◆ const_iterator

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

Definition at line 136 of file PathMappingList.h.

◆ iterator

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

Definition at line 135 of file PathMappingList.h.

◆ pair

Definition at line 133 of file PathMappingList.h.

Constructor & Destructor Documentation

◆ PathMappingList() [1/3]

PathMappingList::PathMappingList ( )

Definition at line 40 of file PathMappingList.cpp.

◆ PathMappingList() [2/3]

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

Definition at line 42 of file PathMappingList.cpp.

◆ PathMappingList() [3/3]

PathMappingList::PathMappingList ( const PathMappingList rhs)

Definition at line 45 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 68 of file PathMappingList.cpp.

References m_callback, m_callback_baton, m_mod_id, 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 79 of file PathMappingList.cpp.

References Append(), 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()

llvm::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 241 of file PathMappingList.cpp.

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

Referenced by lldb_private::SourceManager::File::CommonInitializer(), and lldb_private::Module::FindSourceFile().

◆ FindIndexForPath()

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

Definition at line 313 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 291 of file PathMappingList.cpp.

References m_pairs.

Referenced by Remove().

◆ FindIteratorForPath() [2/2]

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

Definition at line 278 of file PathMappingList.cpp.

References m_pairs.

◆ GetModificationID()

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

Definition at line 130 of file PathMappingList.h.

References m_mod_id.

Referenced by lldb_private::SourceManager::File::CommonInitializer().

◆ GetPathsAtIndex()

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

Definition at line 303 of file PathMappingList.cpp.

References m_pairs.

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

References m_pairs.

◆ operator=()

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

Definition at line 48 of file PathMappingList.cpp.

References m_callback, m_callback_baton, m_mod_id, 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]

llvm::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, None 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 187 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(), and m_pairs.

◆ Remove() [1/2]

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

Definition at line 265 of file PathMappingList.cpp.

References FindIteratorForPath(), m_callback, m_callback_baton, m_mod_id, and m_pairs.

◆ Remove() [2/2]

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

Definition at line 117 of file PathMappingList.cpp.

References m_callback, m_callback_baton, m_mod_id, and m_pairs.

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

References m_callback, m_callback_baton, m_mod_id, and m_pairs.

◆ ReverseRemapPath()

llvm::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
llvm::None 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 224 of file PathMappingList.cpp.

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

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

◆ ToJSON()

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

Definition at line 147 of file PathMappingList.cpp.

References m_pairs.

Member Data Documentation

◆ m_callback

ChangedCallback lldb_private::PathMappingList::m_callback = nullptr
protected

Definition at line 143 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 144 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 145 of file PathMappingList.h.

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

◆ m_pairs

collection lldb_private::PathMappingList::m_pairs
protected

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