@@ -447,13 +447,14 @@ void SourceManager::FindLinesMatchingRegex(SupportFileSP support_file_sp,
447447
448448SourceManager::File::File (SupportFileSP support_file_sp,
449449 lldb::DebuggerSP debugger_sp)
450- : m_support_file_sp(std::make_shared<SupportFile>()), m_mod_time (),
451- m_debugger_wp(debugger_sp), m_target_wp(TargetSP()) {
450+ : m_support_file_sp(std::make_shared<SupportFile>()), m_checksum (),
451+ m_mod_time(), m_debugger_wp(debugger_sp), m_target_wp(TargetSP()) {
452452 CommonInitializer (support_file_sp, {});
453453}
454454
455455SourceManager::File::File (SupportFileSP support_file_sp, TargetSP target_sp)
456- : m_support_file_sp(std::make_shared<SupportFile>()), m_mod_time(),
456+ : m_support_file_sp(std::make_shared<SupportFile>()), m_checksum(),
457+ m_mod_time(),
457458 m_debugger_wp(target_sp ? target_sp->GetDebugger ().shared_from_this()
458459 : DebuggerSP()),
459460 m_target_wp(target_sp) {
@@ -532,9 +533,11 @@ void SourceManager::File::CommonInitializer(SupportFileSP support_file_sp,
532533 }
533534
534535 // If the file exists, read in the data.
535- if (m_mod_time != llvm::sys::TimePoint<>())
536+ if (m_mod_time != llvm::sys::TimePoint<>()) {
536537 m_data_sp = FileSystem::Instance ().CreateDataBuffer (
537538 m_support_file_sp->GetSpecOnly ());
539+ m_checksum = llvm::MD5::hash (m_data_sp->GetData ());
540+ }
538541}
539542
540543void SourceManager::File::SetSupportFile (lldb::SupportFileSP support_file_sp) {
@@ -835,14 +838,24 @@ SourceManager::FileSP SourceManager::SourceFileCache::FindSourceFile(
835838 return {};
836839}
837840
841+ static std::string toString (const Checksum &checksum) {
842+ if (!checksum)
843+ return " " ;
844+ return std::string (llvm::formatv (" {0}" , checksum.digest ()));
845+ }
846+
838847void SourceManager::SourceFileCache::Dump (Stream &stream) const {
839- stream << " Modification time Lines Path\n " ;
840- stream << " ------------------- -------- --------------------------------\n " ;
848+ // clang-format off
849+ stream << " Modification time MD5 Checksum (on-disk) MD5 Checksum (line table) Lines Path\n " ;
850+ stream << " ------------------- -------------------------------- -------------------------------- -------- --------------------------------\n " ;
851+ // clang-format on
841852 for (auto &entry : m_file_cache) {
842853 if (!entry.second )
843854 continue ;
844855 FileSP file = entry.second ;
845- stream.Format (" {0:%Y-%m-%d %H:%M:%S} {1,8:d} {2}\n " , file->GetTimestamp (),
856+ stream.Format (" {0:%Y-%m-%d %H:%M:%S} {1,32} {2,32} {3,8:d} {4}\n " ,
857+ file->GetTimestamp (), toString (file->GetChecksum ()),
858+ toString (file->GetSupportFile ()->GetChecksum ()),
846859 file->GetNumLines (), entry.first .GetPath ());
847860 }
848861}
0 commit comments