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 (off_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 //------------------------------------------------------------------
121 /// Finds a source file given a file spec using the path remappings.
123 /// Tries to resolve \a orig_spec by checking the path remappings.
124 /// It makes sure the file exists by checking with the file system,
125 /// so this call can be expensive if the remappings are on a network
126 /// or are even on the local file system, so use this function
127 /// sparingly (not in a tight debug info parsing loop).
129 /// @param[in] orig_spec
130 /// The original source file path to try and remap.
132 /// @param[out] new_spec
133 /// The newly remapped filespec that is guaranteed to exist.
136 /// /b true if \a orig_spec was successfully located and
137 /// \a new_spec is filled in with an existing file spec,
138 /// \b false otherwise.
139 //------------------------------------------------------------------
141 FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
144 FindIndexForPath (const ConstString &path) const;
147 GetModificationID() const
152 typedef std::pair <ConstString, ConstString> pair;
153 typedef std::vector <pair> collection;
154 typedef collection::iterator iterator;
155 typedef collection::const_iterator const_iterator;
158 FindIteratorForPath (const ConstString &path);
161 FindIteratorForPath (const ConstString &path) const;
164 ChangedCallback m_callback;
165 void * m_callback_baton;
166 uint32_t m_mod_id; // Incremented anytime anything is added or removed.
169 } // namespace lldb_private
171 #endif // liblldb_PathMappingList_h_