[Lldb-commits] [lldb] r121278 - in /lldb/trunk: include/lldb/Core/SourceManager.h source/Core/SourceManager.cpp

Greg Clayton gclayton at apple.com
Wed Dec 8 12:16:12 PST 2010


Author: gclayton
Date: Wed Dec  8 14:16:12 2010
New Revision: 121278

URL: http://llvm.org/viewvc/llvm-project?rev=121278&view=rev
Log:
Fixed an issue in our source manager where we were permanently caching source
file data, so if a source file was modified, we would always show the first
cached copy of the source data. We now check file modification times when
displaying source info so we can show the update source info.


Modified:
    lldb/trunk/include/lldb/Core/SourceManager.h
    lldb/trunk/source/Core/SourceManager.cpp

Modified: lldb/trunk/include/lldb/Core/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=121278&r1=121277&r2=121278&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/SourceManager.h (original)
+++ lldb/trunk/include/lldb/Core/SourceManager.h Wed Dec  8 14:16:12 2010
@@ -53,6 +53,7 @@
         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;

Modified: lldb/trunk/source/Core/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=121278&r1=121277&r2=121278&view=diff
==============================================================================
--- lldb/trunk/source/Core/SourceManager.cpp (original)
+++ lldb/trunk/source/Core/SourceManager.cpp Wed Dec  8 14:16:12 2010
@@ -171,6 +171,7 @@
 
 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 @@
 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)





More information about the lldb-commits mailing list