[Lldb-commits] [lldb] [lldb][progress] Correctly check total for deterministic progress (PR #79912)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 29 15:43:02 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Chelsea Cassanova (chelcassanova)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/79912.diff
2 Files Affected:
- (modified) lldb/include/lldb/Core/DebuggerEvents.h (+1-1)
- (modified) lldb/source/Core/DebuggerEvents.cpp (+1-1)
``````````diff
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h b/lldb/include/lldb/Core/DebuggerEvents.h
index 4a27766e94e3a..2c3fcd7069d5e 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 dd77fff349a64..c83bc20fba97a 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);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/79912
More information about the lldb-commits
mailing list