diff options
author | Chelsea Cassanova <chelsea_cassanova@apple.com> | 2024-01-30 12:00:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-30 12:00:38 -0800 |
commit | 733b86d3ff8087f1e267c23eb315bb16e3c6c953 (patch) | |
tree | 2b639dc35c611104a9214f2699553a90723d0f8f /lldb/include | |
parent | 6fecfbc7b62f54bd633e83c22630d7c2a3e5741e (diff) | |
download | llvm-733b86d3ff8087f1e267c23eb315bb16e3c6c953.zip llvm-733b86d3ff8087f1e267c23eb315bb16e3c6c953.tar.gz llvm-733b86d3ff8087f1e267c23eb315bb16e3c6c953.tar.bz2 |
[lldb][progress] Correctly check total for deterministic progress (#79912)
The `total` parameter for the constructor for Progress was changed to a
std::optional in https://github.com/llvm/llvm-project/pull/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.
Diffstat (limited to 'lldb/include')
-rw-r--r-- | lldb/include/lldb/Core/DebuggerEvents.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/Core/Progress.h | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h index 4a27766..74bb05e 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 @@ public: 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 65d30ea..5d88291 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -93,6 +93,9 @@ public: void Increment(uint64_t amount = 1, std::optional<std::string> updated_detail = {}); + /// Used to indicate a non-deterministic progress report + static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; + private: void ReportProgress(); static std::atomic<uint64_t> g_id; |