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 "lldb/API/LLDB.h" 12 #include "lldb/API/SBAddress.h" 13 #include "lldb/API/SBAttachInfo.h" 14 #include "lldb/API/SBBlock.h" 15 #include "lldb/API/SBBreakpoint.h" 16 #include "lldb/API/SBCommandInterpreter.h" 17 #include "lldb/API/SBData.h" 18 #include "lldb/API/SBDebugger.h" 19 #include "lldb/API/SBDeclaration.h" 20 #include "lldb/API/SBError.h" 21 #include "lldb/API/SBFileSpec.h" 22 #include "lldb/API/SBHostOS.h" 23 #include "lldb/API/SBReproducer.h" 24 25 #include "lldb/Host/FileSystem.h" 26 27 using namespace lldb; 28 using namespace lldb_private; 29 using namespace lldb_private::repro; 30 31 SBRegistry::SBRegistry() {} 32 33 const char *SBReproducer::Capture(const char *path) { 34 static std::string error; 35 if (auto e = 36 Reproducer::Initialize(ReproducerMode::Capture, FileSpec(path))) { 37 error = llvm::toString(std::move(e)); 38 return error.c_str(); 39 } 40 return nullptr; 41 } 42 43 const char *SBReproducer::Replay(const char *path) { 44 static std::string error; 45 if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) { 46 error = llvm::toString(std::move(e)); 47 return error.c_str(); 48 } 49 50 repro::Loader *loader = repro::Reproducer::Instance().GetLoader(); 51 if (!loader) { 52 error = "unable to get replay loader."; 53 return error.c_str(); 54 } 55 56 // FIXME: Enable the following code once the SB reproducer has landed. 57 #if 0 58 FileSpec file = loader->GetFile<SBInfo>(); 59 if (!file) { 60 error = "unable to get replay data from reproducer."; 61 return error.c_str(); 62 } 63 64 SBRegistry registry; 65 registry.Replay(file); 66 #endif 67 68 return nullptr; 69 } 70 71 char lldb_private::repro::SBProvider::ID = 0; 72 const char *SBInfo::name = "sbapi"; 73 const char *SBInfo::file = "sbapi.bin"; 74