Skip to content

Commit

Permalink
Have Progress message updates include their messages when sent over DAP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jlalond committed Jan 21, 2025
1 parent 1888a5f commit 49551ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions lldb/tools/lldb-dap/ProgressEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ json::Value ProgressEvent::ToJSON() const {
body.try_emplace("cancellable", false);
}

if (m_event_type == progressUpdate) {
EmplaceSafeString(body, "message", m_message);
}

std::string timestamp(llvm::formatv("{0:f9}", m_creation_time.count()));
EmplaceSafeString(body, "timestamp", timestamp);

Expand Down Expand Up @@ -164,10 +168,11 @@ const ProgressEvent &ProgressEventManager::GetMostRecentEvent() const {
return m_last_update_event ? *m_last_update_event : m_start_event;
}

void ProgressEventManager::Update(uint64_t progress_id, uint64_t completed,
uint64_t total) {
if (std::optional<ProgressEvent> event = ProgressEvent::Create(
progress_id, std::nullopt, completed, total, &GetMostRecentEvent())) {
void ProgressEventManager::Update(uint64_t progress_id, const char *message,
uint64_t completed, uint64_t total) {
if (std::optional<ProgressEvent> event =
ProgressEvent::Create(progress_id, StringRef(message), completed,
total, &GetMostRecentEvent())) {
if (event->GetEventType() == progressEnd)
m_finished = true;

Expand Down Expand Up @@ -227,7 +232,7 @@ void ProgressEventReporter::Push(uint64_t progress_id, const char *message,
m_unreported_start_events.push(event_manager);
}
} else {
it->second->Update(progress_id, completed, total);
it->second->Update(progress_id, message, completed, total);
if (it->second->Finished())
m_event_managers.erase(it);
}
Expand Down
3 changes: 2 additions & 1 deletion lldb/tools/lldb-dap/ProgressEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class ProgressEventManager {

/// Receive a new progress event for the start event and try to report it if
/// appropriate.
void Update(uint64_t progress_id, uint64_t completed, uint64_t total);
void Update(uint64_t progress_id, const char *message, uint64_t completed,
uint64_t total);

/// \return
/// \b true if a \a progressEnd event has been notified. There's no
Expand Down

0 comments on commit 49551ed

Please sign in to comment.