diff options
-rw-r--r-- | lldb/include/lldb/Core/SourceManager.h | 7 | ||||
-rw-r--r-- | lldb/include/lldb/Target/PathMappingList.h | 6 | ||||
-rw-r--r-- | lldb/source/Core/SourceManager.cpp | 27 | ||||
-rw-r--r-- | lldb/source/Target/PathMappingList.cpp | 26 |
4 files changed, 50 insertions, 16 deletions
diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h index ce17c495d26..891204d7970 100644 --- a/lldb/include/lldb/Core/SourceManager.h +++ b/lldb/include/lldb/Core/SourceManager.h @@ -64,6 +64,12 @@ public: return m_file_spec; } + uint32_t + GetSourceMapModificationID() const + { + return m_source_map_mod_id; + } + protected: bool @@ -72,6 +78,7 @@ public: FileSpec m_file_spec_orig; // The original file spec that was used (can be different from m_file_spec) FileSpec m_file_spec; // The actualy file spec being used (if the target has source mappings, this might be different from m_file_spec_orig) TimeValue m_mod_time; // Keep the modification time that this file data is valid for + uint32_t m_source_map_mod_id; // If the target uses path remappings, be sure to clear our notion of a source file if the path modification ID changes lldb::DataBufferSP m_data_sp; typedef std::vector<uint32_t> LineOffsets; LineOffsets m_offsets; diff --git a/lldb/include/lldb/Target/PathMappingList.h b/lldb/include/lldb/Target/PathMappingList.h index 9244818c5fc..73a41f85e01 100644 --- a/lldb/include/lldb/Target/PathMappingList.h +++ b/lldb/include/lldb/Target/PathMappingList.h @@ -144,6 +144,11 @@ public: uint32_t FindIndexForPath (const ConstString &path) const; + uint32_t + GetModificationID() const + { + return m_mod_id; + } protected: typedef std::pair <ConstString, ConstString> pair; typedef std::vector <pair> collection; @@ -159,6 +164,7 @@ protected: collection m_pairs; ChangedCallback m_callback; void * m_callback_baton; + uint32_t m_mod_id; // Incremented anytime anything is added or removed. }; } // namespace lldb_private diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index 4d3e9f31a48..4267da3e467 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -67,8 +67,19 @@ SourceManager::~SourceManager() SourceManager::FileSP SourceManager::GetFile (const FileSpec &file_spec) { + bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec); + FileSP file_sp; - file_sp = m_debugger->GetSourceFileCache().FindSourceFile (file_spec); + if (same_as_previous) + file_sp = m_last_file_sp; + else + file_sp = m_debugger->GetSourceFileCache().FindSourceFile (file_spec); + + // It the target source path map has been updated, get this file again so we + // can successfully remap the source file + if (file_sp && file_sp->GetSourceMapModificationID() != m_target->GetSourcePathMap().GetModificationID()) + file_sp.reset(); + // If file_sp is no good or it points to a non-existent file, reset it. if (!file_sp || !file_sp->GetFileSpec().Exists()) { @@ -159,10 +170,7 @@ SourceManager::DisplaySourceLinesWithLineNumbers const SymbolContextList *bp_locs ) { - bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec); - - if (!same_as_previous) - m_last_file_sp = GetFile (file_spec); + FileSP file_sp (GetFile (file_spec)); uint32_t start_line; uint32_t count = context_before + context_after + 1; @@ -171,12 +179,12 @@ SourceManager::DisplaySourceLinesWithLineNumbers else start_line = 1; - if (line == 0) + if (m_last_file_sp.get() != file_sp.get()) { - if (!same_as_previous) + if (line == 0) m_last_line = 0; + m_last_file_sp = file_sp; } - return DisplaySourceLinesWithLineNumbersUsingLastFile (start_line, count, line, current_line_cstr, s, bp_locs); } @@ -317,6 +325,7 @@ SourceManager::File::File(const FileSpec &file_spec, Target *target) : m_file_spec_orig (file_spec), m_file_spec(file_spec), m_mod_time (file_spec.GetModificationTime()), + m_source_map_mod_id (0), m_data_sp(), m_offsets() { @@ -324,6 +333,8 @@ SourceManager::File::File(const FileSpec &file_spec, Target *target) : { if (target) { + m_source_map_mod_id = target->GetSourcePathMap().GetModificationID(); + if (!file_spec.GetDirectory() && file_spec.GetFilename()) { // If this is just a file name, lets see if we can find it in the target: diff --git a/lldb/source/Target/PathMappingList.cpp b/lldb/source/Target/PathMappingList.cpp index b6a7bca1774..db23a0b2713 100644 --- a/lldb/source/Target/PathMappingList.cpp +++ b/lldb/source/Target/PathMappingList.cpp @@ -28,18 +28,17 @@ using namespace lldb_private; PathMappingList::PathMappingList () : m_pairs (), m_callback (NULL), - m_callback_baton (NULL) + m_callback_baton (NULL), + m_mod_id (0) { } -PathMappingList::PathMappingList -( - ChangedCallback callback, - void *callback_baton -) : +PathMappingList::PathMappingList (ChangedCallback callback, + void *callback_baton) : m_pairs (), m_callback (callback), - m_callback_baton (callback_baton) + m_callback_baton (callback_baton), + m_mod_id (0) { } @@ -47,7 +46,8 @@ PathMappingList::PathMappingList PathMappingList::PathMappingList (const PathMappingList &rhs) : m_pairs (rhs.m_pairs), m_callback (NULL), - m_callback_baton (NULL) + m_callback_baton (NULL), + m_mod_id (0) { } @@ -60,6 +60,7 @@ PathMappingList::operator =(const PathMappingList &rhs) m_pairs = rhs.m_pairs; m_callback = NULL; m_callback_baton = NULL; + m_mod_id = rhs.m_mod_id; } return *this; } @@ -77,6 +78,7 @@ PathMappingList::Append (const ConstString &path, const ConstString &replacement, bool notify) { + ++m_mod_id; m_pairs.push_back(pair(path, replacement)); if (notify && m_callback) m_callback (*this, m_callback_baton); @@ -85,6 +87,7 @@ PathMappingList::Append (const ConstString &path, void PathMappingList::Append (const PathMappingList &rhs, bool notify) { + ++m_mod_id; if (!rhs.m_pairs.empty()) { const_iterator pos, end = rhs.m_pairs.end(); @@ -101,6 +104,7 @@ PathMappingList::Insert (const ConstString &path, uint32_t index, bool notify) { + ++m_mod_id; iterator insert_iter; if (index >= m_pairs.size()) insert_iter = m_pairs.end(); @@ -120,6 +124,7 @@ PathMappingList::Replace (const ConstString &path, iterator insert_iter; if (index >= m_pairs.size()) return false; + ++m_mod_id; m_pairs[index] = pair(path, replacement); if (notify && m_callback) m_callback (*this, m_callback_baton); @@ -132,6 +137,7 @@ PathMappingList::Remove (off_t index, bool notify) if (index >= m_pairs.size()) return false; + ++m_mod_id; iterator iter = m_pairs.begin() + index; m_pairs.erase(iter); if (notify && m_callback) @@ -164,6 +170,8 @@ PathMappingList::Dump (Stream *s, int pair_index) void PathMappingList::Clear (bool notify) { + if (!m_pairs.empty()) + ++m_mod_id; m_pairs.clear(); if (notify && m_callback) m_callback (*this, m_callback_baton); @@ -255,6 +263,7 @@ PathMappingList::Replace (const ConstString &path, const ConstString &new_path, uint32_t idx = FindIndexForPath (path); if (idx < m_pairs.size()) { + ++m_mod_id; m_pairs[idx].second = new_path; if (notify && m_callback) m_callback (*this, m_callback_baton); @@ -269,6 +278,7 @@ PathMappingList::Remove (const ConstString &path, bool notify) iterator pos = FindIteratorForPath (path); if (pos != m_pairs.end()) { + ++m_mod_id; m_pairs.erase (pos); if (notify && m_callback) m_callback (*this, m_callback_baton); |