diff options
| -rw-r--r-- | lldb/include/lldb/Core/SourceManager.h | 1 | ||||
| -rw-r--r-- | lldb/source/Core/SourceManager.cpp | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h index 6c6fdfdd602..85a1fc19b45 100644 --- a/lldb/include/lldb/Core/SourceManager.h +++ b/lldb/include/lldb/Core/SourceManager.h @@ -53,6 +53,7 @@ public: CalculateLineOffsets (uint32_t line = UINT32_MAX); FileSpec m_file_spec; + TimeValue m_mod_time; // Keep the modification time that this file data is valid for lldb::DataBufferSP m_data_sp; typedef std::vector<uint32_t> LineOffsets; LineOffsets m_offsets; diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp index 2786fe40720..1efaaf21ab5 100644 --- a/lldb/source/Core/SourceManager.cpp +++ b/lldb/source/Core/SourceManager.cpp @@ -171,6 +171,7 @@ SourceManager::DisplayMoreWithLineNumbers (Stream *s) SourceManager::File::File(const FileSpec &file_spec) : m_file_spec(file_spec), + m_mod_time (m_file_spec.GetModificationTime()), m_data_sp(file_spec.ReadFileContents ()), m_offsets() { @@ -211,6 +212,17 @@ SourceManager::File::LineIsValid (uint32_t line) size_t SourceManager::File::DisplaySourceLines (uint32_t line, uint32_t context_before, uint32_t context_after, Stream *s) { + // TODO: use host API to sign up for file modifications to anything in our + // source cache and only update when we determine a file has been updated. + // For now we check each time we want to display info for the file. + TimeValue curr_mod_time (m_file_spec.GetModificationTime()); + if (m_mod_time != curr_mod_time) + { + m_mod_time = curr_mod_time; + m_data_sp = m_file_spec.ReadFileContents (); + m_offsets.clear(); + } + const uint32_t start_line = line <= context_before ? 1 : line - context_before; const uint32_t start_line_offset = GetLineOffset (start_line); if (start_line_offset != UINT32_MAX) |

