diff --git a/lldb/bindings/interface/SBTraceCursor.i b/lldb/bindings/interface/SBTraceCursor.i --- a/lldb/bindings/interface/SBTraceCursor.i +++ b/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; diff --git a/lldb/include/lldb/API/SBTraceCursor.h b/lldb/include/lldb/API/SBTraceCursor.h --- a/lldb/include/lldb/API/SBTraceCursor.h +++ b/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; diff --git a/lldb/source/API/SBTraceCursor.cpp b/lldb/source/API/SBTraceCursor.cpp --- a/lldb/source/API/SBTraceCursor.cpp +++ b/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);