diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 4a27766e94e3a..74bb05e6e6bf8 100644 --- a/lldb/include/lldb/Core/DebuggerEvents.h +++ b/lldb/include/lldb/Core/DebuggerEvents.h @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/Progress.h" #include "lldb/Utility/Event.h" #include "lldb/Utility/StructuredData.h" @@ -39,7 +40,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 != Progress::kNonDeterministicTotal; } uint64_t GetCompleted() const { return m_completed; } uint64_t GetTotal() const { return m_total; } std::string GetMessage() const { diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index 65d30ea25cd29..5d88291024605 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -93,6 +93,9 @@ class Progress { void Increment(uint64_t amount = 1, std::optional updated_detail = {}); + /// Used to indicate a non-deterministic progress report + static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; + private: void ReportProgress(); static std::atomic g_id; diff --git a/lldb/source/Core/DebuggerEvents.cpp b/lldb/source/Core/DebuggerEvents.cpp index dd77fff349a64..65aed0eba9c41 100644 --- a/lldb/source/Core/DebuggerEvents.cpp +++ b/lldb/source/Core/DebuggerEvents.cpp @@ -9,6 +9,7 @@ #include "lldb/Core/DebuggerEvents.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" +#include "lldb/Core/Progress.h" #include "llvm/Support/WithColor.h" using namespace lldb_private; @@ -41,7 +42,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 != Progress::kNonDeterministicTotal) 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 355d6952e53ca..732efbc342b45 100644 --- a/lldb/source/Core/Progress.cpp +++ b/lldb/source/Core/Progress.cpp @@ -22,8 +22,7 @@ Progress::Progress(std::string title, std::string details, std::optional total, 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); + m_total(Progress::kNonDeterministicTotal) { if (total) m_total = *total;