[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 "SBReproducerPrivate.h"
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
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"
|
2019-12-03 23:53:23 +08:00
|
|
|
#include "lldb/lldb-private.h"
|
2019-02-07 02:57:42 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::repro;
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBRegistry::SBRegistry() {
|
2019-11-20 09:28:46 +08:00
|
|
|
Registry &R = *this;
|
2019-03-06 08:06:00 +08:00
|
|
|
|
2019-03-20 01:13:13 +08:00
|
|
|
RegisterMethods<SBAddress>(R);
|
|
|
|
RegisterMethods<SBAttachInfo>(R);
|
|
|
|
RegisterMethods<SBBlock>(R);
|
|
|
|
RegisterMethods<SBBreakpoint>(R);
|
|
|
|
RegisterMethods<SBBreakpointList>(R);
|
|
|
|
RegisterMethods<SBBreakpointLocation>(R);
|
|
|
|
RegisterMethods<SBBreakpointName>(R);
|
|
|
|
RegisterMethods<SBBroadcaster>(R);
|
2020-05-01 04:28:42 +08:00
|
|
|
RegisterMethods<SBCommandInterpreter>(R);
|
2019-03-20 01:13:13 +08:00
|
|
|
RegisterMethods<SBCommandInterpreterRunOptions>(R);
|
|
|
|
RegisterMethods<SBCommandReturnObject>(R);
|
|
|
|
RegisterMethods<SBCommunication>(R);
|
|
|
|
RegisterMethods<SBCompileUnit>(R);
|
|
|
|
RegisterMethods<SBData>(R);
|
|
|
|
RegisterMethods<SBDebugger>(R);
|
|
|
|
RegisterMethods<SBDeclaration>(R);
|
2020-05-21 03:59:51 +08:00
|
|
|
RegisterMethods<SBEnvironment>(R);
|
2019-03-20 01:13:13 +08:00
|
|
|
RegisterMethods<SBError>(R);
|
|
|
|
RegisterMethods<SBEvent>(R);
|
|
|
|
RegisterMethods<SBExecutionContext>(R);
|
|
|
|
RegisterMethods<SBExpressionOptions>(R);
|
2019-10-03 12:01:07 +08:00
|
|
|
RegisterMethods<SBFile>(R);
|
2019-03-20 01:13:13 +08:00
|
|
|
RegisterMethods<SBFileSpec>(R);
|
|
|
|
RegisterMethods<SBFileSpecList>(R);
|
|
|
|
RegisterMethods<SBFrame>(R);
|
|
|
|
RegisterMethods<SBFunction>(R);
|
|
|
|
RegisterMethods<SBHostOS>(R);
|
2020-05-21 03:59:51 +08:00
|
|
|
RegisterMethods<SBInputReader>(R);
|
2019-03-20 01:13:13 +08:00
|
|
|
RegisterMethods<SBInstruction>(R);
|
|
|
|
RegisterMethods<SBInstructionList>(R);
|
|
|
|
RegisterMethods<SBLanguageRuntime>(R);
|
|
|
|
RegisterMethods<SBLaunchInfo>(R);
|
|
|
|
RegisterMethods<SBLineEntry>(R);
|
|
|
|
RegisterMethods<SBListener>(R);
|
|
|
|
RegisterMethods<SBMemoryRegionInfo>(R);
|
|
|
|
RegisterMethods<SBMemoryRegionInfoList>(R);
|
|
|
|
RegisterMethods<SBModule>(R);
|
|
|
|
RegisterMethods<SBModuleSpec>(R);
|
2020-05-21 03:59:51 +08:00
|
|
|
RegisterMethods<SBPlatform>(R);
|
2019-03-20 01:13:13 +08:00
|
|
|
RegisterMethods<SBPlatformConnectOptions>(R);
|
|
|
|
RegisterMethods<SBPlatformShellCommand>(R);
|
|
|
|
RegisterMethods<SBProcess>(R);
|
|
|
|
RegisterMethods<SBProcessInfo>(R);
|
|
|
|
RegisterMethods<SBQueue>(R);
|
|
|
|
RegisterMethods<SBQueueItem>(R);
|
|
|
|
RegisterMethods<SBSection>(R);
|
|
|
|
RegisterMethods<SBSourceManager>(R);
|
|
|
|
RegisterMethods<SBStream>(R);
|
|
|
|
RegisterMethods<SBStringList>(R);
|
|
|
|
RegisterMethods<SBStructuredData>(R);
|
|
|
|
RegisterMethods<SBSymbol>(R);
|
|
|
|
RegisterMethods<SBSymbolContext>(R);
|
|
|
|
RegisterMethods<SBSymbolContextList>(R);
|
|
|
|
RegisterMethods<SBTarget>(R);
|
|
|
|
RegisterMethods<SBThread>(R);
|
|
|
|
RegisterMethods<SBThreadCollection>(R);
|
|
|
|
RegisterMethods<SBThreadPlan>(R);
|
|
|
|
RegisterMethods<SBTrace>(R);
|
|
|
|
RegisterMethods<SBTraceOptions>(R);
|
|
|
|
RegisterMethods<SBType>(R);
|
|
|
|
RegisterMethods<SBTypeCategory>(R);
|
|
|
|
RegisterMethods<SBTypeEnumMember>(R);
|
|
|
|
RegisterMethods<SBTypeFilter>(R);
|
|
|
|
RegisterMethods<SBTypeFormat>(R);
|
|
|
|
RegisterMethods<SBTypeNameSpecifier>(R);
|
|
|
|
RegisterMethods<SBTypeSummary>(R);
|
2020-05-21 03:59:51 +08:00
|
|
|
RegisterMethods<SBTypeSummaryOptions>(R);
|
2019-03-20 01:13:13 +08:00
|
|
|
RegisterMethods<SBTypeSynthetic>(R);
|
|
|
|
RegisterMethods<SBUnixSignals>(R);
|
|
|
|
RegisterMethods<SBValue>(R);
|
|
|
|
RegisterMethods<SBValueList>(R);
|
|
|
|
RegisterMethods<SBVariablesOptions>(R);
|
|
|
|
RegisterMethods<SBWatchpoint>(R);
|
2019-03-06 08:06:00 +08:00
|
|
|
}
|
2019-02-07 02:57:42 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
|
|
|
|
auto &p = g->GetOrCreate<SBProvider>();
|
|
|
|
InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
|
|
|
|
auto &p = g->GetOrCreate<SBProvider>();
|
|
|
|
InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry());
|
|
|
|
}
|
|
|
|
|
2020-04-14 23:41:50 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBReproducer::PassiveReplay(const char *path) {
|
|
|
|
static std::string error;
|
2020-04-21 00:37:07 +08:00
|
|
|
if (auto e = Reproducer::Initialize(ReproducerMode::PassiveReplay,
|
|
|
|
FileSpec(path))) {
|
2020-04-14 23:41:50 +08:00
|
|
|
error = llvm::toString(std::move(e));
|
|
|
|
return error.c_str();
|
2019-02-22 06:26:16 +08:00
|
|
|
}
|
2020-04-21 00:37:07 +08:00
|
|
|
|
|
|
|
if (auto *l = lldb_private::repro::Reproducer::Instance().GetLoader()) {
|
|
|
|
FileSpec file = l->GetFile<SBProvider::Info>();
|
|
|
|
auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
|
|
|
|
if (!error_or_file) {
|
|
|
|
error =
|
|
|
|
"unable to read SB API data: " + error_or_file.getError().message();
|
|
|
|
return error.c_str();
|
|
|
|
}
|
|
|
|
static ReplayData r(std::move(*error_or_file));
|
|
|
|
InstrumentationData::Initialize(r.GetDeserializer(), r.GetRegistry());
|
|
|
|
}
|
|
|
|
|
2019-02-22 06:26:16 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-01-11 06:54:29 +08:00
|
|
|
const char *SBReproducer::Replay(const char *path) {
|
|
|
|
return SBReproducer::Replay(path, false);
|
|
|
|
}
|
|
|
|
|
2019-12-03 23:53:23 +08:00
|
|
|
const char *SBReproducer::Replay(const char *path, bool skip_version_check) {
|
2019-02-22 06:26:16 +08:00
|
|
|
static std::string error;
|
|
|
|
if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) {
|
|
|
|
error = llvm::toString(std::move(e));
|
|
|
|
return error.c_str();
|
|
|
|
}
|
|
|
|
|
2019-02-07 02:57:42 +08:00
|
|
|
repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
|
2019-02-22 06:26:16 +08:00
|
|
|
if (!loader) {
|
|
|
|
error = "unable to get replay loader.";
|
|
|
|
return error.c_str();
|
|
|
|
}
|
2019-02-07 02:57:42 +08:00
|
|
|
|
2019-12-03 23:53:23 +08:00
|
|
|
if (!skip_version_check) {
|
|
|
|
llvm::Expected<std::string> version = loader->LoadBuffer<VersionProvider>();
|
|
|
|
if (!version) {
|
|
|
|
error = llvm::toString(version.takeError());
|
|
|
|
return error.c_str();
|
|
|
|
}
|
|
|
|
if (lldb_private::GetVersion() != llvm::StringRef(*version).rtrim()) {
|
|
|
|
error = "reproducer capture and replay version don't match:\n";
|
|
|
|
error.append("reproducer captured with:\n");
|
|
|
|
error.append(*version);
|
|
|
|
error.append("reproducer replayed with:\n");
|
|
|
|
error.append(lldb_private::GetVersion());
|
|
|
|
return error.c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 06:17:38 +08:00
|
|
|
FileSpec file = loader->GetFile<SBProvider::Info>();
|
2019-02-22 06:26:16 +08:00
|
|
|
if (!file) {
|
|
|
|
error = "unable to get replay data from reproducer.";
|
|
|
|
return error.c_str();
|
|
|
|
}
|
2019-02-07 02:57:42 +08:00
|
|
|
|
|
|
|
SBRegistry registry;
|
|
|
|
registry.Replay(file);
|
|
|
|
|
2019-02-22 06:26:16 +08:00
|
|
|
return nullptr;
|
2019-02-07 02:57:42 +08:00
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
static std::string path;
|
|
|
|
auto &r = Reproducer::Instance();
|
|
|
|
path = r.GetReproducerPath().GetCString();
|
|
|
|
return path.c_str();
|
|
|
|
}
|
|
|
|
|
2020-05-13 23:54:57 +08:00
|
|
|
void SBReproducer::SetWorkingDirectory(const char *path) {
|
|
|
|
if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
|
|
|
|
g->GetOrCreate<WorkingDirectoryProvider>().Update(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-07 02:57:42 +08:00
|
|
|
char lldb_private::repro::SBProvider::ID = 0;
|
2019-06-13 06:17:38 +08:00
|
|
|
const char *SBProvider::Info::name = "sbapi";
|
|
|
|
const char *SBProvider::Info::file = "sbapi.bin";
|