https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/140162

>From 0673dc530a91cb2dd1bdd60dd5136d64e4ed48e8 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalo...@fb.com>
Date: Thu, 15 May 2025 16:37:06 -0700
Subject: [PATCH 1/2] Have interderminate events actually broadcast to dap

---
 .../API/tools/lldb-dap/progress/TestDAP_Progress.py   |  2 +-
 lldb/tools/lldb-dap/ProgressEvent.cpp                 | 11 +++++++----
 lldb/tools/lldb-dap/ProgressEvent.h                   |  2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index fee63655de0da..c87d2afe36821 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -81,7 +81,7 @@ def test(self):
 
         self.verify_progress_events(
             expected_title="Progress tester: Initial Indeterminate Detail",
-            expected_message="Step 1",
+            expected_message="Step 2",
             only_verify_first_update=True,
         )
 
diff --git a/lldb/tools/lldb-dap/ProgressEvent.cpp 
b/lldb/tools/lldb-dap/ProgressEvent.cpp
index 6a4978c055e51..b6b62efb5f33c 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.cpp
+++ b/lldb/tools/lldb-dap/ProgressEvent.cpp
@@ -77,16 +77,19 @@ ProgressEvent::Create(uint64_t progress_id, 
std::optional<StringRef> message,
   if (event.GetEventType() == progressStart && event.GetEventName().empty())
     return std::nullopt;
 
-  if (prev_event && prev_event->EqualsForIDE(event))
+  if (prev_event && prev_event->EqualsForIDE(event, total))
     return std::nullopt;
 
   return event;
 }
 
-bool ProgressEvent::EqualsForIDE(const ProgressEvent &other) const {
+bool ProgressEvent::EqualsForIDE(const ProgressEvent &other, uint64_t total) 
const {
   return m_progress_id == other.m_progress_id &&
-         m_event_type == other.m_event_type &&
-         m_percentage == other.m_percentage;
+         m_event_type == other.m_event_type && 
+         // If we check the percentage of a non-deterministic event
+         // we will basically never send the event, because N+1/Uint64_max
+         // will always be an infinitesimally small change.
+         (total != UINT64_MAX && m_percentage == other.m_percentage);
 }
 
 ProgressEventType ProgressEvent::GetEventType() const { return m_event_type; }
diff --git a/lldb/tools/lldb-dap/ProgressEvent.h 
b/lldb/tools/lldb-dap/ProgressEvent.h
index d1b9b9dd887cd..ab3487c1dbc3d 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.h
+++ b/lldb/tools/lldb-dap/ProgressEvent.h
@@ -54,7 +54,7 @@ class ProgressEvent {
   /// \return
   ///       \b true if two event messages would result in the same event for 
the
   ///       IDE, e.g. same rounded percentage.
-  bool EqualsForIDE(const ProgressEvent &other) const;
+  bool EqualsForIDE(const ProgressEvent &other, uint64_t total) const;
 
   llvm::StringRef GetEventName() const;
 

>From dabda3b2f3288c35d08cf2d4e4788927481222ff Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalo...@fb.com>
Date: Thu, 15 May 2025 16:44:56 -0700
Subject: [PATCH 2/2] Format, add regex to test, and check if progress is
 nullopt instead of comparing total.

---
 lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py | 7 +++++--
 lldb/tools/lldb-dap/ProgressEvent.cpp                     | 8 ++++----
 lldb/tools/lldb-dap/ProgressEvent.h                       | 2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index c87d2afe36821..9fdcbd6162d46 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -7,6 +7,7 @@
 import json
 import os
 import time
+import re
 
 import lldbdap_testcase
 
@@ -16,6 +17,7 @@ def verify_progress_events(
         self,
         expected_title,
         expected_message=None,
+        expected_message_regex=None,
         expected_not_in_message=None,
         only_verify_first_update=False,
     ):
@@ -36,6 +38,8 @@ def verify_progress_events(
                     continue
                 if expected_message is not None:
                     self.assertIn(expected_message, message)
+                if expected_message_regex is not None:
+                    self.assertTrue(re.match(expected_message_regex, message))
                 if expected_not_in_message is not None:
                     self.assertNotIn(expected_not_in_message, message)
                 update_found = True
@@ -81,8 +85,7 @@ def test(self):
 
         self.verify_progress_events(
             expected_title="Progress tester: Initial Indeterminate Detail",
-            expected_message="Step 2",
-            only_verify_first_update=True,
+            expected_message_regex=r"Step [0-9]+",
         )
 
         # Test no details indeterminate.
diff --git a/lldb/tools/lldb-dap/ProgressEvent.cpp 
b/lldb/tools/lldb-dap/ProgressEvent.cpp
index b6b62efb5f33c..8236e827d6775 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.cpp
+++ b/lldb/tools/lldb-dap/ProgressEvent.cpp
@@ -77,19 +77,19 @@ ProgressEvent::Create(uint64_t progress_id, 
std::optional<StringRef> message,
   if (event.GetEventType() == progressStart && event.GetEventName().empty())
     return std::nullopt;
 
-  if (prev_event && prev_event->EqualsForIDE(event, total))
+  if (prev_event && prev_event->EqualsForIDE(event))
     return std::nullopt;
 
   return event;
 }
 
-bool ProgressEvent::EqualsForIDE(const ProgressEvent &other, uint64_t total) 
const {
+bool ProgressEvent::EqualsForIDE(const ProgressEvent &other) const {
   return m_progress_id == other.m_progress_id &&
-         m_event_type == other.m_event_type && 
+         m_event_type == other.m_event_type &&
          // If we check the percentage of a non-deterministic event
          // we will basically never send the event, because N+1/Uint64_max
          // will always be an infinitesimally small change.
-         (total != UINT64_MAX && m_percentage == other.m_percentage);
+         (m_percentage != std::nullopt && m_percentage == other.m_percentage);
 }
 
 ProgressEventType ProgressEvent::GetEventType() const { return m_event_type; }
diff --git a/lldb/tools/lldb-dap/ProgressEvent.h 
b/lldb/tools/lldb-dap/ProgressEvent.h
index ab3487c1dbc3d..d1b9b9dd887cd 100644
--- a/lldb/tools/lldb-dap/ProgressEvent.h
+++ b/lldb/tools/lldb-dap/ProgressEvent.h
@@ -54,7 +54,7 @@ class ProgressEvent {
   /// \return
   ///       \b true if two event messages would result in the same event for 
the
   ///       IDE, e.g. same rounded percentage.
-  bool EqualsForIDE(const ProgressEvent &other, uint64_t total) const;
+  bool EqualsForIDE(const ProgressEvent &other) const;
 
   llvm::StringRef GetEventName() const;
 

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to