LLDB  mainline
SBReproducer.cpp
Go to the documentation of this file.
1 //===-- SBReproducer.cpp ----------------------------------------*- C++ -*-===//
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 "SBReproducerPrivate.h"
10 
11 #include "SBReproducerPrivate.h"
12 #include "lldb/API/LLDB.h"
13 #include "lldb/API/SBAddress.h"
14 #include "lldb/API/SBAttachInfo.h"
15 #include "lldb/API/SBBlock.h"
16 #include "lldb/API/SBBreakpoint.h"
18 #include "lldb/API/SBData.h"
19 #include "lldb/API/SBDebugger.h"
20 #include "lldb/API/SBDeclaration.h"
21 #include "lldb/API/SBError.h"
22 #include "lldb/API/SBFileSpec.h"
23 #include "lldb/API/SBHostOS.h"
24 #include "lldb/API/SBReproducer.h"
25 
26 #include "lldb/Host/FileSystem.h"
27 
28 using namespace lldb;
29 using namespace lldb_private;
30 using namespace lldb_private::repro;
31 
32 SBRegistry::SBRegistry() {
33  Registry& R = *this;
34 
105 }
106 
107 const char *SBReproducer::Capture() {
108  static std::string error;
109  if (auto e = Reproducer::Initialize(ReproducerMode::Capture, llvm::None)) {
110  error = llvm::toString(std::move(e));
111  return error.c_str();
112  }
113  return nullptr;
114 }
115 
116 const char *SBReproducer::Capture(const char *path) {
117  static std::string error;
118  if (auto e =
119  Reproducer::Initialize(ReproducerMode::Capture, FileSpec(path))) {
120  error = llvm::toString(std::move(e));
121  return error.c_str();
122  }
123  return nullptr;
124 }
125 
126 const char *SBReproducer::Replay(const char *path) {
127  static std::string error;
128  if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) {
129  error = llvm::toString(std::move(e));
130  return error.c_str();
131  }
132 
133  repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
134  if (!loader) {
135  error = "unable to get replay loader.";
136  return error.c_str();
137  }
138 
139  FileSpec file = loader->GetFile<SBInfo>();
140  if (!file) {
141  error = "unable to get replay data from reproducer.";
142  return error.c_str();
143  }
144 
145  SBRegistry registry;
146  registry.Replay(file);
147 
148  return nullptr;
149 }
150 
152 const char *SBInfo::name = "sbapi";
153 const char *SBInfo::file = "sbapi.bin";
void RegisterMethods< SBProcess >(Registry &R)
Definition: SBProcess.cpp:1276
void RegisterMethods< SBFrame >(Registry &R)
Definition: SBFrame.cpp:1298
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
void RegisterMethods< SBCommandReturnObject >(Registry &R)
void RegisterMethods< SBTypeFilter >(Registry &R)
void RegisterMethods< SBSymbolContext >(Registry &R)
void RegisterMethods< SBTrace >(Registry &R)
Definition: SBTrace.cpp:135
void RegisterMethods< SBTypeCategory >(Registry &R)
void RegisterMethods< SBAddress >(Registry &R)
Definition: SBAddress.cpp:297
A file utility class.
Definition: FileSpec.h:55
bool Replay(const FileSpec &file)
Replay functions from a file.
void RegisterMethods< SBBreakpoint >(Registry &R)
void RegisterMethods< SBStream >(Registry &R)
Definition: SBStream.cpp:185
void RegisterMethods< SBBlock >(Registry &R)
Definition: SBBlock.cpp:359
void RegisterMethods< SBQueueItem >(Registry &R)
void RegisterMethods< SBListener >(Registry &R)
Definition: SBListener.cpp:330
void RegisterMethods< SBType >(Registry &R)
Definition: SBType.cpp:900
void RegisterMethods< SBCommandInterpreterRunOptions >(Registry &R)
void RegisterMethods< SBModuleSpec >(Registry &R)
void RegisterMethods< SBTypeEnumMember >(Registry &R)
void RegisterMethods< SBUnixSignals >(Registry &R)
void RegisterMethods< SBExpressionOptions >(Registry &R)
void RegisterMethods< SBBreakpointLocation >(Registry &R)
void RegisterMethods< SBTypeSummaryOptions >(Registry &R)
void RegisterMethods< SBDebugger >(Registry &R)
void RegisterMethods< SBPlatformShellCommand >(Registry &R)
Definition: SBPlatform.cpp:644
void RegisterMethods< SBLaunchInfo >(Registry &R)
void RegisterMethods< SBTypeFormat >(Registry &R)
void RegisterMethods< SBLineEntry >(Registry &R)
void RegisterMethods< SBEvent >(Registry &R)
Definition: SBEvent.cpp:214
void RegisterMethods< SBSection >(Registry &R)
Definition: SBSection.cpp:296
llvm::StringRef toString(Record::Kind K)
void RegisterMethods< SBDeclaration >(Registry &R)
static const char * Replay(const char *path)
void RegisterMethods< SBFileSpec >(Registry &R)
Definition: SBFileSpec.cpp:195
void RegisterMethods< SBData >(Registry &R)
Definition: SBData.cpp:654
void RegisterMethods< SBVariablesOptions >(Registry &R)
void RegisterMethods< SBThreadPlan >(Registry &R)
void RegisterMethods< SBPlatformConnectOptions >(Registry &R)
Definition: SBPlatform.cpp:622
void RegisterMethods< SBThread >(Registry &R)
Definition: SBThread.cpp:1406
void RegisterMethods< SBPlatform >(Registry &R)
Definition: SBPlatform.cpp:666
void RegisterMethods< SBFunction >(Registry &R)
Definition: SBFunction.cpp:252
void RegisterMethods< SBTypeSummary >(Registry &R)
void RegisterMethods< SBCompileUnit >(Registry &R)
void RegisterMethods< SBInputReader >(Registry &R)
void RegisterMethods< SBAttachInfo >(Registry &R)
void RegisterMethods< SBLanguageRuntime >(Registry &R)
void RegisterMethods< SBQueue >(Registry &R)
Definition: SBQueue.cpp:336
void RegisterMethods< SBTraceOptions >(Registry &R)
void RegisterMethods< SBSourceManager >(Registry &R)
void RegisterMethods< SBSymbolContextList >(Registry &R)
void RegisterMethods< SBExecutionContext >(Registry &R)
void RegisterMethods< SBInstruction >(Registry &R)
void RegisterMethods< SBHostOS >(Registry &R)
Definition: SBHostOS.cpp:173
void RegisterMethods< SBStringList >(Registry &R)
static const char * Capture()
void RegisterMethods< SBBreakpointName >(Registry &R)
void RegisterMethods< SBInstructionList >(Registry &R)
Definition: SBAddress.h:15
void RegisterMethods< SBMemoryRegionInfo >(Registry &R)
void RegisterMethods< SBMemoryRegionInfoList >(Registry &R)
void RegisterMethods< SBSymbol >(Registry &R)
Definition: SBSymbol.cpp:216
void RegisterMethods< SBTypeSynthetic >(Registry &R)
void RegisterMethods< SBError >(Registry &R)
Definition: SBError.cpp:190
void RegisterMethods< SBProcessInfo >(Registry &R)
void RegisterMethods< SBBreakpointList >(Registry &R)
void RegisterMethods< SBFileSpecList >(Registry &R)
void RegisterMethods< SBValueList >(Registry &R)
void RegisterMethods< SBTarget >(Registry &R)
Definition: SBTarget.cpp:2432
void RegisterMethods< SBStructuredData >(Registry &R)
void RegisterMethods< SBValue >(Registry &R)
Definition: SBValue.cpp:1569
void RegisterMethods< SBTypeNameSpecifier >(Registry &R)
void RegisterMethods< SBModule >(Registry &R)
Definition: SBModule.cpp:696
void RegisterMethods< SBThreadCollection >(Registry &R)
void RegisterMethods< SBBroadcaster >(Registry &R)
void RegisterMethods< SBWatchpoint >(Registry &R)
void RegisterMethods< SBCommunication >(Registry &R)