[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 19 17:13:49 PST 2025


================
@@ -428,14 +453,35 @@ void ProgressEventThreadFunction(DAP &dap) {
           done = true;
         }
       } else {
-        uint64_t progress_id = 0;
-        uint64_t completed = 0;
-        uint64_t total = 0;
-        bool is_debugger_specific = false;
-        const char *message = lldb::SBDebugger::GetProgressFromEvent(
-            event, progress_id, completed, total, is_debugger_specific);
-        if (message)
-          dap.SendProgressEvent(progress_id, message, completed, total);
+        lldb::SBStructuredData data =
+            lldb::SBDebugger::GetProgressDataFromEvent(event);
+
+        const uint64_t progress_id =
+            GetUintFromStructuredData(data, "progress_id");
+        const uint64_t completed = GetUintFromStructuredData(data, "completed");
+        const uint64_t total = GetUintFromStructuredData(data, "total");
+        const std::string details =
+            GetStringFromStructuredData(data, "details");
+
+        // If we're only creating and sending on progress event, we send
+        // the title and the detail as a single message.
+        if (completed == 0 && total == 1) {
+          const std::string message =
+              GetStringFromStructuredData(data, "message");
+          dap.SendProgressEvent(progress_id, message.c_str(), completed, total);
+        } else if (completed == 0) {
+          // On the first event, send just the title which will be captured by
+          // DAP Then if details is not empty, send a second event with the
+          // detail.
+          const std::string title = GetStringFromStructuredData(data, "title");
+          dap.SendProgressEvent(progress_id, title.c_str(), completed, total);
+          if (!details.empty())
+            dap.SendProgressEvent(progress_id, details.c_str(), completed,
+                                  total);
+        } else
+          // We don't check if message has any contents, because we still want
+          // to broadcast a status update.
----------------
clayborg wrote:

Lets document what VS code expects a bit more to make it clear. Something like:
```
// This progress event is either the end of the progress dialog, or an update
// with possible detail. The "detail" string we send to VS Code will be appended to
// the progress dialog's initial text from when it was created.
```

https://github.com/llvm/llvm-project/pull/124648


More information about the lldb-commits mailing list