@@ -447,13 +447,14 @@ void SourceManager::FindLinesMatchingRegex(SupportFileSP support_file_sp,
447
447
448
448
SourceManager::File::File (SupportFileSP support_file_sp,
449
449
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()) {
452
452
CommonInitializer (support_file_sp, {});
453
453
}
454
454
455
455
SourceManager::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(),
457
458
m_debugger_wp(target_sp ? target_sp->GetDebugger ().shared_from_this()
458
459
: DebuggerSP()),
459
460
m_target_wp(target_sp) {
@@ -532,9 +533,11 @@ void SourceManager::File::CommonInitializer(SupportFileSP support_file_sp,
532
533
}
533
534
534
535
// If the file exists, read in the data.
535
- if (m_mod_time != llvm::sys::TimePoint<>())
536
+ if (m_mod_time != llvm::sys::TimePoint<>()) {
536
537
m_data_sp = FileSystem::Instance ().CreateDataBuffer (
537
538
m_support_file_sp->GetSpecOnly ());
539
+ m_checksum = llvm::MD5::hash (m_data_sp->GetData ());
540
+ }
538
541
}
539
542
540
543
void SourceManager::File::SetSupportFile (lldb::SupportFileSP support_file_sp) {
@@ -835,14 +838,24 @@ SourceManager::FileSP SourceManager::SourceFileCache::FindSourceFile(
835
838
return {};
836
839
}
837
840
841
+ static std::string toString (const Checksum &checksum) {
842
+ if (!checksum)
843
+ return " " ;
844
+ return std::string (llvm::formatv (" {0}" , checksum.digest ()));
845
+ }
846
+
838
847
void 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
841
852
for (auto &entry : m_file_cache) {
842
853
if (!entry.second )
843
854
continue ;
844
855
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 ()),
846
859
file->GetNumLines (), entry.first .GetPath ());
847
860
}
848
861
}
0 commit comments