1 //===-- SBReproducerPrivate.h -----------------------------------*- C++ -*-===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_API_SBREPRODUCER_PRIVATE_H
11 #define LLDB_API_SBREPRODUCER_PRIVATE_H
13 #include "lldb/API/SBReproducer.h"
15 #include "lldb/Utility/FileSpec.h"
16 #include "lldb/Utility/Log.h"
17 #include "lldb/Utility/Reproducer.h"
18 #include "lldb/Utility/ReproducerInstrumentation.h"
20 #include "llvm/ADT/DenseMap.h"
22 #define LLDB_GET_INSTRUMENTATION_DATA() \
23 lldb_private::repro::GetInstrumentationData()
25 namespace lldb_private
{
28 class SBRegistry
: public Registry
{
33 class SBProvider
: public Provider
<SBProvider
> {
36 static const char *name
;
37 static const char *file
;
40 SBProvider(const FileSpec
&directory
)
41 : Provider(directory
),
42 m_stream(directory
.CopyByAppendingPathComponent("sbapi.bin").GetPath(),
43 m_ec
, llvm::sys::fs::OpenFlags::OF_None
),
44 m_serializer(m_stream
) {}
46 Serializer
&GetSerializer() { return m_serializer
; }
47 Registry
&GetRegistry() { return m_registry
; }
53 llvm::raw_fd_ostream m_stream
;
54 Serializer m_serializer
;
55 SBRegistry m_registry
;
58 inline InstrumentationData
GetInstrumentationData() {
59 if (!lldb_private::repro::Reproducer::Initialized())
62 if (auto *g
= lldb_private::repro::Reproducer::Instance().GetGenerator()) {
63 auto &p
= g
->GetOrCreate
<SBProvider
>();
64 return {p
.GetSerializer(), p
.GetRegistry()};
70 template <typename T
> void RegisterMethods(Registry
&R
);
73 } // namespace lldb_private