Index: lldb/trunk/include/lldb/Core/Module.h =================================================================== --- lldb/trunk/include/lldb/Core/Module.h +++ lldb/trunk/include/lldb/Core/Module.h @@ -10,26 +10,27 @@ #ifndef liblldb_Module_h_ #define liblldb_Module_h_ -// C Includes -// C++ Includes -#include -#include -#include -#include +#include "lldb/Symbol/SymbolContextScope.h" -// Other libraries and framework includes // Project includes #include "lldb/Core/ArchSpec.h" #include "lldb/Core/UUID.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/TimeValue.h" -#include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" #include "lldb/lldb-forward.h" +// Other libraries and framework includes #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Chrono.h" + +// C Includes +// C++ Includes +#include +#include +#include +#include namespace lldb_private { @@ -92,10 +93,11 @@ /// module within a module (.a files and modules that contain /// multiple architectures). //------------------------------------------------------------------ - Module(const FileSpec &file_spec, const ArchSpec &arch, - const ConstString *object_name = nullptr, - lldb::offset_t object_offset = 0, - const TimeValue *object_mod_time_ptr = nullptr); + Module( + const FileSpec &file_spec, const ArchSpec &arch, + const ConstString *object_name = nullptr, + lldb::offset_t object_offset = 0, + const llvm::sys::TimePoint<> &object_mod_time = llvm::sys::TimePoint<>()); Module(const ModuleSpec &module_spec); @@ -557,13 +559,15 @@ void SetSymbolFileFileSpec(const FileSpec &file); - const TimeValue &GetModificationTime() const { return m_mod_time; } + const llvm::sys::TimePoint<> &GetModificationTime() const { + return m_mod_time; + } - const TimeValue &GetObjectModificationTime() const { + const llvm::sys::TimePoint<> &GetObjectModificationTime() const { return m_object_mod_time; } - void SetObjectModificationTime(const TimeValue &mod_time) { + void SetObjectModificationTime(const llvm::sys::TimePoint<> &mod_time) { m_mod_time = mod_time; } @@ -1025,8 +1029,10 @@ //------------------------------------------------------------------ mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy ///in multi-threaded environments. - TimeValue m_mod_time; ///< The modification time for this module when it was - ///created. + + /// The modification time for this module when it was created. + llvm::sys::TimePoint<> m_mod_time; + ArchSpec m_arch; ///< The architecture for this module. UUID m_uuid; ///< Each module is assumed to have a unique identifier to help ///match it up to debug symbols. @@ -1044,7 +1050,7 @@ ///selected, or empty of the module is represented ///by \a m_file. uint64_t m_object_offset; - TimeValue m_object_mod_time; + llvm::sys::TimePoint<> m_object_mod_time; lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file ///parser for this module as it may or may ///not be shared with the SymbolFile Index: lldb/trunk/include/lldb/Host/TimeValue.h =================================================================== --- lldb/trunk/include/lldb/Host/TimeValue.h +++ lldb/trunk/include/lldb/Host/TimeValue.h @@ -14,12 +14,14 @@ #include "lldb/lldb-private.h" -#include +#include "llvm/Support/Chrono.h" #include namespace lldb_private { +void DumpTimePoint(llvm::sys::TimePoint<>, Stream &s, uint32_t width = 0); + class TimeValue { public: static const uint64_t MicroSecPerSec = 1000000UL; @@ -34,9 +36,7 @@ TimeValue(const TimeValue &rhs); TimeValue(const struct timespec &ts); explicit TimeValue(uint32_t seconds, uint64_t nanos = 0); - TimeValue(std::chrono::time_point - point) + TimeValue(const llvm::sys::TimePoint<> point) : m_nano_seconds(point.time_since_epoch().count()) {} ~TimeValue(); @@ -44,6 +44,9 @@ // Operators //------------------------------------------------------------------ const TimeValue &operator=(const TimeValue &rhs); + operator llvm::sys::TimePoint<>() { + return llvm::sys::TimePoint<>(std::chrono::nanoseconds(m_nano_seconds)); + } void Clear(); @@ -65,7 +68,6 @@ static TimeValue Now(); - void Dump(Stream *s, uint32_t width = 0) const; /// Returns only the seconds component of the TimeValue. The nanoseconds /// portion is ignored. No rounding is performed. Index: lldb/trunk/source/Commands/CommandObjectTarget.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp @@ -9,11 +9,6 @@ #include "CommandObjectTarget.h" -// C Includes -// C++ Includes -#include - -// Other libraries and framework includes // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" @@ -55,6 +50,10 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" +// C Includes +// C++ Includes +#include + using namespace lldb; using namespace lldb_private; @@ -3108,7 +3107,7 @@ } break; case 'm': - module->GetModificationTime().Dump(&strm, width); + DumpTimePoint(module->GetModificationTime(), strm, width); break; case 'p': Index: lldb/trunk/source/Core/Module.cpp =================================================================== --- lldb/trunk/source/Core/Module.cpp +++ lldb/trunk/source/Core/Module.cpp @@ -229,10 +229,11 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name, lldb::offset_t object_offset, - const TimeValue *object_mod_time_ptr) + const llvm::sys::TimePoint<> &object_mod_time) : m_mod_time(FileSystem::GetModificationTime(file_spec)), m_arch(arch), m_file(file_spec), m_object_offset(object_offset), - m_file_has_changed(false), m_first_file_changed_log(false) { + m_object_mod_time(object_mod_time), m_file_has_changed(false), + m_first_file_changed_log(false) { // Scope for locker below... { std::lock_guard guard( @@ -243,9 +244,6 @@ if (object_name) m_object_name = *object_name; - if (object_mod_time_ptr) - m_object_mod_time = *object_mod_time_ptr; - Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES)); if (log != nullptr) Index: lldb/trunk/source/Host/common/TimeValue.cpp =================================================================== --- lldb/trunk/source/Host/common/TimeValue.cpp +++ lldb/trunk/source/Host/common/TimeValue.cpp @@ -100,27 +100,6 @@ return *this; } -void TimeValue::Dump(Stream *s, uint32_t width) const { - if (s == NULL) - return; - -#ifndef LLDB_DISABLE_POSIX - char time_buf[32]; - time_t time = GetAsSecondsSinceJan1_1970(); - char *time_cstr = ::ctime_r(&time, time_buf); - if (time_cstr) { - char *newline = ::strpbrk(time_cstr, "\n\r"); - if (newline) - *newline = '\0'; - if (width > 0) - s->Printf("%-*s", width, time_cstr); - else - s->PutCString(time_cstr); - } else if (width > 0) - s->Printf("%-*s", width, ""); -#endif -} - bool lldb_private::operator==(const TimeValue &lhs, const TimeValue &rhs) { return lhs.GetAsNanoSecondsSinceJan1_1970() == rhs.GetAsNanoSecondsSinceJan1_1970(); @@ -155,3 +134,22 @@ return lhs.GetAsNanoSecondsSinceJan1_1970() - rhs.GetAsNanoSecondsSinceJan1_1970(); } + +void lldb_private::DumpTimePoint(llvm::sys::TimePoint<> tp, Stream &s, uint32_t width) { +#ifndef LLDB_DISABLE_POSIX + char time_buf[32]; + time_t time = llvm::sys::toTimeT(tp); + char *time_cstr = ::ctime_r(&time, time_buf); + if (time_cstr) { + char *newline = ::strpbrk(time_cstr, "\n\r"); + if (newline) + *newline = '\0'; + if (width > 0) + s.Printf("%-*s", width, time_cstr); + else + s.PutCString(time_cstr); + } else if (width > 0) + s.Printf("%-*s", width, ""); +#endif +} + Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -14,8 +14,8 @@ #include #include "lldb/Core/RangeMap.h" -#include "lldb/Host/TimeValue.h" #include "lldb/Symbol/SymbolFile.h" +#include "llvm/Support/Chrono.h" #include "UniqueDWARFASTType.h" @@ -155,7 +155,7 @@ struct CompileUnitInfo { lldb_private::FileSpec so_file; lldb_private::ConstString oso_path; - lldb_private::TimeValue oso_mod_time; + llvm::sys::TimePoint<> oso_mod_time; OSOInfoSP oso_sp; lldb::CompUnitSP compile_unit_sp; uint32_t first_symbol_index; Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -35,6 +35,7 @@ #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/Symbol/VariableList.h" +#include "llvm/Support/ScopedPrinter.h" #include "LogChannelDWARF.h" #include "SymbolFileDWARF.h" @@ -175,9 +176,8 @@ DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx, const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name, off_t object_offset, - const TimeValue *object_mod_time_ptr) - : Module(file_spec, arch, object_name, object_offset, - object_mod_time_ptr), + const llvm::sys::TimePoint<> object_mod_time) + : Module(file_spec, arch, object_name, object_offset, object_mod_time), m_exe_module_wp(exe_module_sp), m_cu_idx(cu_idx) {} ~DebugMapModule() override = default; @@ -355,9 +355,8 @@ m_compile_unit_infos[i].so_file.SetFile( so_symbol->GetName().AsCString(), false); m_compile_unit_infos[i].oso_path = oso_symbol->GetName(); - TimeValue oso_mod_time; - oso_mod_time.OffsetWithSeconds(oso_symbol->GetIntegerValue(0)); - m_compile_unit_infos[i].oso_mod_time = oso_mod_time; + m_compile_unit_infos[i].oso_mod_time = + llvm::sys::toTimePoint(oso_symbol->GetIntegerValue(0)); uint32_t sibling_idx = so_symbol->GetSiblingIndex(); // The sibling index can't be less that or equal to the current index // "i" @@ -425,15 +424,14 @@ FileSpec oso_file(oso_path, false); ConstString oso_object; if (oso_file.Exists()) { - TimeValue oso_mod_time(FileSystem::GetModificationTime(oso_file)); + auto oso_mod_time = FileSystem::GetModificationTime(oso_file); if (oso_mod_time != comp_unit_info->oso_mod_time) { obj_file->GetModule()->ReportError( "debug map object file '%s' has changed (actual time is " - "0x%" PRIx64 ", debug map time is 0x%" PRIx64 + "%s, debug map time is %s" ") since this executable was linked, file will be ignored", - oso_file.GetPath().c_str(), - oso_mod_time.GetAsSecondsSinceJan1_1970(), - comp_unit_info->oso_mod_time.GetAsSecondsSinceJan1_1970()); + oso_file.GetPath().c_str(), llvm::to_string(oso_mod_time).c_str(), + llvm::to_string(comp_unit_info->oso_mod_time).c_str()); return NULL; } @@ -464,7 +462,8 @@ comp_unit_info->oso_sp->module_sp.reset(new DebugMapModule( obj_file->GetModule(), GetCompUnitInfoIndex(comp_unit_info), oso_file, oso_arch, oso_object ? &oso_object : NULL, 0, - oso_object ? &comp_unit_info->oso_mod_time : NULL)); + oso_object ? comp_unit_info->oso_mod_time + : llvm::sys::TimePoint<>())); } } if (comp_unit_info->oso_sp)