LLDB  mainline
SBReproducerPrivate.h
Go to the documentation of this file.
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_API_SBREPRODUCER_PRIVATE_H
11 #define LLDB_API_SBREPRODUCER_PRIVATE_H
12 
13 #include "lldb/API/SBReproducer.h"
14 
15 #include "lldb/Utility/FileSpec.h"
16 #include "lldb/Utility/Log.h"
19 
20 #include "llvm/ADT/DenseMap.h"
21 
22 #define LLDB_GET_INSTRUMENTATION_DATA() \
23  lldb_private::repro::GetInstrumentationData()
24 
25 namespace lldb_private {
26 namespace repro {
27 
28 class SBRegistry : public Registry {
29 public:
30  SBRegistry();
31 };
32 
33 struct SBInfo {
34  static const char *name;
35  static const char *file;
36 };
37 
38 class SBProvider : public Provider<SBProvider> {
39 public:
40  typedef SBInfo info;
41 
42  SBProvider(const FileSpec &directory)
43  : Provider(directory),
44  m_stream(directory.CopyByAppendingPathComponent("sbapi.bin").GetPath(),
45  m_ec, llvm::sys::fs::OpenFlags::F_None),
46  m_serializer(m_stream) {}
47 
48  Serializer &GetSerializer() { return m_serializer; }
49  Registry &GetRegistry() { return m_registry; }
50 
51  static char ID;
52 
53 private:
54  std::error_code m_ec;
55  llvm::raw_fd_ostream m_stream;
56  Serializer m_serializer;
57  SBRegistry m_registry;
58 };
59 
62  return {};
63 
64  if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
65  auto &p = g->GetOrCreate<SBProvider>();
66  return {p.GetSerializer(), p.GetRegistry()};
67  }
68 
69  return {};
70 }
71 
72 template <typename T> void RegisterMethods(Registry &R);
73 
74 } // namespace repro
75 } // namespace lldb_private
76 
77 #endif
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
Definition: Debugger.h:71
void RegisterMethods(Registry &R)
SBProvider(const FileSpec &directory)
A file utility class.
Definition: FileSpec.h:55
InstrumentationData GetInstrumentationData()
static Reproducer & Instance()
Definition: Reproducer.cpp:21
Serializes functions, their arguments and their return type to a stream.