LLVM  8.0.1
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);
51  void setObjFileName(StringRef Name);
52  void setFirstSectionContrib(const SectionContrib &SC);
53  void addSymbol(codeview::CVSymbol Symbol);
54  void addSymbolsInBulk(ArrayRef<uint8_t> BulkSymbols);
55 
56  void
57  addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection);
58 
59  void
60  addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents);
61 
62  uint16_t getStreamIndex() const;
63  StringRef getModuleName() const { return ModuleName; }
64  StringRef getObjFileName() const { return ObjFileName; }
65 
66  unsigned getModuleIndex() const { return Layout.Mod; }
67 
69  return makeArrayRef(SourceFiles);
70  }
71 
72  uint32_t calculateSerializedLength() const;
73 
74  /// Return the offset within the module symbol stream of the next symbol
75  /// record passed to addSymbol. Add four to account for the signature.
76  uint32_t getNextSymbolOffset() const { return SymbolByteSize + 4; }
77 
78  void finalize();
79  Error finalizeMsfLayout();
80 
81  Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout,
82  WritableBinaryStreamRef MsfBuffer);
83 
84 private:
85  uint32_t calculateC13DebugInfoSize() const;
86 
87  void addSourceFile(StringRef Path);
88  msf::MSFBuilder &MSF;
89 
90  uint32_t SymbolByteSize = 0;
91  uint32_t PdbFilePathNI = 0;
92  std::string ModuleName;
93  std::string ObjFileName;
94  std::vector<std::string> SourceFiles;
95  std::vector<ArrayRef<uint8_t>> Symbols;
96 
97  std::vector<std::unique_ptr<codeview::DebugSubsectionRecordBuilder>>
98  C13Builders;
99 
100  ModuleInfoHeader Layout;
101 };
102 
103 } // end namespace pdb
104 
105 } // end namespace llvm
106 
107 #endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
arc branch finalize
amdgpu Simplify well known AMD library false Value Value const Twine & Name
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
ArrayRef< std::string > source_files() const
The header preceeding each entry in the Module Info substream of the DBI stream.
Definition: RawTypes.h:213
Provides write only access to a subclass of WritableBinaryStream.
CHAIN = SC CHAIN, Imm128 - System call.
uint32_t getNextSymbolOffset() const
Return the offset within the module symbol stream of the next symbol record passed to addSymbol...
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