LLVM  5.0.0
DbiModuleDescriptorBuilder.h
Go to the documentation of this file.
1 //===- DbiModuleDescriptorBuilder.h - PDB module information ----*- 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_DBIMODULEDESCRIPTORBUILDER_H
11 #define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
12 
13 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/Error.h"
21 #include <cstdint>
22 #include <string>
23 #include <vector>
24 
25 namespace llvm {
26 class BinaryStreamWriter;
27 
28 namespace codeview {
29 class DebugSubsectionRecordBuilder;
30 }
31 
32 namespace msf {
33 class MSFBuilder;
34 struct MSFLayout;
35 }
36 namespace pdb {
37 
39  friend class DbiStreamBuilder;
40 
41 public:
42  DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex,
43  msf::MSFBuilder &Msf);
45 
48  operator=(const DbiModuleDescriptorBuilder &) = delete;
49 
50  void setPdbFilePathNI(uint32_t NI);
53 
54  void
55  addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection);
56 
57  void
58  addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents);
59 
60  uint16_t getStreamIndex() const;
61  StringRef getModuleName() const { return ModuleName; }
62  StringRef getObjFileName() const { return ObjFileName; }
63 
64  unsigned getModuleIndex() const { return Layout.Mod; }
65 
67  return makeArrayRef(SourceFiles);
68  }
69 
71 
72  /// Return the offset within the module symbol stream of the next symbol
73  /// record passed to addSymbol. Add four to account for the signature.
74  uint32_t getNextSymbolOffset() const { return SymbolByteSize + 4; }
75 
76  void finalize();
78 
79  Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout,
80  WritableBinaryStreamRef MsfBuffer);
81 
82 private:
83  uint32_t calculateC13DebugInfoSize() const;
84 
85  void addSourceFile(StringRef Path);
86  msf::MSFBuilder &MSF;
87 
88  uint32_t SymbolByteSize = 0;
89  uint32_t PdbFilePathNI = 0;
90  std::string ModuleName;
91  std::string ObjFileName;
92  std::vector<std::string> SourceFiles;
93  std::vector<codeview::CVSymbol> Symbols;
94 
95  std::vector<std::unique_ptr<codeview::DebugSubsectionRecordBuilder>>
96  C13Builders;
97 
98  ModuleInfoHeader Layout;
99 };
100 
101 } // end namespace pdb
102 
103 } // end namespace llvm
104 
105 #endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, msf::MSFBuilder &Msf)
Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer)
DbiModuleDescriptorBuilder & operator=(const DbiModuleDescriptorBuilder &)=delete
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
const char * Name
The header preceeding each entry in the Module Info substream of the DBI stream.
Definition: RawTypes.h:209
Provides write only access to a subclass of WritableBinaryStream.
support::ulittle32_t Mod
Currently opened module.
Definition: RawTypes.h:214
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
uint32_t getNextSymbolOffset() const
Return the offset within the module symbol stream of the next symbol record passed to addSymbol...
void addDebugSubsection(std::shared_ptr< codeview::DebugSubsection > Subsection)
ArrayRef< std::string > source_files() const