Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLDB-DAP] Send Progress update message over DAP #123837

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Jlalond
Copy link
Contributor

@Jlalond Jlalond commented Jan 21, 2025

When testing my SBProgress DAP PR (#123826), I noticed Progress update messages aren't sent over DAP. This patch adds the lldb progress event's message to the body when sent over DAP.

Before
image

Now
image

Tested with my progress tester command, testing 10 events 5 seconds apart 1-10

@llvmbot
Copy link
Member

llvmbot commented Jan 21, 2025

@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)

Changes

When testing my SBProgress DAP PR (#123826), I noticed Progress update messages aren't sent over DAP. This patch adds the lldb progress event's message to the body when sent over DAP.

Before
image

Now
image

Tested with my progress tester command, testing 10 events 5 seconds apart 1-10


Full diff: /~https://github.com/llvm/llvm-project/pull/123837.diff

2 Files Affected:

  • (modified) lldb/tools/lldb-dap/ProgressEvent.cpp (+10-5)
  • (modified) lldb/tools/lldb-dap/ProgressEvent.h (+2-1)
diff --git a/lldb/tools/lldb-dap/ProgressEvent.cpp b/lldb/tools/lldb-dap/ProgressEvent.cpp
index 0dcc2ee81001d5..7807ecfb6c34d0 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.cpp
+++ b/lldb/tools/lldb-dap/ProgressEvent.cpp
@@ -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);
 
@@ -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;
 
@@ -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);
   }
diff --git a/lldb/tools/lldb-dap/ProgressEvent.h b/lldb/tools/lldb-dap/ProgressEvent.h
index 72317b879c803a..8494221890a1c8 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.h
+++ b/lldb/tools/lldb-dap/ProgressEvent.h
@@ -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

@Jlalond
Copy link
Contributor Author

Jlalond commented Jan 21, 2025

CC: @youngdfb

lldb/tools/lldb-dap/ProgressEvent.cpp Outdated Show resolved Hide resolved
lldb/tools/lldb-dap/ProgressEvent.cpp Outdated Show resolved Hide resolved
lldb/tools/lldb-dap/ProgressEvent.cpp Outdated Show resolved Hide resolved
lldb/tools/lldb-dap/ProgressEvent.h Outdated Show resolved Hide resolved
Copy link
Contributor

@jeffreytan81 jeffreytan81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a DAP test to ensure progress event does contain the message you update in SBProgress?

@Jlalond
Copy link
Contributor Author

Jlalond commented Jan 21, 2025

@jeffreytan81 Sure, can you point me towards some existing test cases?

@Jlalond Jlalond force-pushed the dap-progress-event-update-message branch from 49551ed to a4446e0 Compare January 21, 2025 23:20
@Jlalond Jlalond force-pushed the dap-progress-event-update-message branch from a4446e0 to 56846b2 Compare January 22, 2025 19:58
Copy link

github-actions bot commented Jan 22, 2025

✅ With the latest revision this PR passed the Python code formatter.


self.dap_server.wait_for_event("progressEnd", 15)
# Expect at least a start, an update, and end event
# However because the progress is an RAII object and we can't guaruntee
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "progress is not a RAII object"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, but I believe because we'll free that memory when the python object is destroyed we can't depend on the deterministic behavior of the RAII object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants