LLVM  8.0.1
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  // If HashPDBContentsToGUID is true on the InfoStreamBuilder, Guid is filled
57  // with the computed PDB GUID on return.
58  Error commit(StringRef Filename, codeview::GUID *Guid);
59 
60  Expected<uint32_t> getNamedStreamIndex(StringRef Name) const;
61  Error addNamedStream(StringRef Name, StringRef Data);
62  void addInjectedSource(StringRef Name, std::unique_ptr<MemoryBuffer> Buffer);
63 
64 private:
65  struct InjectedSourceDescriptor {
66  // The full name of the stream that contains the contents of this injected
67  // source. This is built as a concatenation of the literal "/src/files"
68  // plus the "vname".
69  std::string StreamName;
70 
71  // The exact name of the file name as specified by the user.
72  uint32_t NameIndex;
73 
74  // The string table index of the "vname" of the file. As far as we
75  // understand, this is the same as the name, except it is lowercased and
76  // forward slashes are converted to backslashes.
77  uint32_t VNameIndex;
78  std::unique_ptr<MemoryBuffer> Content;
79  };
80 
81  Error finalizeMsfLayout();
82  Expected<uint32_t> allocateNamedStream(StringRef Name, uint32_t Size);
83 
84  void commitFpm(WritableBinaryStream &MsfBuffer, const msf::MSFLayout &Layout);
85  void commitInjectedSources(WritableBinaryStream &MsfBuffer,
86  const msf::MSFLayout &Layout);
87  void commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer,
88  const msf::MSFLayout &Layout);
89 
91 
92  std::unique_ptr<msf::MSFBuilder> Msf;
93  std::unique_ptr<InfoStreamBuilder> Info;
94  std::unique_ptr<DbiStreamBuilder> Dbi;
95  std::unique_ptr<GSIStreamBuilder> Gsi;
96  std::unique_ptr<TpiStreamBuilder> Tpi;
97  std::unique_ptr<TpiStreamBuilder> Ipi;
98 
99  PDBStringTableBuilder Strings;
100  StringTableHashTraits InjectedSourceHashTraits;
102 
104 
105  NamedStreamMap NamedStreams;
106  DenseMap<uint32_t, std::string> NamedStreamData;
107 };
108 }
109 }
110 
111 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
This represents the &#39;GUID&#39; type from windows.h.
Definition: GUID.h:22
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
Analysis containing CSE Info
Definition: CSEInfo.cpp:21
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:141
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.
uint32_t Size
Definition: Profile.cpp:47
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
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