Skip to content

[lldb][Progress] Separate title and details #77547

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 6 commits into from
Jan 16, 2024

Conversation

chelcassanova
Copy link
Contributor

Per this RFC:
https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717 on improving progress reports, this commit separates the title field and details field so that the title specifies the category that the progress report falls under. The details field is added as a part of the constructor for progress reports and by default is an empty string. Also updates the test to check for details being correctly reported from the event structured data dictionary.

Per this RFC:
https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717
on improving progress reports, this commit separates the title field and
details field so that the title specifies the category that the progress
report falls under. The details field is added as a part of the
constructor for progress reports and by default is an empty string. Also
updates the test to check for details being correctly reported from the
event structured data dictionary.
@llvmbot
Copy link
Member

llvmbot commented Jan 10, 2024

@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)

Changes

Per this RFC:
https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717 on improving progress reports, this commit separates the title field and details field so that the title specifies the category that the progress report falls under. The details field is added as a part of the constructor for progress reports and by default is an empty string. Also updates the test to check for details being correctly reported from the event structured data dictionary.


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

8 Files Affected:

  • (modified) lldb/include/lldb/Core/DebuggerEvents.h (+2-2)
  • (modified) lldb/include/lldb/Core/Progress.h (+2-1)
  • (modified) lldb/source/Core/Progress.cpp (+4-3)
  • (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+1-1)
  • (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+1-3)
  • (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+2-4)
  • (modified) lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp (+1-3)
  • (modified) lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py (+2)
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h
index 982b22229701f8..1fadb96a4b565d 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -20,9 +20,9 @@ class Stream;
 
 class ProgressEventData : public EventData {
 public:
-  ProgressEventData(uint64_t progress_id, std::string title, std::string update,
+  ProgressEventData(uint64_t progress_id, std::string title, std::string details,
                     uint64_t completed, uint64_t total, bool debugger_specific)
-      : m_title(std::move(title)), m_details(std::move(update)),
+      : m_title(std::move(title)), m_details(std::move(details)),
         m_id(progress_id), m_completed(completed), m_total(total),
         m_debugger_specific(debugger_specific) {}
 
diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h
index b2b8781a43b059..1ea6df01a4bd4a 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -69,7 +69,7 @@ class Progress {
   ///
   /// @param [in] debugger An optional debugger pointer to specify that this
   /// progress is to be reported only to specific debuggers.
-  Progress(std::string title, uint64_t total = UINT64_MAX,
+    Progress(std::string title, std::string details = {}, uint64_t total = UINT64_MAX,
            lldb_private::Debugger *debugger = nullptr);
 
   /// Destroy the progress object.
@@ -96,6 +96,7 @@ class Progress {
   static std::atomic<uint64_t> g_id;
   /// The title of the progress activity.
   std::string m_title;
+  std::string m_details;
   std::mutex m_mutex;
   /// A unique integer identifier for progress reporting.
   const uint64_t m_id;
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index ea3f874916a999..8c99b561373362 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -16,9 +16,9 @@ using namespace lldb_private;
 
 std::atomic<uint64_t> Progress::g_id(0);
 
-Progress::Progress(std::string title, uint64_t total,
+Progress::Progress(std::string title, std::string details, uint64_t total,
                    lldb_private::Debugger *debugger)
-    : m_title(title), m_id(++g_id), m_completed(0), m_total(total) {
+    : m_title(title), m_details(details), m_id(++g_id), m_completed(0), m_total(total) {
   assert(total > 0);
   if (debugger)
     m_debugger_id = debugger->GetID();
@@ -38,6 +38,7 @@ Progress::~Progress() {
 void Progress::Increment(uint64_t amount, std::string update) {
   if (amount > 0) {
     std::lock_guard<std::mutex> guard(m_mutex);
+    m_details = update;
     // Watch out for unsigned overflow and make sure we don't increment too
     // much and exceed m_total.
     if (amount > (m_total - m_completed))
@@ -53,7 +54,7 @@ void Progress::ReportProgress(std::string update) {
     // Make sure we only send one notification that indicates the progress is
     // complete.
     m_complete = m_completed == m_total;
-    Debugger::ReportProgress(m_id, m_title, std::move(update), m_completed,
+    Debugger::ReportProgress(m_id, m_title, m_details, m_completed,
                              m_total, m_debugger_id);
   }
 }
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 182a9f2afaeb2e..f451bac598b874 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2225,7 +2225,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   const char *file_name = file.GetFilename().AsCString("<Unknown>");
   LLDB_SCOPED_TIMERF("ObjectFileMachO::ParseSymtab () module = %s", file_name);
   LLDB_LOG(log, "Parsing symbol table for {0}", file_name);
-  Progress progress(llvm::formatv("Parsing symbol table for {0}", file_name));
+  Progress progress("Parsing symbol table", file_name);
 
   llvm::MachO::symtab_command symtab_load_command = {0, 0, 0, 0, 0, 0};
   llvm::MachO::linkedit_data_command function_starts_load_command = {0, 0, 0, 0};
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 16ff5f7d4842ca..52555908865b0b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -75,9 +75,7 @@ void ManualDWARFIndex::Index() {
   // Include 2 passes per unit to index for extracting DIEs from the unit and
   // indexing the unit, and then 8 extra entries for finalizing each index set.
   const uint64_t total_progress = units_to_index.size() * 2 + 8;
-  Progress progress(
-      llvm::formatv("Manually indexing DWARF for {0}", module_desc.GetData()),
-      total_progress);
+  Progress progress("Manually indexing DWARF", module_desc.GetData(), total_progress);
 
   std::vector<IndexSet> sets(units_to_index.size());
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 1a16b70f42fe1f..1ea14366ad7dd7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -519,8 +519,7 @@ void SymbolFileDWARF::InitializeObject() {
 
     if (apple_names.GetByteSize() > 0 || apple_namespaces.GetByteSize() > 0 ||
         apple_types.GetByteSize() > 0 || apple_objc.GetByteSize() > 0) {
-      Progress progress(llvm::formatv("Loading Apple DWARF index for {0}",
-                                      module_desc.GetData()));
+      Progress progress("Loading Apple DWARF index", module_desc.GetData());
       m_index = AppleDWARFIndex::Create(
           *GetObjectFile()->GetModule(), apple_names, apple_namespaces,
           apple_types, apple_objc, m_context.getOrLoadStrData());
@@ -532,8 +531,7 @@ void SymbolFileDWARF::InitializeObject() {
     DWARFDataExtractor debug_names;
     LoadSectionData(eSectionTypeDWARFDebugNames, debug_names);
     if (debug_names.GetByteSize() > 0) {
-      Progress progress(
-          llvm::formatv("Loading DWARF5 index for {0}", module_desc.GetData()));
+      Progress progress("Loading DWARF5 index", module_desc.GetData());
       llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> index_or =
           DebugNamesDWARFIndex::Create(*GetObjectFile()->GetModule(),
                                        debug_names,
diff --git a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
index ed014f99fdb5e7..52ae7adb8d3d97 100644
--- a/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
@@ -98,9 +98,7 @@ std::optional<FileSpec> SymbolLocatorDefault::LocateExecutableSymbolFile(
       FileSystem::Instance().Exists(symbol_file_spec))
     return symbol_file_spec;
 
-  Progress progress(llvm::formatv(
-      "Locating external symbol file for {0}",
-      module_spec.GetFileSpec().GetFilename().AsCString("<Unknown>")));
+  Progress progress("Locating external symbol file", module_spec.GetFileSpec().GetFilename().AsCString("<Unknown>"));
 
   FileSpecList debug_file_search_paths = default_search_paths;
 
diff --git a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
index 0e72770e350366..9af53845ca1b77 100644
--- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -39,3 +39,5 @@ def test_dwarf_symbol_loading_progress_report_structured_data(self):
         progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event)
         message = progress_data.GetValueForKey("message").GetStringValue(100)
         self.assertGreater(len(message), 0)
+        details = progress_data.GetValueForKey("details").GetStringValue(100)
+        self.assertGreater(len(details), 0)

Copy link

github-actions bot commented Jan 10, 2024

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

Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

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

The roots of this look really good. A few nits we can choose to fix or do in another patch.

@@ -69,7 +69,8 @@ class Progress {
///
/// @param [in] debugger An optional debugger pointer to specify that this
/// progress is to be reported only to specific debuggers.
Progress(std::string title, uint64_t total = UINT64_MAX,
Progress(std::string title, std::string details = {},
uint64_t total = UINT64_MAX,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be good to start using std::optional<uint64_t> internally in the Progress class and avoid the magic numbers as long as we are changing things up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure, this was actually a part of the original patch I made trying to introduce the aggregate flag.

@@ -519,8 +519,7 @@ void SymbolFileDWARF::InitializeObject() {

if (apple_names.GetByteSize() > 0 || apple_namespaces.GetByteSize() > 0 ||
apple_types.GetByteSize() > 0 || apple_objc.GetByteSize() > 0) {
Progress progress(llvm::formatv("Loading Apple DWARF index for {0}",
module_desc.GetData()));
Progress progress("Loading Apple DWARF index", module_desc.GetData());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we get rid of this? This will never take any time to load and will just cause progress spam. I would vote to remove this unless there is something that can take time, but I can't think of anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be removed, I also have to update the progress report for ELF files to match the rest of the changes here 😅

@@ -532,8 +531,7 @@ void SymbolFileDWARF::InitializeObject() {
DWARFDataExtractor debug_names;
LoadSectionData(eSectionTypeDWARFDebugNames, debug_names);
if (debug_names.GetByteSize() > 0) {
Progress progress(
llvm::formatv("Loading DWARF5 index for {0}", module_desc.GetData()));
Progress progress("Loading DWARF5 index", module_desc.GetData());
Copy link
Collaborator

Choose a reason for hiding this comment

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

DWARF5 on the other hand usually has a single .debug_names table per compile unit, and there can be mixed DWARF5 .debug_names tables along with some compile units that need to be manually indexed, so it might be worth keeping this progress.

Updates the ELF index progress report, remove the Apple DWARF progress
report and use a std::optional for the `m_total` field in `Progress`
Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

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

A bit more cleanup, see inline comment

ReportProgress();
}

void Progress::Increment(uint64_t amount, std::string update) {
if (amount > 0) {
std::lock_guard<std::mutex> guard(m_mutex);
m_details = update;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably make std::string update into std::optional<std::string> updated_detail as we default this argument to an empty string currently and the first call to this function from the DWARF indexer will then clear the DWARF path since update will be empty. Now that m_details is the only thing that holds onto the filename for all progresses, we don't want the Increment(...) call to result the m_details. This code will now need to be:

if (updated_detail)
  m_details = *updated_detail;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll add the std::optional for Increment and remove this parameter from ReportProgress 👍🏾

if (amount > (m_total - m_completed))
m_completed = m_total;
if (m_total.has_value() && (amount > (m_total.value() - m_completed)))
m_completed = m_total.value();
else
m_completed += amount;
ReportProgress(update);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are now storing any new detail into m_details, do we need to send this to ReportProgress now? Prior to this, this string wasn't stored anywhere but now we have a copy, so we should probably remove the parameter to this.

@@ -51,9 +56,10 @@ void Progress::Increment(uint64_t amount, std::string update) {
void Progress::ReportProgress(std::string update) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove std::string update as we have it in m_details

Comment on lines 62 to 63
Debugger::ReportProgress(m_id, m_title, m_details, m_completed,
m_total.value_or(0), m_debugger_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will actually mess up reporting of progress reports with no valid total. We will always sent out completed = 0 and total = 0 for both the start and end events. The easiest way to fix this would be to leave m_total as a uint64_t inside of progress, but still allow the argument to be an optional in the constructor. We need completed to not be equal to total, the start progress event will have completed=0 and total=<non-zero>, and then the end event will need to have completed=total where total is non zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how I didn't realize that, I had this implementation from my first patch for a bool flag for this. Weirdly enough the test passed with those changes even though I don't think they should've. Either way I'll update this, my mistake.

/// Total amount of work, UINT64_MAX for non deterministic progress.
const uint64_t m_total;
/// Total amount of work, use a std::nullopt for non deterministic progress.
const std::optional<uint64_t> m_total;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to leave this as a uint64_t so that we can report progress start events and end events correctly. See comments in Progress::ReportProgress(...). We need total to be reported as non-zero as the end events are considered a notification where completed == total

Comment on lines 24 to 26
: m_title(title), m_details(details), m_id(++g_id), m_completed(0),
m_total(total) {
assert(total == std::nullopt || total > 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need total to be non zero when there is no actual total:

m_total(1) { // Default to one if in case there is no valid total
// Set the actual total if we have a valid value
if (total)
  m_total = *total;

Comment on lines 37 to 38
if (m_total.has_value() && !m_completed)
m_completed = m_total.value();
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert (see comments above and down in Progress::ReportProgress(...) for details

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seconded from your comments on ReportProgress above.

variable for total

Change the parameter for `Increment` to use a std::optional string for
the updated details as well as remove the string parameter for
`ReportProgress` as its no longer necessary since all details are being
stored in a member variable at object creation. Also reverts Progress's
`m_total` to being a uint64_t instead of having both the member variable
and construction parameter both be a std::optional<uint64_t>
@@ -90,10 +90,11 @@ class Progress {
/// @param [in] amount The amount to increment m_completed by.
///
/// @param [in] an optional message associated with this update.
void Increment(uint64_t amount = 1, std::string update = {});
void Increment(uint64_t amount = 1,
std::optional<std::string> updated_detail = {});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated_detail is still kept as an empty string by default, though I'm unsure if the empty string or std::nullopt is preferred here

if (amount > 0) {
std::lock_guard<std::mutex> guard(m_mutex);
if (updated_detail)
m_details = *updated_detail;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could use std::move() here to avoid a copy?

Comment on lines 65 to 66
if (m_total)
m_complete = m_completed == m_total;
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for the if statement anymore, these two lines can just be:

m_complete = m_completed == m_total;

When `m_details` is updated with `Increment` use std::move instead of
making a copy of the updated details. Also removes the if clause that
updates m_complete in `ReportProgress`
Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. On comment might be able to be reverted, but this looks good.

if (!m_complete) {
// Make sure we only send one notification that indicates the progress is
// complete.
// complete, and only modify m_complete is m_total isn't null.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the comment out of date? revert comment?

Fix outdated comment
Copy link
Member

@medismailben medismailben left a comment

Choose a reason for hiding this comment

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

LGTM!

@chelcassanova chelcassanova merged commit f1ef910 into llvm:main Jan 16, 2024
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Jan 18, 2024
Per this RFC:
https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717
on improving progress reports, this commit separates the title field and
details field so that the title specifies the category that the progress
report falls under. The details field is added as a part of the
constructor for progress reports and by default is an empty string. In addition, changes the total amount of progress completed into a std::optional. Also
updates the test to check for details being correctly reported from the
event structured data dictionary.

Some changes were made to Swift progress reports to match the upstream
changes to `Progress`.
(cherry picked from commit f1ef910)
chelcassanova added a commit to swiftlang/llvm-project that referenced this pull request Jan 22, 2024
Per this RFC:
https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717
on improving progress reports, this commit separates the title field and
details field so that the title specifies the category that the progress
report falls under. The details field is added as a part of the
constructor for progress reports and by default is an empty string. In addition, changes the total amount of progress completed into a std::optional. Also
updates the test to check for details being correctly reported from the
event structured data dictionary.

Some changes were made to Swift progress reports to match the upstream
changes to `Progress`.
(cherry picked from commit f1ef910)
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Per this RFC:
https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717
on improving progress reports, this commit separates the title field and
details field so that the title specifies the category that the progress
report falls under. The details field is added as a part of the
constructor for progress reports and by default is an empty string. In addition, changes the total amount of progress completed into a std::optional. Also
updates the test to check for details being correctly reported from the
event structured data dictionary.
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Jan 29, 2024
The `total` parameter for the constructor for Progress was changed to a
std::optional in llvm#77547. When
initializing the `m_total` member variable for progress, it is set to 1
if the `total` parameter is std::nullopt. Other areas of the code were
still checking if `m_total` was a UINT64_MAX to determine if the
progress was deterministic or not, so these have been changed to check
for the integer 1.

The member variable `m_total` could be changed to a std::optional as
well, but this means that the `ProgressEventData::GetTotal()` (which is
used for the public API) would
either need to return a std::optional value or it would return some
specific integer to represent non-deterministic progress if `m_total`
is std::nullopt.
chelcassanova added a commit that referenced this pull request Jan 30, 2024
…9912)

The `total` parameter for the constructor for Progress was changed to a
std::optional in #77547. It was originally set to 1 to indicate non-determinisitic progress, but this commit changes this. First, `UINT64_MAX` will again be used for non-deterministic progress, and `Progress` now has a static variable set to this value so that we can use this instead of a magic number. 

The member variable `m_total` could be changed to a std::optional as
well, but this means that the `ProgressEventData::GetTotal()` (which is
used for the public API) would
either need to return a std::optional value or it would return some
specific integer to represent non-deterministic progress if `m_total` is
std::nullopt.
JDevlieghere pushed a commit to swiftlang/llvm-project that referenced this pull request Feb 1, 2024
Per this RFC:
https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717
on improving progress reports, this commit separates the title field and
details field so that the title specifies the category that the progress
report falls under. The details field is added as a part of the
constructor for progress reports and by default is an empty string. In addition, changes the total amount of progress completed into a std::optional. Also
updates the test to check for details being correctly reported from the
event structured data dictionary.

Some changes were made to Swift progress reports to match the upstream
changes to `Progress`.
(cherry picked from commit f1ef910)
(cherry picked from commit 342d11d)
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Feb 1, 2024
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this pull request Feb 1, 2024
…vm#79912)

The `total` parameter for the constructor for Progress was changed to a
std::optional in llvm#77547. It was originally set to 1 to indicate non-determinisitic progress, but this commit changes this. First, `UINT64_MAX` will again be used for non-deterministic progress, and `Progress` now has a static variable set to this value so that we can use this instead of a magic number.

The member variable `m_total` could be changed to a std::optional as
well, but this means that the `ProgressEventData::GetTotal()` (which is
used for the public API) would
either need to return a std::optional value or it would return some
specific integer to represent non-deterministic progress if `m_total` is
std::nullopt.

(cherry picked from commit 733b86d)
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 7, 2024
As part of the effort to improve progress reporting in
LLDB (https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717)
we want a way to keep track of progress reports to see if they're
ongoing. The ultimate goal is to use this information to essentially
keep these reports alive using timeouts to more gracefully deliver these
reports.

To lay the groundwork to do this, this commit adds a map to progress
reports that keeps track of each category of reports (using the changes
from llvm#77547) and uses a
refcount to check if these reports are still considered active or not. A
refcount of at least one indicates that the report is still active.

I've added an enum to `Progress.h` to toggle whether this behaviour is
used or not. By default it is not used, so this commit is marked as NFC.
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 7, 2024
As part of the effort to improve progress reporting in
LLDB (https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717)
we want a way to keep track of progress reports to see if they're
ongoing. The ultimate goal is to use this information to essentially
keep these reports alive using timeouts to more gracefully deliver these
reports.

To lay the groundwork to do this, this commit adds a map to progress
reports that keeps track of each category of reports (using the changes
from llvm#77547) and uses a
refcount to check if these reports are still considered active or not. A
refcount of at least one indicates that the report is still active.

I've added an enum to `Progress.h` to toggle whether this behaviour is
used or not. By default it is not used, so this commit is marked as NFC.
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