1 //===-- PathMappingList.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_PathMappingList_h_
11 #define liblldb_PathMappingList_h_
17 // Other libraries and framework includes
18 #include "lldb/Core/ConstString.h"
19 #include "lldb/Core/Error.h"
22 namespace lldb_private {
28 typedef void (*ChangedCallback) (const PathMappingList &path_list,
31 //------------------------------------------------------------------
32 // Constructors and Destructors
33 //------------------------------------------------------------------
36 PathMappingList (ChangedCallback callback,
37 void *callback_baton);
39 PathMappingList (const PathMappingList &rhs);
43 const PathMappingList &
44 operator =(const PathMappingList &rhs);
47 Append (const ConstString &path, const ConstString &replacement, bool notify);
50 Append (const PathMappingList &rhs, bool notify);
55 // By default, dump all pairs.
57 Dump (Stream *s, int pair_index=-1);
62 return m_pairs.empty();
68 return m_pairs.size();
72 GetPathsAtIndex (uint32_t idx, ConstString &path, ConstString &new_path) const;
75 Insert (const ConstString &path,
76 const ConstString &replacement,
81 Remove (size_t index, bool notify);
84 Remove (const ConstString &path, bool notify);
87 Replace (const ConstString &path,
88 const ConstString &replacement,
92 Replace (const ConstString &path,
93 const ConstString &replacement,
97 RemapPath (const ConstString &path, ConstString &new_path) const;
99 //------------------------------------------------------------------
100 /// Remaps a source file given \a path into \a new_path.
102 /// Remaps \a path if any source remappings match. This function
103 /// does NOT stat the file system so it can be used in tight loops
104 /// where debug info is being parsed.
107 /// The original source file path to try and remap.
109 /// @param[out] new_path
110 /// The newly remapped filespec that is may or may not exist.
113 /// /b true if \a path was successfully located and \a new_path
114 /// is filled in with a new source path, \b false otherwise.
115 //------------------------------------------------------------------
117 RemapPath (const char *path, std::string &new_path) const;
120 ReverseRemapPath (const ConstString &path, ConstString &new_path) const;
122 //------------------------------------------------------------------
123 /// Finds a source file given a file spec using the path remappings.
125 /// Tries to resolve \a orig_spec by checking the path remappings.
126 /// It makes sure the file exists by checking with the file system,
127 /// so this call can be expensive if the remappings are on a network
128 /// or are even on the local file system, so use this function
129 /// sparingly (not in a tight debug info parsing loop).
131 /// @param[in] orig_spec
132 /// The original source file path to try and remap.
134 /// @param[out] new_spec
135 /// The newly remapped filespec that is guaranteed to exist.
138 /// /b true if \a orig_spec was successfully located and
139 /// \a new_spec is filled in with an existing file spec,
140 /// \b false otherwise.
141 //------------------------------------------------------------------
143 FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
146 FindIndexForPath (const ConstString &path) const;
149 GetModificationID() const
154 typedef std::pair <ConstString, ConstString> pair;
155 typedef std::vector <pair> collection;
156 typedef collection::iterator iterator;
157 typedef collection::const_iterator const_iterator;
160 FindIteratorForPath (const ConstString &path);
163 FindIteratorForPath (const ConstString &path) const;
166 ChangedCallback m_callback;
167 void * m_callback_baton;
168 uint32_t m_mod_id; // Incremented anytime anything is added or removed.
171 } // namespace lldb_private
173 #endif // liblldb_PathMappingList_h_