Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/lldb/source/API/SBProgress.cpp
213764 views
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
9
#include "lldb/API/SBProgress.h"
10
#include "lldb/Core/Progress.h"
11
#include "lldb/Utility/Instrumentation.h"
12
13
using namespace lldb;
14
15
SBProgress::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
title, details, /*total=*/std::nullopt, debugger.get(),
21
/*minimum_report_time=*/std::nullopt,
22
lldb_private::Progress::Origin::eExternal);
23
}
24
25
SBProgress::SBProgress(const char *title, const char *details,
26
uint64_t total_units, SBDebugger &debugger) {
27
LLDB_INSTRUMENT_VA(this, title, details, total_units, debugger);
28
29
m_opaque_up = std::make_unique<lldb_private::Progress>(
30
title, details, total_units, debugger.get(),
31
/*minimum_report_time=*/std::nullopt,
32
lldb_private::Progress::Origin::eExternal);
33
}
34
35
SBProgress::SBProgress(SBProgress &&rhs)
36
: m_opaque_up(std::move(rhs.m_opaque_up)) {}
37
38
SBProgress::~SBProgress() = default;
39
40
void SBProgress::Increment(uint64_t amount, const char *description) {
41
LLDB_INSTRUMENT_VA(amount, description);
42
43
if (!m_opaque_up)
44
return;
45
46
std::optional<std::string> description_opt;
47
if (description && description[0])
48
description_opt = description;
49
m_opaque_up->Increment(amount, std::move(description_opt));
50
}
51
52
void SBProgress::Finalize() {
53
// The lldb_private::Progress object is designed to be RAII and send the end
54
// progress event when it gets destroyed. So force our contained object to be
55
// destroyed and send the progress end event. Clearing this object also allows
56
// all other methods to quickly return without doing any work if they are
57
// called after this method.
58
m_opaque_up.reset();
59
}
60
61
lldb_private::Progress &SBProgress::ref() const { return *m_opaque_up; }
62
63