[Lldb-commits] [lldb] r286349 - Remove TimeValue usage from Core/Module
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 9 01:59:18 PST 2016
Author: labath
Date: Wed Nov 9 03:59:18 2016
New Revision: 286349
URL: http://llvm.org/viewvc/llvm-project?rev=286349&view=rev
Log:
Remove TimeValue usage from Core/Module
Summary:
The only interesting part here is that TimePoint and TimeValue have different
natural string representations, which affects "target modules list" output. It
is now "2016-07-09 04:02:21.000000000", whereas previously in was
"Sat Jul 9 04:02:21 2016". I wanted to check if we're OK with that.
Reviewers: clayborg
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D26275
Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Host/TimeValue.h
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Host/common/TimeValue.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=286349&r1=286348&r2=286349&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Wed Nov 9 03:59:18 2016
@@ -10,26 +10,27 @@
#ifndef liblldb_Module_h_
#define liblldb_Module_h_
-// C Includes
-// C++ Includes
-#include <atomic>
-#include <mutex>
-#include <string>
-#include <vector>
+#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 <atomic>
+#include <mutex>
+#include <string>
+#include <vector>
namespace lldb_private {
@@ -92,10 +93,11 @@ public:
/// 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 @@ public:
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 @@ protected:
//------------------------------------------------------------------
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 @@ protected:
///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
Modified: lldb/trunk/include/lldb/Host/TimeValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=286349&r1=286348&r2=286349&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/TimeValue.h (original)
+++ lldb/trunk/include/lldb/Host/TimeValue.h Wed Nov 9 03:59:18 2016
@@ -14,12 +14,14 @@
#include "lldb/lldb-private.h"
-#include <chrono>
+#include "llvm/Support/Chrono.h"
#include <stdint.h>
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 @@ public:
TimeValue(const TimeValue &rhs);
TimeValue(const struct timespec &ts);
explicit TimeValue(uint32_t seconds, uint64_t nanos = 0);
- TimeValue(std::chrono::time_point<std::chrono::system_clock,
- std::chrono::nanoseconds>
- point)
+ TimeValue(const llvm::sys::TimePoint<> point)
: m_nano_seconds(point.time_since_epoch().count()) {}
~TimeValue();
@@ -44,6 +44,9 @@ public:
// 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 @@ public:
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.
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=286349&r1=286348&r2=286349&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Nov 9 03:59:18 2016
@@ -9,11 +9,6 @@
#include "CommandObjectTarget.h"
-// C Includes
-// C++ Includes
-#include <cerrno>
-
-// 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 <cerrno>
+
using namespace lldb;
using namespace lldb_private;
@@ -3108,7 +3107,7 @@ protected:
} break;
case 'm':
- module->GetModificationTime().Dump(&strm, width);
+ DumpTimePoint(module->GetModificationTime(), strm, width);
break;
case 'p':
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=286349&r1=286348&r2=286349&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Wed Nov 9 03:59:18 2016
@@ -229,10 +229,11 @@ Module::Module(const ModuleSpec &module_
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<std::recursive_mutex> guard(
@@ -243,9 +244,6 @@ Module::Module(const FileSpec &file_spec
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)
Modified: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=286349&r1=286348&r2=286349&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Wed Nov 9 03:59:18 2016
@@ -100,27 +100,6 @@ const TimeValue &TimeValue::operator=(co
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 @@ uint64_t lldb_private::operator-(const T
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
+}
+
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=286349&r1=286348&r2=286349&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Nov 9 03:59:18 2016
@@ -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 @@ public:
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 @@ void SymbolFileDWARFDebugMap::InitOSO()
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 @@ Module *SymbolFileDWARFDebugMap::GetModu
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 @@ Module *SymbolFileDWARFDebugMap::GetModu
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)
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=286349&r1=286348&r2=286349&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Wed Nov 9 03:59:18 2016
@@ -14,8 +14,8 @@
#include <vector>
#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 @@ protected:
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;
More information about the lldb-commits
mailing list