[Lldb-commits] [lldb] [lldb][progress] Correctly check total for deterministic progress (PR #79912)
Chelsea Cassanova via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 29 15:43:47 PST 2024
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/79912
>From af9a5581702b5c9ca8009fc32c7ae10a1654d391 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova <chelsea_cassanova at apple.com>
Date: Mon, 29 Jan 2024 15:29:46 -0800
Subject: [PATCH] [lldb][progress] Correctly check total for deterministic
progress
The `total` parameter for the constructor for Progress was changed to a
std::optional in https://github.com/llvm/llvm-project/pull/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.
---
lldb/include/lldb/Core/DebuggerEvents.h | 2 +-
lldb/source/Core/DebuggerEvents.cpp | 2 +-
lldb/source/Core/Progress.cpp | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h
index 4a27766e94e3aa7..2c3fcd7069d5e97 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -39,7 +39,7 @@ class ProgressEventData : public EventData {
GetAsStructuredData(const Event *event_ptr);
uint64_t GetID() const { return m_id; }
- bool IsFinite() const { return m_total != UINT64_MAX; }
+ bool IsFinite() const { return m_total != 1; }
uint64_t GetCompleted() const { return m_completed; }
uint64_t GetTotal() const { return m_total; }
std::string GetMessage() const {
diff --git a/lldb/source/Core/DebuggerEvents.cpp b/lldb/source/Core/DebuggerEvents.cpp
index dd77fff349a64a7..c83bc20fba97ae2 100644
--- a/lldb/source/Core/DebuggerEvents.cpp
+++ b/lldb/source/Core/DebuggerEvents.cpp
@@ -41,7 +41,7 @@ void ProgressEventData::Dump(Stream *s) const {
s->PutCString(", type = update");
// If m_total is UINT64_MAX, there is no progress to report, just "start"
// and "end". If it isn't we will show the completed and total amounts.
- if (m_total != UINT64_MAX)
+ if (m_total != 1)
s->Printf(", progress = %" PRIu64 " of %" PRIu64, m_completed, m_total);
}
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index 355d6952e53ca9d..411a27fbf7e9938 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -23,7 +23,6 @@ Progress::Progress(std::string title, std::string details,
lldb_private::Debugger *debugger)
: m_title(title), m_details(details), m_id(++g_id), m_completed(0),
m_total(1) {
- assert(total == std::nullopt || total > 0);
if (total)
m_total = *total;
More information about the lldb-commits
mailing list