1 //===-- SBReproducerPrivate.h -----------------------------------*- C++ -*-===// 2 // 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H 11 #define LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H 12 13 #include "lldb/API/SBReproducer.h" 14 15 #include "lldb/Utility/FileSpec.h" 16 #include "lldb/Utility/Log.h" 17 #include "lldb/Utility/Reproducer.h" 18 #include "lldb/Utility/ReproducerInstrumentation.h" 19 #include "lldb/Utility/ReproducerProvider.h" 20 21 #include "llvm/ADT/DenseMap.h" 22 23 #define LLDB_GET_INSTRUMENTATION_DATA() \ 24 lldb_private::repro::InstrumentationData::Instance() 25 26 namespace lldb_private { 27 namespace repro { 28 29 class SBRegistry : public Registry { 30 public: 31 SBRegistry(); 32 }; 33 34 class SBProvider : public Provider<SBProvider> { 35 public: 36 struct Info { 37 static const char *name; 38 static const char *file; 39 }; 40 SBProvider(const FileSpec & directory)41 SBProvider(const FileSpec &directory) 42 : Provider(directory), 43 m_stream(directory.CopyByAppendingPathComponent("sbapi.bin").GetPath(), 44 m_ec, llvm::sys::fs::OpenFlags::OF_None), 45 m_serializer(m_stream) {} 46 GetSerializer()47 Serializer &GetSerializer() { return m_serializer; } GetRegistry()48 Registry &GetRegistry() { return m_registry; } 49 50 static char ID; 51 52 private: 53 std::error_code m_ec; 54 llvm::raw_fd_ostream m_stream; 55 Serializer m_serializer; 56 SBRegistry m_registry; 57 }; 58 59 class ReplayData { 60 public: ReplayData(std::unique_ptr<llvm::MemoryBuffer> memory_buffer)61 ReplayData(std::unique_ptr<llvm::MemoryBuffer> memory_buffer) 62 : m_memory_buffer(std::move(memory_buffer)), m_registry(), 63 m_deserializer(m_memory_buffer->getBuffer()) {} GetDeserializer()64 Deserializer &GetDeserializer() { return m_deserializer; } GetRegistry()65 Registry &GetRegistry() { return m_registry; } 66 67 private: 68 std::unique_ptr<llvm::MemoryBuffer> m_memory_buffer; 69 SBRegistry m_registry; 70 Deserializer m_deserializer; 71 }; 72 73 template <typename T> void RegisterMethods(Registry &R); 74 75 } // namespace repro 76 } // namespace lldb_private 77 78 #endif 79