Home | History | Annotate | Download | only in Native
      1 //===- PDBFileBuilder.h - PDB File 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_PDBFILEBUILDER_H
     11 #define LLVM_DEBUGINFO_PDB_RAW_PDBFILEBUILDER_H
     12 
     13 #include "llvm/ADT/ArrayRef.h"
     14 #include "llvm/ADT/BitVector.h"
     15 #include "llvm/ADT/Optional.h"
     16 #include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h"
     17 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
     18 #include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
     19 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
     20 #include "llvm/Support/Allocator.h"
     21 #include "llvm/Support/Endian.h"
     22 #include "llvm/Support/Error.h"
     23 
     24 #include <memory>
     25 #include <vector>
     26 
     27 namespace llvm {
     28 namespace msf {
     29 class MSFBuilder;
     30 }
     31 namespace pdb {
     32 class DbiStreamBuilder;
     33 class InfoStreamBuilder;
     34 class TpiStreamBuilder;
     35 
     36 class PDBFileBuilder {
     37 public:
     38   explicit PDBFileBuilder(BumpPtrAllocator &Allocator);
     39   PDBFileBuilder(const PDBFileBuilder &) = delete;
     40   PDBFileBuilder &operator=(const PDBFileBuilder &) = delete;
     41 
     42   Error initialize(uint32_t BlockSize);
     43 
     44   msf::MSFBuilder &getMsfBuilder();
     45   InfoStreamBuilder &getInfoBuilder();
     46   DbiStreamBuilder &getDbiBuilder();
     47   TpiStreamBuilder &getTpiBuilder();
     48   TpiStreamBuilder &getIpiBuilder();
     49   PDBStringTableBuilder &getStringTableBuilder();
     50 
     51   Error commit(StringRef Filename);
     52 
     53   Expected<uint32_t> getNamedStreamIndex(StringRef Name) const;
     54   Error addNamedStream(StringRef Name, uint32_t Size);
     55 
     56 private:
     57   Expected<msf::MSFLayout> finalizeMsfLayout();
     58 
     59   BumpPtrAllocator &Allocator;
     60 
     61   std::unique_ptr<msf::MSFBuilder> Msf;
     62   std::unique_ptr<InfoStreamBuilder> Info;
     63   std::unique_ptr<DbiStreamBuilder> Dbi;
     64   std::unique_ptr<TpiStreamBuilder> Tpi;
     65   std::unique_ptr<TpiStreamBuilder> Ipi;
     66 
     67   PDBStringTableBuilder Strings;
     68   NamedStreamMap NamedStreams;
     69 };
     70 }
     71 }
     72 
     73 #endif
     74