[Lldb-commits] [PATCH] D128768: [lldb/Core] Fix finite progress event reporting

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 28 15:31:38 PDT 2022


mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch should fix event handling for finite progress reports.

Previously, the event handler would get stuck when receiving a finite
progress report, and stop displaying upcoming reports.
This was due to the fact that we were checking if the progress event was
completed by calling `GetCompleted` but returns the completion amount
instead of saying whether it's completed.

That caused the current event id to remain the same, preventing all the
following progress reports to be shown to the user.

This patch also adds some logging to facilitate debugging progress events.

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128768

Files:
  lldb/source/Core/Debugger.cpp


Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1827,6 +1827,12 @@
 }
 
 void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
+  Log *log = GetLog(LLDBLog::Events);
+
+  LLDB_LOGF(log, "%p Debugger('%llu')::HandleProgressEvent (event_sp = {%p})",
+            static_cast<void *>(this), m_uid,
+            static_cast<void *>(event_sp.get()));
+
   auto *data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
   if (!data)
     return;
@@ -1835,10 +1841,22 @@
   // going to show the progress.
   const uint64_t id = data->GetID();
   if (m_current_event_id) {
+    if (data->IsFinite())
+      LLDB_LOGF(log,
+                "%p Debugger('%llu')::HandleProgressEvent (m_current_event_id "
+                "= {%llu}, data = {id = %llu, message = %s, completed = %llu, "
+                "total = %llu})",
+                static_cast<void *>(this), m_uid, *m_current_event_id, id,
+                data->GetMessage().data(), data->GetCompleted(),
+                data->GetTotal());
+    else
+      LLDB_LOGF(log,
+                "%p Debugger('%llu')::HandleProgressEvent (m_current_event_id "
+                "= {%llu}, data = {id = %llu, message = %s, infinite = true})",
+                static_cast<void *>(this), m_uid, *m_current_event_id, id,
+                data->GetMessage().data());
     if (id != *m_current_event_id)
       return;
-    if (data->GetCompleted())
-      m_current_event_id.reset();
   } else {
     m_current_event_id = id;
   }
@@ -1860,8 +1878,9 @@
   // Print over previous line, if any.
   output->Printf("\r");
 
-  if (data->GetCompleted()) {
+  if (data->GetCompleted() == data->GetTotal()) {
     // Clear the current line.
+    m_current_event_id.reset();
     output->Printf("\x1B[2K");
     output->Flush();
     return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128768.440792.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220628/ad521f86/attachment-0001.bin>


More information about the lldb-commits mailing list