Skip to content

Commit af9a558

Browse files
committed
[lldb][progress] Correctly check total for deterministic progress
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.
1 parent 8f1d94a commit af9a558

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

lldb/include/lldb/Core/DebuggerEvents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ProgressEventData : public EventData {
3939
GetAsStructuredData(const Event *event_ptr);
4040

4141
uint64_t GetID() const { return m_id; }
42-
bool IsFinite() const { return m_total != UINT64_MAX; }
42+
bool IsFinite() const { return m_total != 1; }
4343
uint64_t GetCompleted() const { return m_completed; }
4444
uint64_t GetTotal() const { return m_total; }
4545
std::string GetMessage() const {

lldb/source/Core/DebuggerEvents.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void ProgressEventData::Dump(Stream *s) const {
4141
s->PutCString(", type = update");
4242
// If m_total is UINT64_MAX, there is no progress to report, just "start"
4343
// and "end". If it isn't we will show the completed and total amounts.
44-
if (m_total != UINT64_MAX)
44+
if (m_total != 1)
4545
s->Printf(", progress = %" PRIu64 " of %" PRIu64, m_completed, m_total);
4646
}
4747

lldb/source/Core/Progress.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Progress::Progress(std::string title, std::string details,
2323
lldb_private::Debugger *debugger)
2424
: m_title(title), m_details(details), m_id(++g_id), m_completed(0),
2525
m_total(1) {
26-
assert(total == std::nullopt || total > 0);
2726
if (total)
2827
m_total = *total;
2928

0 commit comments

Comments
 (0)