[Lldb-commits] [PATCH] D93657: [lldb] Ad os_signpost support to `lldb_private::Timer`
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 6 15:16:23 PST 2021
This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
Closed by commit rG6d94eeadd28a: [lldb] Ad os_signpost support to lldb_private::Timer (authored by JDevlieghere).
Herald added a project: LLDB.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93657/new/
https://reviews.llvm.org/D93657
Files:
lldb/include/lldb/Utility/Timer.h
lldb/source/Utility/Timer.cpp
Index: lldb/source/Utility/Timer.cpp
===================================================================
--- lldb/source/Utility/Timer.cpp
+++ lldb/source/Utility/Timer.cpp
@@ -7,6 +7,8 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/Timer.h"
#include "lldb/Utility/Stream.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Signposts.h"
#include <algorithm>
#include <map>
@@ -28,6 +30,9 @@
static std::atomic<Timer::Category *> g_categories;
} // end of anonymous namespace
+/// Allows llvm::Timer to emit signposts when supported.
+static llvm::ManagedStatic<llvm::SignpostEmitter> Signposts;
+
std::atomic<bool> Timer::g_quiet(true);
std::atomic<unsigned> Timer::g_display_depth(0);
static std::mutex &GetFileMutex() {
@@ -54,6 +59,7 @@
Timer::Timer(Timer::Category &category, const char *format, ...)
: m_category(category), m_total_start(std::chrono::steady_clock::now()) {
+ Signposts->startInterval(this, m_category.GetName());
TimerStack &stack = GetTimerStackForCurrentThread();
stack.push_back(this);
@@ -80,6 +86,8 @@
auto total_dur = stop_time - m_total_start;
auto timer_dur = total_dur - m_child_duration;
+ Signposts->endInterval(this, m_category.GetName());
+
TimerStack &stack = GetTimerStackForCurrentThread();
if (g_quiet && stack.size() <= g_display_depth) {
std::lock_guard<std::mutex> lock(GetFileMutex());
Index: lldb/include/lldb/Utility/Timer.h
===================================================================
--- lldb/include/lldb/Utility/Timer.h
+++ lldb/include/lldb/Utility/Timer.h
@@ -25,6 +25,7 @@
class Category {
public:
explicit Category(const char *category_name);
+ llvm::StringRef GetName() { return m_name; }
private:
friend class Timer;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93657.315008.patch
Type: text/x-patch
Size: 1830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210106/3fddadbf/attachment.bin>
More information about the lldb-commits
mailing list