LLVM  4.0.0
DbiStreamBuilder.h
Go to the documentation of this file.
1 //===- DbiStreamBuilder.h - PDB Dbi Stream 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_PDBDBISTREAMBUILDER_H
11 #define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAMBUILDER_H
12 
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/StringSet.h"
15 #include "llvm/Support/Error.h"
16 
22 #include "llvm/Support/Endian.h"
23 
24 namespace llvm {
25 namespace msf {
26 class MSFBuilder;
27 }
28 namespace object {
29 struct coff_section;
30 }
31 namespace pdb {
32 class DbiStream;
33 struct DbiStreamHeader;
34 class PDBFile;
35 
37 public:
39 
40  DbiStreamBuilder(const DbiStreamBuilder &) = delete;
41  DbiStreamBuilder &operator=(const DbiStreamBuilder &) = delete;
42 
44  void setAge(uint32_t A);
45  void setBuildNumber(uint16_t B);
46  void setPdbDllVersion(uint16_t V);
47  void setPdbDllRbld(uint16_t R);
48  void setFlags(uint16_t F);
52 
53  // Add given bytes as a new stream.
55 
57 
60 
62 
63  Error commit(const msf::MSFLayout &Layout,
64  const msf::WritableStream &Buffer);
65 
66  // A helper function to create Section Contributions from COFF input
67  // section headers.
68  static std::vector<SectionContrib>
70 
71  // A helper function to create a Section Map from a COFF section header.
72  static std::vector<SecMapEntry>
74 
75 private:
76  struct DebugStream {
78  uint16_t StreamNumber = 0;
79  };
80 
81  Error finalize();
82  uint32_t calculateModiSubstreamSize() const;
83  uint32_t calculateSectionContribsStreamSize() const;
84  uint32_t calculateSectionMapStreamSize() const;
85  uint32_t calculateFileInfoSubstreamSize() const;
86  uint32_t calculateNamesBufferSize() const;
87  uint32_t calculateDbgStreamsSize() const;
88 
89  Error generateModiSubstream();
90  Error generateFileInfoSubstream();
91 
92  struct ModuleInfo {
93  std::vector<StringRef> SourceFiles;
94  StringRef Obj;
95  StringRef Mod;
96  };
97 
98  msf::MSFBuilder &Msf;
99  BumpPtrAllocator &Allocator;
100 
101  Optional<PdbRaw_DbiVer> VerHeader;
102  uint32_t Age;
103  uint16_t BuildNumber;
104  uint16_t PdbDllVersion;
105  uint16_t PdbDllRbld;
106  uint16_t Flags;
107  PDB_Machine MachineType;
108 
109  const DbiStreamHeader *Header;
110 
112  std::vector<ModuleInfo *> ModuleInfoList;
113 
114  StringMap<uint32_t> SourceFileNames;
115 
116  msf::WritableStreamRef NamesBuffer;
117  msf::MutableByteStream ModInfoBuffer;
118  msf::MutableByteStream FileInfoBuffer;
119  ArrayRef<SectionContrib> SectionContribs;
120  ArrayRef<SecMapEntry> SectionMap;
122 };
123 }
124 }
125 
126 #endif
uint32_t calculateSerializedLength() const
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
void setSectionMap(ArrayRef< SecMapEntry > SecMap)
void setMachineType(PDB_Machine M)
static std::vector< SecMapEntry > createSectionMap(ArrayRef< llvm::object::coff_section > SecHdrs)
The fixed size header that appears at the beginning of the DBI Stream.
Definition: RawTypes.h:110
#define F(x, y, z)
Definition: MD5.cpp:51
Error addDbgStream(pdb::DbgHeaderType Type, ArrayRef< uint8_t > Data)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
Error commit(const msf::MSFLayout &Layout, const msf::WritableStream &Buffer)
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
DbiStreamBuilder & operator=(const DbiStreamBuilder &)=delete
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
void setVersionHeader(PdbRaw_DbiVer V)
static std::vector< SectionContrib > createSectionContribs(ArrayRef< llvm::object::coff_section > SecHdrs)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:223
Error addModuleSourceFile(StringRef Module, StringRef File)
void setSectionContribs(ArrayRef< SectionContrib > SecMap)
Error addModuleInfo(StringRef ObjFile, StringRef Module)
DbiStreamBuilder(msf::MSFBuilder &Msf)
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")