LLVM  10.0.0svn
DbiModuleDescriptorBuilder.h
Go to the documentation of this file.
1 //===- DbiModuleDescriptorBuilder.h - PDB module information ----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
10 #define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
11 
12 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/Error.h"
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23 
24 namespace llvm {
25 class BinaryStreamWriter;
26 
27 namespace codeview {
28 class DebugSubsectionRecordBuilder;
29 }
30 
31 namespace msf {
32 class MSFBuilder;
33 struct MSFLayout;
34 }
35 namespace pdb {
36 
38  friend class DbiStreamBuilder;
39 
40 public:
41  DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex,
42  msf::MSFBuilder &Msf);
44 
47  operator=(const DbiModuleDescriptorBuilder &) = delete;
48 
49  void setPdbFilePathNI(uint32_t NI);
50  void setObjFileName(StringRef Name);
51  void setFirstSectionContrib(const SectionContrib &SC);
52  void addSymbol(codeview::CVSymbol Symbol);
53  void addSymbolsInBulk(ArrayRef<uint8_t> BulkSymbols);
54 
55  void
56  addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection);
57 
58  void
59  addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents);
60 
61  uint16_t getStreamIndex() const;
62  StringRef getModuleName() const { return ModuleName; }
63  StringRef getObjFileName() const { return ObjFileName; }
64 
65  unsigned getModuleIndex() const { return Layout.Mod; }
66 
68  return makeArrayRef(SourceFiles);
69  }
70 
71  uint32_t calculateSerializedLength() const;
72 
73  /// Return the offset within the module symbol stream of the next symbol
74  /// record passed to addSymbol. Add four to account for the signature.
75  uint32_t getNextSymbolOffset() const { return SymbolByteSize + 4; }
76 
77  void finalize();
78  Error finalizeMsfLayout();
79 
80  Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout,
81  WritableBinaryStreamRef MsfBuffer);
82 
83 private:
84  uint32_t calculateC13DebugInfoSize() const;
85 
86  void addSourceFile(StringRef Path);
87  msf::MSFBuilder &MSF;
88 
89  uint32_t SymbolByteSize = 0;
90  uint32_t PdbFilePathNI = 0;
91  std::string ModuleName;
92  std::string ObjFileName;
93  std::vector<std::string> SourceFiles;
94  std::vector<ArrayRef<uint8_t>> Symbols;
95 
96  std::vector<std::unique_ptr<codeview::DebugSubsectionRecordBuilder>>
97  C13Builders;
98 
99  ModuleInfoHeader Layout;
100 };
101 
102 } // end namespace pdb
103 
104 } // end namespace llvm
105 
106 #endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
arc branch finalize
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:450
ArrayRef< std::string > source_files() const
The header preceding each entry in the Module Info substream of the DBI stream.
Definition: RawTypes.h:212
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:157
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:30