summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBReproducer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/API/SBReproducer.cpp')
-rw-r--r--lldb/source/API/SBReproducer.cpp61
1 files changed, 57 insertions, 4 deletions
diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp
index 3d2de07274448..0eb3429c4fefc 100644
--- a/lldb/source/API/SBReproducer.cpp
+++ b/lldb/source/API/SBReproducer.cpp
@@ -1,4 +1,4 @@
-//===-- SBReproducer.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBReproducer.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +15,7 @@
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
#include "lldb/API/SBData.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDeclaration.h"
@@ -40,14 +41,15 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBBreakpointLocation>(R);
RegisterMethods<SBBreakpointName>(R);
RegisterMethods<SBBroadcaster>(R);
+ RegisterMethods<SBCommandInterpreter>(R);
RegisterMethods<SBCommandInterpreterRunOptions>(R);
RegisterMethods<SBCommandReturnObject>(R);
RegisterMethods<SBCommunication>(R);
RegisterMethods<SBCompileUnit>(R);
RegisterMethods<SBData>(R);
- RegisterMethods<SBInputReader>(R);
RegisterMethods<SBDebugger>(R);
RegisterMethods<SBDeclaration>(R);
+ RegisterMethods<SBEnvironment>(R);
RegisterMethods<SBError>(R);
RegisterMethods<SBEvent>(R);
RegisterMethods<SBExecutionContext>(R);
@@ -58,6 +60,7 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBFrame>(R);
RegisterMethods<SBFunction>(R);
RegisterMethods<SBHostOS>(R);
+ RegisterMethods<SBInputReader>(R);
RegisterMethods<SBInstruction>(R);
RegisterMethods<SBInstructionList>(R);
RegisterMethods<SBLanguageRuntime>(R);
@@ -68,9 +71,9 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBMemoryRegionInfoList>(R);
RegisterMethods<SBModule>(R);
RegisterMethods<SBModuleSpec>(R);
+ RegisterMethods<SBPlatform>(R);
RegisterMethods<SBPlatformConnectOptions>(R);
RegisterMethods<SBPlatformShellCommand>(R);
- RegisterMethods<SBPlatform>(R);
RegisterMethods<SBProcess>(R);
RegisterMethods<SBProcessInfo>(R);
RegisterMethods<SBQueue>(R);
@@ -95,8 +98,8 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBTypeFilter>(R);
RegisterMethods<SBTypeFormat>(R);
RegisterMethods<SBTypeNameSpecifier>(R);
- RegisterMethods<SBTypeSummaryOptions>(R);
RegisterMethods<SBTypeSummary>(R);
+ RegisterMethods<SBTypeSummaryOptions>(R);
RegisterMethods<SBTypeSynthetic>(R);
RegisterMethods<SBUnixSignals>(R);
RegisterMethods<SBValue>(R);
@@ -111,6 +114,12 @@ const char *SBReproducer::Capture() {
error = llvm::toString(std::move(e));
return error.c_str();
}
+
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ auto &p = g->GetOrCreate<SBProvider>();
+ InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry());
+ }
+
return nullptr;
}
@@ -121,6 +130,35 @@ const char *SBReproducer::Capture(const char *path) {
error = llvm::toString(std::move(e));
return error.c_str();
}
+
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ auto &p = g->GetOrCreate<SBProvider>();
+ InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry());
+ }
+
+ return nullptr;
+}
+
+const char *SBReproducer::PassiveReplay(const char *path) {
+ static std::string error;
+ if (auto e = Reproducer::Initialize(ReproducerMode::PassiveReplay,
+ FileSpec(path))) {
+ error = llvm::toString(std::move(e));
+ return error.c_str();
+ }
+
+ 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());
+ }
+
return nullptr;
}
@@ -178,6 +216,15 @@ bool SBReproducer::Generate() {
return false;
}
+bool SBReproducer::SetAutoGenerate(bool b) {
+ auto &r = Reproducer::Instance();
+ if (auto generator = r.GetGenerator()) {
+ generator->SetAutoGenerate(b);
+ return true;
+ }
+ return false;
+}
+
const char *SBReproducer::GetPath() {
static std::string path;
auto &r = Reproducer::Instance();
@@ -185,6 +232,12 @@ const char *SBReproducer::GetPath() {
return path.c_str();
}
+void SBReproducer::SetWorkingDirectory(const char *path) {
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ g->GetOrCreate<WorkingDirectoryProvider>().Update(path);
+ }
+}
+
char lldb_private::repro::SBProvider::ID = 0;
const char *SBProvider::Info::name = "sbapi";
const char *SBProvider::Info::file = "sbapi.bin";