diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -67,9 +67,13 @@ /// set to UINT64_MAX then an indeterminate progress indicator should be /// displayed. /// + /// @param [in] report_increment Notify only when progress has exceeded + /// this amount. Throttles messaging. + /// /// @param [in] debugger An optional debugger pointer to specify that this /// progress is to be reported only to specific debuggers. Progress(std::string title, uint64_t total = UINT64_MAX, + uint64_t report_increment = 1, lldb_private::Debugger *debugger = nullptr); /// Destroy the progress object. @@ -101,6 +105,10 @@ const uint64_t m_id; /// How much work ([0...m_total]) that has been completed. uint64_t m_completed; + /// Print a message when progress exceeds this amount. + uint64_t m_report_increment; + /// Progress at the time of last message. + uint64_t m_last_reported; /// Total amount of work, UINT64_MAX for non deterministic progress. const uint64_t m_total; /// The optional debugger ID to report progress to. If this has no value then diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp --- a/lldb/source/Core/Progress.cpp +++ b/lldb/source/Core/Progress.cpp @@ -16,9 +16,10 @@ std::atomic Progress::g_id(0); -Progress::Progress(std::string title, uint64_t total, +Progress::Progress(std::string title, uint64_t total, uint64_t report_increment, lldb_private::Debugger *debugger) - : m_title(title), m_id(++g_id), m_completed(0), m_total(total) { + : m_title(title), m_id(++g_id), m_completed(0), + m_report_increment(report_increment), m_last_reported(0), m_total(total) { assert(total > 0); if (debugger) m_debugger_id = debugger->GetID(); @@ -54,7 +55,11 @@ // Make sure we only send one notification that indicates the progress is // complete. m_complete = m_completed == m_total; - Debugger::ReportProgress(m_id, m_title, std::move(update), m_completed, - m_total, m_debugger_id); + if (m_complete || m_completed == 0 || + m_completed >= m_last_reported + m_report_increment) { + m_last_reported = m_completed; + Debugger::ReportProgress(m_id, m_title, std::move(update), m_completed, + m_total, m_debugger_id); + } } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -76,7 +76,8 @@ const uint64_t total_progress = units_to_index.size() * 2 + 8; Progress progress( llvm::formatv("Manually indexing DWARF for {0}", module_desc.GetData()), - total_progress); + total_progress, + /*report_increment=*/ 1000); std::vector sets(units_to_index.size());