LLVM  7.0.0
PDBFileBuilder.h
Go to the documentation of this file.
1 //===- PDBFileBuilder.h - PDB File Creation ---------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILEBUILDER_H
11 #define LLVM_DEBUGINFO_PDB_RAW_PDBFILEBUILDER_H
12 
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/BitVector.h"
15 #include "llvm/ADT/Optional.h"
21 #include "llvm/Support/Allocator.h"
22 #include "llvm/Support/Endian.h"
23 #include "llvm/Support/Error.h"
25 
26 #include <memory>
27 #include <vector>
28 
29 namespace llvm {
30 namespace msf {
31 class MSFBuilder;
32 }
33 namespace pdb {
34 class DbiStreamBuilder;
35 class InfoStreamBuilder;
36 class GSIStreamBuilder;
37 class TpiStreamBuilder;
38 
40 public:
42  ~PDBFileBuilder();
43  PDBFileBuilder(const PDBFileBuilder &) = delete;
44  PDBFileBuilder &operator=(const PDBFileBuilder &) = delete;
45 
47 
48  msf::MSFBuilder &getMsfBuilder();
49  InfoStreamBuilder &getInfoBuilder();
50  DbiStreamBuilder &getDbiBuilder();
51  TpiStreamBuilder &getTpiBuilder();
52  TpiStreamBuilder &getIpiBuilder();
53  PDBStringTableBuilder &getStringTableBuilder();
54  GSIStreamBuilder &getGsiBuilder();
55 
56  Error commit(StringRef Filename);
57 
58  Expected<uint32_t> getNamedStreamIndex(StringRef Name) const;
59  Error addNamedStream(StringRef Name, StringRef Data);
60  void addInjectedSource(StringRef Name, std::unique_ptr<MemoryBuffer> Buffer);
61 
62 private:
63  struct InjectedSourceDescriptor {
64  // The full name of the stream that contains the contents of this injected
65  // source. This is built as a concatenation of the literal "/src/files"
66  // plus the "vname".
67  std::string StreamName;
68 
69  // The exact name of the file name as specified by the user.
70  uint32_t NameIndex;
71 
72  // The string table index of the "vname" of the file. As far as we
73  // understand, this is the same as the name, except it is lowercased and
74  // forward slashes are converted to backslashes.
75  uint32_t VNameIndex;
76  std::unique_ptr<MemoryBuffer> Content;
77  };
78 
79  Error finalizeMsfLayout();
80  Expected<uint32_t> allocateNamedStream(StringRef Name, uint32_t Size);
81 
82  void commitFpm(WritableBinaryStream &MsfBuffer, const msf::MSFLayout &Layout);
83  void commitInjectedSources(WritableBinaryStream &MsfBuffer,
84  const msf::MSFLayout &Layout);
85  void commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer,
86  const msf::MSFLayout &Layout);
87 
89 
90  std::unique_ptr<msf::MSFBuilder> Msf;
91  std::unique_ptr<InfoStreamBuilder> Info;
92  std::unique_ptr<DbiStreamBuilder> Dbi;
93  std::unique_ptr<GSIStreamBuilder> Gsi;
94  std::unique_ptr<TpiStreamBuilder> Tpi;
95  std::unique_ptr<TpiStreamBuilder> Ipi;
96 
97  PDBStringTableBuilder Strings;
98  StringTableHashTraits InjectedSourceHashTraits;
100 
102 
103  NamedStreamMap NamedStreams;
104  DenseMap<uint32_t, std::string> NamedStreamData;
105 };
106 }
107 }
108 
109 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
static void commitFpm(WritableBinaryStream &MsfBuffer, const MSFLayout &Layout, BumpPtrAllocator &Allocator)
Definition: MSFBuilder.cpp:314
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:140
static const int BlockSize
Definition: TarWriter.cpp:34
Basic Register Allocator
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringRef > StandardNames)
Initialize the set of available library functions based on the specified target triple.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
A BinaryStream which can be read from as well as written to.
Definition: BinaryStream.h:74