Skip to content

[lldb] Make sure that a Progress "completed" update is always reported at destruction #102097

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

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

royitaqi
Copy link
Contributor

@royitaqi royitaqi commented Aug 6, 2024

Make all Progress destructions to cause progressEnd events, regardless of the value of m_completed before the destruction.

Currently, a Progress instance with m_completed != 0 && m_complete != m_total will cause a progressUpdate event (not progressEnd) at destruction (see Process.cpp and lldb-dap/ProgressEvent.cpp). This contradicts with the classdoc:

a progress completed update is reported even if the user doesn't explicitly cause one to be sent.

See this discourse discussion for more details.

Test

Confirmed that the tests pass with the patch, and don't pass without the patch.

ninja lldb-unit-test-deps
tools/lldb/unittests/Core/LLDBCoreTests --gtest_filter="Progress*"

@royitaqi royitaqi requested a review from JDevlieghere as a code owner August 6, 2024 03:35
@royitaqi royitaqi requested review from clayborg and removed request for JDevlieghere August 6, 2024 03:35
@llvmbot llvmbot added the lldb label Aug 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2024

@llvm/pr-subscribers-lldb

Author: None (royitaqi)

Changes

Currently, a Progress instance with m_completed != 0 && m_complete != m_total will cause a progressUpdate event (not progressEnd) at destruction. This contradicts with the classdoc:
> a progress completed update is reported even if the user doesn't explicitly cause one to be sent.

Changing it so that any Progress destruction will cause an progressEnd event regardless of the value of m_completed before destruction.

See this discourse discussion for more details.


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

1 Files Affected:

  • (modified) lldb/source/Core/Progress.cpp (+1-2)
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index 1a779e2ddf924..e0ba1a63c508e 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -45,8 +45,7 @@ Progress::~Progress() {
   // Make sure to always report progress completed when this object is
   // destructed so it indicates the progress dialog/activity should go away.
   std::lock_guard<std::mutex> guard(m_mutex);
-  if (!m_completed)
-    m_completed = m_total;
+  m_completed = m_total;
   ReportProgress();
 
   // Report to the ProgressManager if that subsystem is enabled.

@clayborg clayborg requested a review from JDevlieghere August 6, 2024 06:01
@clayborg
Copy link
Collaborator

clayborg commented Aug 6, 2024

Was this why we saw some Swift progress dialogs hanging around forever?

Looks ok to me. @JDevlieghere feel free to add any more reviewers that have been working on progress dialogs.

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

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

LGTM. Could we cover this scenario by the existing unit test?

@royitaqi
Copy link
Contributor Author

royitaqi commented Aug 6, 2024

LGTM. Could we cover this scenario by the existing unit test?

Yes, definitely.

At the time of the patch I didn't find any existing unit test files by searching for "ProgressTest.cpp". Just now I realize there is the ProgressReportTest.cpp. I will read it and try to add a test for this scenario.

Copy link

github-actions bot commented Aug 6, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@royitaqi
Copy link
Contributor Author

royitaqi commented Aug 6, 2024

@JDevlieghere A unit test has been added. I have confirmed that it fails before the patch, and succeeds after the patch.

@royitaqi royitaqi changed the title Make sure that a Progress "completed" update is always reported at destruction [lldb] Make sure that a Progress "completed" update is always reported at destruction Aug 6, 2024
@JDevlieghere
Copy link
Member

Thanks @royitaqi! Once the formatting is fixed this is ready to be merged.

@royitaqi royitaqi merged commit 12fa4b1 into llvm:main Aug 7, 2024
6 checks passed
JDevlieghere pushed a commit to swiftlang/llvm-project that referenced this pull request Aug 7, 2024
…ted at destruction (llvm#102097)

Make all `Progress` destructions to cause `progressEnd` events,
regardless of the value of `m_completed` before the destruction.

Currently, a `Progress` instance with `m_completed != 0 && m_complete !=
m_total` will cause a `progressUpdate` event (not `progressEnd`) at
destruction and. This contradicts with the classdoc: "a progress completed
update is reported even if the user doesn't explicitly cause one to be sent."

(cherry picked from commit 12fa4b1)
JDevlieghere pushed a commit to swiftlang/llvm-project that referenced this pull request Aug 15, 2024
…ted at destruction (llvm#102097)

Make all `Progress` destructions to cause `progressEnd` events,
regardless of the value of `m_completed` before the destruction.

Currently, a `Progress` instance with `m_completed != 0 && m_complete !=
m_total` will cause a `progressUpdate` event (not `progressEnd`) at
destruction and. This contradicts with the classdoc: "a progress completed
update is reported even if the user doesn't explicitly cause one to be sent."

(cherry picked from commit 12fa4b1)
@royitaqi royitaqi deleted the fix-progress-end branch October 24, 2024 21:49
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