-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) ChangesWhen 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. 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:
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
|
CC: @youngdfb |
There was a problem hiding this 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?
@jeffreytan81 Sure, can you point me towards some existing test cases? |
49551ed
to
a4446e0
Compare
a4446e0
to
56846b2
Compare
✅ 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 |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
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
Now
Tested with my progress tester command, testing 10 events 5 seconds apart 1-10