brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · e331862 Raw
62 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/API/SBProgress.h"10#include "lldb/Core/Progress.h"11#include "lldb/Utility/Instrumentation.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      title, details, /*total=*/std::nullopt, debugger.get(),21      /*minimum_report_time=*/std::nullopt,22      lldb_private::Progress::Origin::eExternal);23}24 25SBProgress::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 35SBProgress::SBProgress(SBProgress &&rhs)36    : m_opaque_up(std::move(rhs.m_opaque_up)) {}37 38SBProgress::~SBProgress() = default;39 40void 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 52void SBProgress::Finalize() {53  // The lldb_private::Progress object is designed to be RAII and send the end54  // progress event when it gets destroyed. So force our contained object to be55  // destroyed and send the progress end event. Clearing this object also allows56  // all other methods to quickly return without doing any work if they are57  // called after this method.58  m_opaque_up.reset();59}60 61lldb_private::Progress &SBProgress::ref() const { return *m_opaque_up; }62