LLDB mainline
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
lldb_private::Progress Class Reference

A Progress indicator helper class. More...

#include <Progress.h>

Classes

struct  ProgressData
 Data belonging to this Progress event that is used for bookkeeping by ProgressManager. More...
 

Public Member Functions

 Progress (std::string title, std::string details={}, std::optional< uint64_t > total=std::nullopt, lldb_private::Debugger *debugger=nullptr, Timeout< std::nano > minimum_report_time=std::nullopt)
 Construct a progress object that will report information.
 
 ~Progress ()
 Destroy the progress object.
 
void Increment (uint64_t amount=1, std::optional< std::string > updated_detail={})
 Increment the progress and send a notification to the installed callback.
 

Static Public Attributes

static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX
 Used to indicate a non-deterministic progress report.
 

Private Member Functions

void ReportProgress ()
 

Private Attributes

const uint64_t m_total
 Total amount of work, use a std::nullopt in the constructor for non deterministic progress.
 
const Timeout< std::nano > m_minimum_report_time
 
const ProgressData m_progress_data
 Data needed by the debugger to broadcast a progress event.
 
std::atomic< uint64_t > m_completed = 0
 How much work ([0...m_total]) that has been completed.
 
std::atomic< uint64_t > m_last_report_time_ns
 Time (in nanoseconds since epoch) of the last progress report.
 
std::mutex m_mutex
 Guards non-const non-atomic members of the class.
 
std::string m_details
 More specific information about the current file being displayed in the report.
 
std::optional< uint64_t > m_prev_completed
 The "completed" value of the last reported event.
 

Static Private Attributes

static std::atomic< uint64_t > g_id
 

Detailed Description

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 completed set to zero and 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 completed set to Progress::m_total. This ensures we always send a progress completed update even if the user does not.

Definition at line 60 of file Progress.h.

Constructor & Destructor Documentation

◆ Progress()

Progress::Progress ( std::string  title,
std::string  details = {},
std::optional< uint64_t >  total = std::nullopt,
lldb_private::Debugger debugger = nullptr,
Timeout< std::nano >  minimum_report_time = std::nullopt 
)

Construct a progress object that will report information.

The constructor will create a unique progress reporting object and immediately send out a progress update by calling the installed callback with completed set to zero out of the specified total.

Parameters
[in]titleThe title of this progress activity.
[in]detailsSpecific information about what the progress report is currently working on. Although not required, if the progress report is updated with Progress::Increment() then this field will be overwritten with the new set of details passed into that function, and the details passed initially will act as an "item 0" for the total set of items being reported on.
[in]totalThe total units of work to be done if specified, if set to std::nullopt then an indeterminate progress indicator should be displayed.
[in]debuggerAn optional debugger pointer to specify that this progress is to be reported only to specific debuggers.

Definition at line 28 of file Progress.cpp.

References lldb_private::ProgressManager::Enabled(), g_progress_signposts, lldb_private::ProgressManager::Increment(), lldb_private::ProgressManager::Instance(), m_mutex, m_progress_data, ReportProgress(), and lldb_private::Progress::ProgressData::title.

◆ ~Progress()

Progress::~Progress ( )

Destroy the progress object.

If the progress has not yet sent a completion update, the destructor will send out a notification where the completed == m_total. This ensures that we always send out a progress complete notification.

Definition at line 53 of file Progress.cpp.

References lldb_private::ProgressManager::Decrement(), lldb_private::ProgressManager::Enabled(), g_progress_signposts, lldb_private::ProgressManager::Instance(), m_completed, m_mutex, m_progress_data, m_total, ReportProgress(), and lldb_private::Progress::ProgressData::title.

Member Function Documentation

◆ Increment()

void Progress::Increment ( uint64_t  amount = 1,
std::optional< std::string >  updated_detail = {} 
)

Increment the progress and send a notification to the installed callback.

If incrementing ends up exceeding m_total, m_completed will be updated to match m_total and no subsequent progress notifications will be sent. If no total was specified in the constructor, this function will not do anything nor send any progress updates.

Parameters
[in]amountThe amount to increment m_completed by.
[in]anoptional message associated with this update.

Definition at line 68 of file Progress.cpp.

References m_completed, m_details, m_last_report_time_ns, m_minimum_report_time, m_mutex, and ReportProgress().

Referenced by MinidumpFileBuilder::AddMemoryList_32(), MinidumpFileBuilder::AddMemoryList_64(), lldb_private::plugin::dwarf::ManualDWARFIndex::Index(), and DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule().

◆ ReportProgress()

void Progress::ReportProgress ( )
private

Member Data Documentation

◆ g_id

std::atomic< uint64_t > Progress::g_id
staticprivate

Definition at line 125 of file Progress.h.

◆ kNonDeterministicTotal

constexpr uint64_t lldb_private::Progress::kNonDeterministicTotal = UINT64_MAX
staticconstexpr

Used to indicate a non-deterministic progress report.

Definition at line 109 of file Progress.h.

Referenced by lldb_private::ProgressEventData::Dump(), lldb_private::ProgressEventData::IsFinite(), and lldb_private::ProgressManager::ReportProgress().

◆ m_completed

std::atomic<uint64_t> lldb_private::Progress::m_completed = 0
private

How much work ([0...m_total]) that has been completed.

Definition at line 138 of file Progress.h.

Referenced by Increment(), ReportProgress(), and ~Progress().

◆ m_details

std::string lldb_private::Progress::m_details
private

More specific information about the current file being displayed in the report.

Definition at line 148 of file Progress.h.

Referenced by Increment(), and ReportProgress().

◆ m_last_report_time_ns

std::atomic<uint64_t> lldb_private::Progress::m_last_report_time_ns
private

Time (in nanoseconds since epoch) of the last progress report.

Definition at line 141 of file Progress.h.

Referenced by Increment().

◆ m_minimum_report_time

const Timeout<std::nano> lldb_private::Progress::m_minimum_report_time
private

Definition at line 132 of file Progress.h.

Referenced by Increment().

◆ m_mutex

std::mutex lldb_private::Progress::m_mutex
private

Guards non-const non-atomic members of the class.

Definition at line 144 of file Progress.h.

Referenced by Increment(), Progress(), and ~Progress().

◆ m_prev_completed

std::optional<uint64_t> lldb_private::Progress::m_prev_completed
private

The "completed" value of the last reported event.

Definition at line 151 of file Progress.h.

Referenced by ReportProgress().

◆ m_progress_data

const ProgressData lldb_private::Progress::m_progress_data
private

Data needed by the debugger to broadcast a progress event.

Definition at line 135 of file Progress.h.

Referenced by Progress(), ReportProgress(), and ~Progress().

◆ m_total

const uint64_t lldb_private::Progress::m_total
private

Total amount of work, use a std::nullopt in the constructor for non deterministic progress.

Definition at line 129 of file Progress.h.

Referenced by ReportProgress(), and ~Progress().


The documentation for this class was generated from the following files: