diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h index 2122860a5f6b..bfc5f93f696f 100644 --- a/lldb/include/lldb/Host/FileSystem.h +++ b/lldb/include/lldb/Host/FileSystem.h @@ -56,8 +56,12 @@ public: /// Returns the modification time of the given file. /// @{ - llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const; - llvm::sys::TimePoint<> GetModificationTime(const llvm::Twine &path) const; + llvm::sys::TimePoint<> + GetModificationTime(const FileSpec &file_spec, + bool nanosecond_precision = true) const; + llvm::sys::TimePoint<> + GetModificationTime(const llvm::Twine &path, + bool nanosecond_precision = true) const; /// @} /// Returns the on-disk size of the given file in bytes. diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp index a01059975891..db218a3f7638 100644 --- a/lldb/source/Host/common/FileSystem.cpp +++ b/lldb/source/Host/common/FileSystem.cpp @@ -64,15 +64,22 @@ Optional &FileSystem::InstanceImpl() { } sys::TimePoint<> -FileSystem::GetModificationTime(const FileSpec &file_spec) const { - return GetModificationTime(file_spec.GetPath()); +FileSystem::GetModificationTime(const FileSpec &file_spec, + bool nanosecond_precision) const { + return GetModificationTime(file_spec.GetPath(), nanosecond_precision); } -sys::TimePoint<> FileSystem::GetModificationTime(const Twine &path) const { +sys::TimePoint<> +FileSystem::GetModificationTime(const Twine &path, + bool nanosecond_precision) const { ErrorOr status = m_fs->status(path); if (!status) return sys::TimePoint<>(); - return status->getLastModificationTime(); + if (nanosecond_precision) + return status->getLastModificationTime(); + else + return std::chrono::time_point_cast( + status->getLastModificationTime()); } uint64_t FileSystem::GetByteSize(const FileSpec &file_spec) const { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 50e27b2f9e47..fa07fd1ebde7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -420,7 +420,8 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo( FileSpec oso_file(oso_path); ConstString oso_object; if (FileSystem::Instance().Exists(oso_file)) { - auto oso_mod_time = FileSystem::Instance().GetModificationTime(oso_file); + auto oso_mod_time = FileSystem::Instance().GetModificationTime( + oso_file, /*nanosecond_precision=*/false); if (oso_mod_time != comp_unit_info->oso_mod_time) { obj_file->GetModule()->ReportError( "debug map object file '%s' has changed (actual time is "