[Lldb-commits] [lldb] r287096 - Remove TimeValue class
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 16 02:54:22 PST 2016
Author: labath
Date: Wed Nov 16 04:54:22 2016
New Revision: 287096
URL: http://llvm.org/viewvc/llvm-project?rev=287096&view=rev
Log:
Remove TimeValue class
Summary:
All usages have been replaced by appropriate std::chrono funcionality, and the
class is now unused. The only used part of the cpp file is the DumpTimePoint
function, which I have moved into the only caller (CommandObjectTarget.cpp).
Reviewers: clayborg, zturner
Subscribers: mgorny, lldb-commits
Differential Revision: https://reviews.llvm.org/D26451
Removed:
lldb/trunk/include/lldb/Host/TimeValue.h
lldb/trunk/source/Host/common/TimeValue.cpp
Modified:
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Host/CMakeLists.txt
Removed: lldb/trunk/include/lldb/Host/TimeValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=287095&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/TimeValue.h (original)
+++ lldb/trunk/include/lldb/Host/TimeValue.h (removed)
@@ -1,112 +0,0 @@
-//===-- TimeValue.h ---------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_TimeValue_h_
-#define liblldb_TimeValue_h_
-
-#include "lldb/Host/PosixApi.h"
-
-#include "lldb/lldb-private.h"
-
-#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;
- static const uint64_t NanoSecPerSec = 1000000000UL;
- static const uint64_t NanoSecPerMicroSec = 1000U;
- static const uint64_t NanoSecPerMilliSec = 1000000UL;
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- TimeValue();
- TimeValue(const TimeValue &rhs);
- TimeValue(const struct timespec &ts);
- explicit TimeValue(uint32_t seconds, uint64_t nanos = 0);
- TimeValue(const llvm::sys::TimePoint<> point)
- : m_nano_seconds(point.time_since_epoch().count()) {}
- ~TimeValue();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const TimeValue &operator=(const TimeValue &rhs);
- operator llvm::sys::TimePoint<>() {
- return llvm::sys::TimePoint<>(std::chrono::nanoseconds(m_nano_seconds));
- }
-
- void Clear();
-
- uint64_t GetAsNanoSecondsSinceJan1_1970() const;
-
- uint64_t GetAsMicroSecondsSinceJan1_1970() const;
-
- uint64_t GetAsSecondsSinceJan1_1970() const;
-
- struct timespec GetAsTimeSpec() const;
-
- bool IsValid() const;
-
- void OffsetWithSeconds(uint64_t sec);
-
- void OffsetWithMicroSeconds(uint64_t usec);
-
- void OffsetWithNanoSeconds(uint64_t nsec);
-
- static TimeValue Now();
-
-
- /// Returns only the seconds component of the TimeValue. The nanoseconds
- /// portion is ignored. No rounding is performed.
- /// @brief Retrieve the seconds component
- uint32_t seconds() const { return m_nano_seconds / NanoSecPerSec; }
-
- /// Returns only the nanoseconds component of the TimeValue. The seconds
- /// portion is ignored.
- /// @brief Retrieve the nanoseconds component.
- uint32_t nanoseconds() const { return m_nano_seconds % NanoSecPerSec; }
-
- /// Returns only the fractional portion of the TimeValue rounded down to the
- /// nearest microsecond (divide by one thousand).
- /// @brief Retrieve the fractional part as microseconds;
- uint32_t microseconds() const {
- return (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec;
- }
-
- /// Returns only the fractional portion of the TimeValue rounded down to the
- /// nearest millisecond (divide by one million).
- /// @brief Retrieve the milliseconds component;
- uint32_t milliseconds() const { return m_nano_seconds / NanoSecPerMilliSec; }
-
-protected:
- //------------------------------------------------------------------
- // Classes that inherit from TimeValue can see and modify these
- //------------------------------------------------------------------
- uint64_t m_nano_seconds;
-};
-
-bool operator==(const TimeValue &lhs, const TimeValue &rhs);
-bool operator!=(const TimeValue &lhs, const TimeValue &rhs);
-bool operator<(const TimeValue &lhs, const TimeValue &rhs);
-bool operator<=(const TimeValue &lhs, const TimeValue &rhs);
-bool operator>(const TimeValue &lhs, const TimeValue &rhs);
-bool operator>=(const TimeValue &lhs, const TimeValue &rhs);
-
-uint64_t operator-(const TimeValue &lhs, const TimeValue &rhs);
-
-} // namespace lldb_private
-
-#endif // liblldb_TimeValue_h_
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=287096&r1=287095&r2=287096&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Wed Nov 16 04:54:22 2016
@@ -255,7 +255,6 @@ class ThreadPlanStepRange;
class ThreadPlanStepThrough;
class ThreadPlanTracer;
class ThreadSpec;
-class TimeValue;
class Type;
class TypeAndOrName;
class TypeCategoryMap;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=287096&r1=287095&r2=287096&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 16 04:54:22 2016
@@ -454,7 +454,6 @@
2689007113353E1A00698AC0 /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1C1236C5D400C660B5 /* Host.cpp */; };
2689007313353E1A00698AC0 /* Symbols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1F1236C5D400C660B5 /* Symbols.cpp */; };
2689007413353E1A00698AC0 /* Terminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268DA873130095ED00C9483A /* Terminal.cpp */; };
- 2689007513353E1A00698AC0 /* TimeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E201236C5D400C660B5 /* TimeValue.cpp */; };
2689007613353E1A00698AC0 /* CFCBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */; };
2689007713353E1A00698AC0 /* CFCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */; };
2689007813353E1A00698AC0 /* CFCMutableArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF110F1B8AD00F91463 /* CFCMutableArray.cpp */; };
@@ -1956,7 +1955,6 @@
26B1EFAC154638AF00E2DAC7 /* DWARFDeclContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFDeclContext.cpp; sourceTree = "<group>"; };
26B1EFAD154638AF00E2DAC7 /* DWARFDeclContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFDeclContext.h; sourceTree = "<group>"; };
26B42C4C1187ABA50079C8C8 /* LLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDB.h; path = include/lldb/API/LLDB.h; sourceTree = "<group>"; };
- 26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = "<group>"; };
26B7564C14F89356008D9CB3 /* PlatformiOSSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformiOSSimulator.cpp; sourceTree = "<group>"; };
26B7564D14F89356008D9CB3 /* PlatformiOSSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformiOSSimulator.h; sourceTree = "<group>"; };
26B75B421AD6E29A001F7A57 /* MipsLinuxSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MipsLinuxSignals.cpp; path = Utility/MipsLinuxSignals.cpp; sourceTree = "<group>"; };
@@ -2586,7 +2584,6 @@
4CF52AF7142829390051E832 /* SBFileSpecList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFileSpecList.cpp; path = source/API/SBFileSpecList.cpp; sourceTree = "<group>"; };
69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = "<group>"; };
69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = "<group>"; };
- 69A01E201236C5D400C660B5 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeValue.cpp; sourceTree = "<group>"; };
6D0F613C1C80AA8900A4ECEE /* DebugMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DebugMacros.h; path = include/lldb/Symbol/DebugMacros.h; sourceTree = "<group>"; };
6D0F613D1C80AA8900A4ECEE /* JavaASTContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaASTContext.h; path = include/lldb/Symbol/JavaASTContext.h; sourceTree = "<group>"; };
6D0F61411C80AAAA00A4ECEE /* JavaASTContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaASTContext.cpp; path = source/Symbol/JavaASTContext.cpp; sourceTree = "<group>"; };
@@ -5108,7 +5105,6 @@
3FDFED0D19B7D269009756A7 /* ThisThread.cpp */,
3FDFED0919B7C8C7009756A7 /* ThisThread.h */,
3FDFED2319BA6D55009756A7 /* ThreadLauncher.h */,
- 26B4E26E112F35F700AB3F64 /* TimeValue.h */,
267A48031B1416080021A5BC /* XML.h */,
267A48001B1411E40021A5BC /* XML.cpp */,
);
@@ -5906,7 +5902,6 @@
69A01E1F1236C5D400C660B5 /* Symbols.cpp */,
268DA873130095ED00C9483A /* Terminal.cpp */,
3FDFED2619BA6D96009756A7 /* ThreadLauncher.cpp */,
- 69A01E201236C5D400C660B5 /* TimeValue.cpp */,
);
name = common;
path = source/Host/common;
@@ -7254,7 +7249,6 @@
26474CBC18D0CB2D0073DEBA /* RegisterContextMach_arm.cpp in Sources */,
257E47171AA56C2000A62F81 /* ModuleCache.cpp in Sources */,
2689007413353E1A00698AC0 /* Terminal.cpp in Sources */,
- 2689007513353E1A00698AC0 /* TimeValue.cpp in Sources */,
6D0F61431C80AAAE00A4ECEE /* JavaASTContext.cpp in Sources */,
2689007613353E1A00698AC0 /* CFCBundle.cpp in Sources */,
94BA8B70176F97CE005A91B5 /* CommandHistory.cpp in Sources */,
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=287096&r1=287095&r2=287096&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Nov 16 04:54:22 2016
@@ -21,7 +21,6 @@
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
-#include "lldb/Host/TimeValue.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -133,6 +132,25 @@ static uint32_t DumpTargetList(TargetLis
return num_targets;
}
+// TODO: Remove this once llvm can pretty-print time points
+static void 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
+}
+
#pragma mark CommandObjectTargetCreate
//-------------------------------------------------------------------------
Modified: lldb/trunk/source/Host/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=287096&r1=287095&r2=287096&view=diff
==============================================================================
--- lldb/trunk/source/Host/CMakeLists.txt (original)
+++ lldb/trunk/source/Host/CMakeLists.txt Wed Nov 16 04:54:22 2016
@@ -36,7 +36,6 @@ add_host_subdirectory(common
common/Terminal.cpp
common/ThisThread.cpp
common/ThreadLauncher.cpp
- common/TimeValue.cpp
common/XML.cpp
common/UDPSocket.cpp
)
Removed: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=287095&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp (removed)
@@ -1,155 +0,0 @@
-//===-- TimeValue.cpp -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/TimeValue.h"
-#include "lldb/Host/Config.h"
-
-// C Includes
-#include <cstring>
-#include <stddef.h>
-#include <time.h>
-
-#ifdef _MSC_VER
-#include "lldb/Host/windows/windows.h"
-#endif
-
-// C++ Includes
-#include <chrono>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Stream.h"
-
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// TimeValue constructor
-//----------------------------------------------------------------------
-TimeValue::TimeValue() : m_nano_seconds(0) {}
-
-//----------------------------------------------------------------------
-// TimeValue copy constructor
-//----------------------------------------------------------------------
-TimeValue::TimeValue(const TimeValue &rhs)
- : m_nano_seconds(rhs.m_nano_seconds) {}
-
-TimeValue::TimeValue(const struct timespec &ts)
- : m_nano_seconds((uint64_t)ts.tv_sec * NanoSecPerSec + ts.tv_nsec) {}
-
-TimeValue::TimeValue(uint32_t seconds, uint64_t nanos)
- : m_nano_seconds((uint64_t)seconds * NanoSecPerSec + nanos) {}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-TimeValue::~TimeValue() {}
-
-uint64_t TimeValue::GetAsNanoSecondsSinceJan1_1970() const {
- return m_nano_seconds;
-}
-
-uint64_t TimeValue::GetAsMicroSecondsSinceJan1_1970() const {
- return m_nano_seconds / NanoSecPerMicroSec;
-}
-
-uint64_t TimeValue::GetAsSecondsSinceJan1_1970() const {
- return m_nano_seconds / NanoSecPerSec;
-}
-
-struct timespec TimeValue::GetAsTimeSpec() const {
- struct timespec ts;
- ts.tv_sec = m_nano_seconds / NanoSecPerSec;
- ts.tv_nsec = m_nano_seconds % NanoSecPerSec;
- return ts;
-}
-
-void TimeValue::Clear() { m_nano_seconds = 0; }
-
-bool TimeValue::IsValid() const { return m_nano_seconds != 0; }
-
-void TimeValue::OffsetWithSeconds(uint64_t sec) {
- m_nano_seconds += sec * NanoSecPerSec;
-}
-
-void TimeValue::OffsetWithMicroSeconds(uint64_t usec) {
- m_nano_seconds += usec * NanoSecPerMicroSec;
-}
-
-void TimeValue::OffsetWithNanoSeconds(uint64_t nsec) { m_nano_seconds += nsec; }
-
-TimeValue TimeValue::Now() {
- using namespace std::chrono;
- auto now = system_clock::now();
- auto ns_since_epoch =
- duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
-
- return TimeValue(0, ns_since_epoch);
-}
-
-//----------------------------------------------------------------------
-// TimeValue assignment operator
-//----------------------------------------------------------------------
-const TimeValue &TimeValue::operator=(const TimeValue &rhs) {
- m_nano_seconds = rhs.m_nano_seconds;
- return *this;
-}
-
-bool lldb_private::operator==(const TimeValue &lhs, const TimeValue &rhs) {
- return lhs.GetAsNanoSecondsSinceJan1_1970() ==
- rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool lldb_private::operator!=(const TimeValue &lhs, const TimeValue &rhs) {
- return lhs.GetAsNanoSecondsSinceJan1_1970() !=
- rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool lldb_private::operator<(const TimeValue &lhs, const TimeValue &rhs) {
- return lhs.GetAsNanoSecondsSinceJan1_1970() <
- rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool lldb_private::operator<=(const TimeValue &lhs, const TimeValue &rhs) {
- return lhs.GetAsNanoSecondsSinceJan1_1970() <=
- rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool lldb_private::operator>(const TimeValue &lhs, const TimeValue &rhs) {
- return lhs.GetAsNanoSecondsSinceJan1_1970() >
- rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool lldb_private::operator>=(const TimeValue &lhs, const TimeValue &rhs) {
- return lhs.GetAsNanoSecondsSinceJan1_1970() >=
- rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-uint64_t lldb_private::operator-(const TimeValue &lhs, const TimeValue &rhs) {
- 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
-}
-
More information about the lldb-commits
mailing list