[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- SBReproducer.cpp --------------------------------------------------===//
|
2019-02-07 02:57:42 +08:00
|
|
|
//
|
2019-02-11 16:03:41 +08:00
|
|
|
// 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
|
2019-02-07 02:57:42 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
#include "lldb/API/LLDB.h"
|
|
|
|
#include "lldb/API/SBAddress.h"
|
|
|
|
#include "lldb/API/SBAttachInfo.h"
|
|
|
|
#include "lldb/API/SBBlock.h"
|
|
|
|
#include "lldb/API/SBBreakpoint.h"
|
|
|
|
#include "lldb/API/SBCommandInterpreter.h"
|
2020-05-01 04:28:42 +08:00
|
|
|
#include "lldb/API/SBCommandInterpreterRunOptions.h"
|
2019-02-07 02:57:42 +08:00
|
|
|
#include "lldb/API/SBData.h"
|
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
#include "lldb/API/SBDeclaration.h"
|
|
|
|
#include "lldb/API/SBError.h"
|
|
|
|
#include "lldb/API/SBFileSpec.h"
|
|
|
|
#include "lldb/API/SBHostOS.h"
|
|
|
|
#include "lldb/API/SBReproducer.h"
|
|
|
|
#include "lldb/Host/FileSystem.h"
|
2021-12-09 04:23:57 +08:00
|
|
|
#include "lldb/Version/Version.h"
|
2022-01-08 08:26:40 +08:00
|
|
|
#include "lldb/Utility/ReproducerInstrumentation.h"
|
|
|
|
#include "lldb/Utility/Reproducer.h"
|
|
|
|
#include "lldb/Utility/ReproducerProvider.h"
|
2019-02-07 02:57:42 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::repro;
|
|
|
|
|
2020-09-01 06:13:49 +08:00
|
|
|
SBReplayOptions::SBReplayOptions()
|
2020-09-03 16:19:40 +08:00
|
|
|
: m_opaque_up(std::make_unique<ReplayOptions>()){}
|
2020-09-01 06:13:49 +08:00
|
|
|
|
|
|
|
SBReplayOptions::SBReplayOptions(const SBReplayOptions &rhs)
|
|
|
|
: m_opaque_up(std::make_unique<ReplayOptions>(*rhs.m_opaque_up)) {}
|
|
|
|
|
|
|
|
SBReplayOptions::~SBReplayOptions() = default;
|
|
|
|
|
|
|
|
SBReplayOptions &SBReplayOptions::operator=(const SBReplayOptions &rhs) {
|
|
|
|
if (this == &rhs)
|
|
|
|
return *this;
|
|
|
|
*m_opaque_up = *rhs.m_opaque_up;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBReplayOptions::SetVerify(bool verify) { m_opaque_up->verify = verify; }
|
|
|
|
|
|
|
|
bool SBReplayOptions::GetVerify() const { return m_opaque_up->verify; }
|
|
|
|
|
|
|
|
void SBReplayOptions::SetCheckVersion(bool check) {
|
|
|
|
m_opaque_up->check_version = check;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBReplayOptions::GetCheckVersion() const {
|
|
|
|
return m_opaque_up->check_version;
|
|
|
|
}
|
|
|
|
|
2019-03-13 00:44:18 +08:00
|
|
|
const char *SBReproducer::Capture() {
|
|
|
|
static std::string error;
|
|
|
|
if (auto e = Reproducer::Initialize(ReproducerMode::Capture, llvm::None)) {
|
|
|
|
error = llvm::toString(std::move(e));
|
|
|
|
return error.c_str();
|
|
|
|
}
|
2020-04-21 00:37:07 +08:00
|
|
|
|
2019-03-13 00:44:18 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-02-22 06:26:16 +08:00
|
|
|
const char *SBReproducer::Capture(const char *path) {
|
|
|
|
static std::string error;
|
|
|
|
if (auto e =
|
|
|
|
Reproducer::Initialize(ReproducerMode::Capture, FileSpec(path))) {
|
|
|
|
error = llvm::toString(std::move(e));
|
|
|
|
return error.c_str();
|
2020-04-14 23:41:50 +08:00
|
|
|
}
|
2020-04-21 00:37:07 +08:00
|
|
|
|
2020-04-14 23:41:50 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBReproducer::PassiveReplay(const char *path) {
|
2021-12-18 06:45:24 +08:00
|
|
|
return "Reproducer replay has been removed";
|
2019-02-22 06:26:16 +08:00
|
|
|
}
|
|
|
|
|
2020-01-11 06:54:29 +08:00
|
|
|
const char *SBReproducer::Replay(const char *path) {
|
2021-12-18 06:45:24 +08:00
|
|
|
return "Reproducer replay has been removed";
|
2020-01-11 06:54:29 +08:00
|
|
|
}
|
|
|
|
|
2019-12-03 23:53:23 +08:00
|
|
|
const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
|
2021-12-18 06:45:24 +08:00
|
|
|
return Replay(path);
|
2020-09-01 06:13:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBReproducer::Replay(const char *path,
|
|
|
|
const SBReplayOptions &options) {
|
2021-12-18 06:45:24 +08:00
|
|
|
return Replay(path);
|
2019-02-07 02:57:42 +08:00
|
|
|
}
|
|
|
|
|
2020-10-24 03:31:33 +08:00
|
|
|
const char *SBReproducer::Finalize(const char *path) {
|
|
|
|
static std::string error;
|
|
|
|
|
|
|
|
repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
|
|
|
|
if (!loader) {
|
|
|
|
error = "unable to get replay loader.";
|
|
|
|
return error.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto e = repro::Finalize(loader)) {
|
|
|
|
error = llvm::toString(std::move(e));
|
|
|
|
return error.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-11-20 09:28:46 +08:00
|
|
|
bool SBReproducer::Generate() {
|
|
|
|
auto &r = Reproducer::Instance();
|
|
|
|
if (auto generator = r.GetGenerator()) {
|
|
|
|
generator->Keep();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-16 11:44:46 +08:00
|
|
|
bool SBReproducer::SetAutoGenerate(bool b) {
|
|
|
|
auto &r = Reproducer::Instance();
|
|
|
|
if (auto generator = r.GetGenerator()) {
|
|
|
|
generator->SetAutoGenerate(b);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-11-20 09:28:46 +08:00
|
|
|
const char *SBReproducer::GetPath() {
|
2020-10-24 03:31:33 +08:00
|
|
|
ConstString path;
|
2019-11-20 09:28:46 +08:00
|
|
|
auto &r = Reproducer::Instance();
|
2020-10-24 03:31:33 +08:00
|
|
|
if (FileSpec reproducer_path = Reproducer::Instance().GetReproducerPath())
|
|
|
|
path = ConstString(r.GetReproducerPath().GetCString());
|
|
|
|
return path.GetCString();
|
2019-11-20 09:28:46 +08:00
|
|
|
}
|
|
|
|
|
2020-05-13 23:54:57 +08:00
|
|
|
void SBReproducer::SetWorkingDirectory(const char *path) {
|
|
|
|
if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
|
2020-07-21 02:23:43 +08:00
|
|
|
auto &wp = g->GetOrCreate<repro::WorkingDirectoryProvider>();
|
2020-08-21 07:03:45 +08:00
|
|
|
wp.SetDirectory(path);
|
2020-07-21 02:23:43 +08:00
|
|
|
auto &fp = g->GetOrCreate<repro::FileProvider>();
|
2020-08-21 07:03:45 +08:00
|
|
|
fp.RecordInterestingDirectory(wp.GetDirectory());
|
2020-05-13 23:54:57 +08:00
|
|
|
}
|
|
|
|
}
|