[Lldb-commits] [PATCH] D137645: [trace] Add `SBTraceCursor::GetWallClockTime` API

Jakob Johnson via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 8 14:39:35 PST 2022


jj10306 updated this revision to Diff 474092.
jj10306 added a comment.

update the way items with no timestamps are handled


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137645/new/

https://reviews.llvm.org/D137645

Files:
  lldb/bindings/interface/SBTraceCursor.i
  lldb/include/lldb/API/SBTraceCursor.h
  lldb/source/API/SBTraceCursor.cpp


Index: lldb/source/API/SBTraceCursor.cpp
===================================================================
--- lldb/source/API/SBTraceCursor.cpp
+++ lldb/source/API/SBTraceCursor.cpp
@@ -124,6 +124,16 @@
   return m_opaque_sp->GetCPU();
 }
 
+bool SBTraceCursor::GetWallClockTime(double &estimated_time) const {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (const auto &maybe_wall_clock_time = m_opaque_sp->GetWallClockTime()) {
+    estimated_time = *maybe_wall_clock_time;
+    return true;
+  }
+  return false;
+}
+
 bool SBTraceCursor::IsValid() const {
   LLDB_INSTRUMENT_VA(this);
 
Index: lldb/include/lldb/API/SBTraceCursor.h
===================================================================
--- lldb/include/lldb/API/SBTraceCursor.h
+++ lldb/include/lldb/API/SBTraceCursor.h
@@ -169,6 +169,19 @@
   ///    not available for the current item.
   lldb::cpu_id_t GetCPU() const;
 
+  /// Get the approximate wall clock time in nanoseconds at which the current
+  /// trace item was executed. Each trace plug-in has a different definition for
+  /// what time 0 means.
+  ///
+  /// \param[out] estimated_time
+  ///     The trace item's estimtated timestamp, if available.
+  ///
+  /// \return
+  ///   true if the current trace item has an estimated timestamp associated
+  ///   with it, false otherwise.
+  bool GetWallClockTime(double &estimated_time) const;
+  /// \}
+
   bool IsValid() const;
 
   explicit operator bool() const;
Index: lldb/bindings/interface/SBTraceCursor.i
===================================================================
--- lldb/bindings/interface/SBTraceCursor.i
+++ lldb/bindings/interface/SBTraceCursor.i
@@ -51,6 +51,8 @@
 
   lldb::cpu_id_t GetCPU() const;
 
+  bool GetWallClockTime(double &estimated_time) const;
+
   bool IsValid() const;
 
   explicit operator bool() const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137645.474092.patch
Type: text/x-patch
Size: 1820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221108/a18125aa/attachment.bin>


More information about the lldb-commits mailing list