//===-- Progress.h ----------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLDB_CORE_PROGRESS_H #define LLDB_CORE_PROGRESS_H #include "lldb/Host/Alarm.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringMap.h" #include <atomic> #include <cstdint> #include <mutex> #include <optional> namespace lldb_private { /// A Progress indicator helper class. /// /// Any potentially long running sections of code in LLDB should report /// progress so that clients are aware of delays that might appear during /// debugging. Delays commonly include indexing debug information, parsing /// symbol tables for object files, downloading symbols from remote /// repositories, and many more things. /// /// The Progress class helps make sure that progress is correctly reported /// and will always send an initial progress update, updates when /// Progress::Increment() is called, and also will make sure that a progress /// completed update is reported even if the user doesn't explicitly cause one /// to be sent. /// /// The progress is reported via a callback whose type is ProgressCallback: /// /// typedef void (*ProgressCallback)(uint64_t progress_id, /// const char *message, /// uint64_t completed, /// uint64_t total, /// void *baton); /// /// This callback will always initially be called with \a completed set to zero /// and \a total set to the total amount specified in the constructor. This is /// considered the progress start event. As Progress::Increment() is called, /// the callback will be called as long as the Progress::m_completed has not /// yet exceeded the Progress::m_total. When the callback is called with /// Progress::m_completed == Progress::m_total, that is considered a progress /// completed event. If Progress::m_completed is non-zero and less than /// Progress::m_total, then this is considered a progress update event. /// /// This callback will be called in the destructor if Progress::m_completed is /// not equal to Progress::m_total with the \a completed set to /// Progress::m_total. This ensures we always send a progress completed update /// even if the user does not. class Progress { … }; /// A class used to group progress reports by category. This is done by using a /// map that maintains a refcount of each category of progress reports that have /// come in. Keeping track of progress reports this way will be done if a /// debugger is listening to the eBroadcastBitProgressByCategory broadcast bit. class ProgressManager { … }; } // namespace lldb_private #endif // LLDB_CORE_PROGRESS_H