LLDB mainline
SBProgress.cpp
Go to the documentation of this file.
1//===-- SBProgress.cpp --------------------------------------------------*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Progress.h"
12
13using namespace lldb;
14
15SBProgress::SBProgress(const char *title, const char *details,
16 SBDebugger &debugger) {
17 LLDB_INSTRUMENT_VA(this, title, details, debugger);
18
19 m_opaque_up = std::make_unique<lldb_private::Progress>(
20 llvm::StringRef(title).str(), llvm::StringRef(details).str(),
21 /*total=*/std::nullopt, debugger.get(),
22 /*minimum_report_time=*/std::nullopt,
24}
25
26SBProgress::SBProgress(const char *title, const char *details,
27 uint64_t total_units, SBDebugger &debugger) {
28 LLDB_INSTRUMENT_VA(this, title, details, total_units, debugger);
29
30 m_opaque_up = std::make_unique<lldb_private::Progress>(
31 llvm::StringRef(title).str(), llvm::StringRef(details).str(), total_units,
32 debugger.get(),
33 /*minimum_report_time=*/std::nullopt,
35}
36
39
40SBProgress::~SBProgress() = default;
41
42void SBProgress::Increment(uint64_t amount, const char *description) {
43 LLDB_INSTRUMENT_VA(amount, description);
44
45 if (!m_opaque_up)
46 return;
47
48 std::optional<std::string> description_opt;
49 if (description && description[0])
50 description_opt = description;
51 m_opaque_up->Increment(amount, std::move(description_opt));
52}
53
55 // The lldb_private::Progress object is designed to be RAII and send the end
56 // progress event when it gets destroyed. So force our contained object to be
57 // destroyed and send the progress end event. Clearing this object also allows
58 // all other methods to quickly return without doing any work if they are
59 // called after this method.
60 m_opaque_up.reset();
61}
62
#define LLDB_INSTRUMENT_VA(...)
lldb_private::Debugger * get() const
lldb_private::Progress & ref() const
void Finalize()
Explicitly finalize an SBProgress, this can be used to terminate a progress on command instead of wai...
SBProgress(const char *title, const char *details, SBDebugger &debugger)
Construct a progress object with a title, details and a given debugger.
void Increment(uint64_t amount, const char *description=nullptr)
std::unique_ptr< lldb_private::Progress > m_opaque_up
Definition SBProgress.h:74
A Progress indicator helper class.
Definition Progress.h:60