1 //===- DbiModuleDescriptorBuilder.h - PDB module information ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
11 #define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
15 #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
16 #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
17 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
18 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
19 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
20 #include "llvm/Support/Error.h"
26 class BinaryStreamWriter;
29 class DebugSubsectionRecordBuilder;
38 class DbiModuleDescriptorBuilder {
39 friend class DbiStreamBuilder;
42 DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex,
43 msf::MSFBuilder &Msf);
44 ~DbiModuleDescriptorBuilder();
46 DbiModuleDescriptorBuilder(const DbiModuleDescriptorBuilder &) = delete;
47 DbiModuleDescriptorBuilder &
48 operator=(const DbiModuleDescriptorBuilder &) = delete;
50 void setPdbFilePathNI(uint32_t NI);
51 void setObjFileName(StringRef Name);
52 void addSymbol(codeview::CVSymbol Symbol);
55 addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection);
58 addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents);
60 uint16_t getStreamIndex() const;
61 StringRef getModuleName() const { return ModuleName; }
62 StringRef getObjFileName() const { return ObjFileName; }
64 unsigned getModuleIndex() const { return Layout.Mod; }
66 ArrayRef<std::string> source_files() const {
67 return makeArrayRef(SourceFiles);
70 uint32_t calculateSerializedLength() const;
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; }
77 Error finalizeMsfLayout();
79 Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout,
80 WritableBinaryStreamRef MsfBuffer);
83 uint32_t calculateC13DebugInfoSize() const;
85 void addSourceFile(StringRef Path);
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;
95 std::vector<std::unique_ptr<codeview::DebugSubsectionRecordBuilder>>
98 ModuleInfoHeader Layout;
101 } // end namespace pdb
103 } // end namespace llvm
105 #endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H