Skip to content

Commit

Permalink
Merge pull request #9697 from swiftlang/cherrypick-swift/release/6.1-…
Browse files Browse the repository at this point in the history
…90f077cba8f4

[🍒 swift/release/6.1] [lldb] Emit signpost intervals for progress events (NFC) (llvm#108498)
  • Loading branch information
JDevlieghere authored Dec 6, 2024
2 parents 61f615a + 5a4720a commit 119bd56
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lldb/source/Core/Progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "lldb/Core/Debugger.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/Support/Signposts.h"

#include <cstdint>
#include <mutex>
Expand All @@ -20,6 +21,9 @@ using namespace lldb_private;

std::atomic<uint64_t> Progress::g_id(0);

// Instrument progress events with signposts when supported.
static llvm::ManagedStatic<llvm::SignpostEmitter> g_progress_signposts;

Progress::Progress(std::string title, std::string details,
std::optional<uint64_t> total,
lldb_private::Debugger *debugger)
Expand All @@ -39,9 +43,15 @@ Progress::Progress(std::string title, std::string details,
// Report to the ProgressManager if that subsystem is enabled.
if (ProgressManager::Enabled())
ProgressManager::Instance().Increment(m_progress_data);

// Start signpost interval right before the meaningful work starts.
g_progress_signposts->startInterval(this, m_progress_data.title);
}

Progress::~Progress() {
// End signpost interval as soon as possible.
g_progress_signposts->endInterval(this, m_progress_data.title);

// Make sure to always report progress completed when this object is
// destructed so it indicates the progress dialog/activity should go away.
std::lock_guard<std::mutex> guard(m_mutex);
Expand Down

0 comments on commit 119bd56

Please sign in to comment.