[Lldb-commits] [lldb] r347615 - [FileSystem] Ignore nanoseconds when comparing oso_mod_time

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 27 06:25:09 PST 2018


Was it necessary to modify FileSystem to achieve this. It looks like you 
could have just as easily made the time_point_cast in 
SymbolFileDWARFDebugMap (next to a comment explaining why that was needed).

The extra nanosecond_precision argument looks fairly odd, and diverges 
from how the llvm interfaces for modification times operate.

On 27/11/2018 00:40, Jonas Devlieghere via lldb-commits wrote:
> Author: jdevlieghere
> Date: Mon Nov 26 15:40:52 2018
> New Revision: 347615
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=347615&view=rev
> Log:
> [FileSystem] Ignore nanoseconds when comparing oso_mod_time
> 
> After a recent change in LLVM the TimePoint encoding become more
> precise, exceeding the precision of the TimePoint obtained from the
> DebugMap. This patch adds a flag to the GetModificationTime helper in
> the FileSystem to return the modification time with less precision.
> 
> Thanks to Davide for bisecting this failure on the LLDB bots.
> 
> Modified:
>      lldb/trunk/include/lldb/Host/FileSystem.h
>      lldb/trunk/source/Host/common/FileSystem.cpp
>      lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
> 
> Modified: lldb/trunk/include/lldb/Host/FileSystem.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=347615&r1=347614&r2=347615&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/FileSystem.h (original)
> +++ lldb/trunk/include/lldb/Host/FileSystem.h Mon Nov 26 15:40:52 2018
> @@ -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.
> 
> Modified: lldb/trunk/source/Host/common/FileSystem.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSystem.cpp?rev=347615&r1=347614&r2=347615&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/common/FileSystem.cpp (original)
> +++ lldb/trunk/source/Host/common/FileSystem.cpp Mon Nov 26 15:40:52 2018
> @@ -64,15 +64,22 @@ Optional<FileSystem> &FileSystem::Instan
>   }
>   
>   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<vfs::Status> 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<std::chrono::seconds>(
> +        status->getLastModificationTime());
>   }
>   
>   uint64_t FileSystem::GetByteSize(const FileSpec &file_spec) const {
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=347615&r1=347614&r2=347615&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Mon Nov 26 15:40:52 2018
> @@ -420,7 +420,8 @@ Module *SymbolFileDWARFDebugMap::GetModu
>         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 "
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> 



More information about the lldb-commits mailing list