29    : Msf(Msf), Allocator(Msf.getAllocator()), Age(1), BuildNumber(0),
 
   30      PdbDllVersion(0), PdbDllRbld(0), Flags(0), MachineType(
PDB_Machine::
x86),
 
 
   63  GlobalsStreamIndex = Index;
 
 
   67  SymRecordStreamIndex = Index;
 
 
   71  PublicsStreamIndex = Index;
 
 
   76    NewFpoData.emplace(
false);
 
   78  NewFpoData->addFrameData(FD);
 
 
   82  OldFpoData.push_back(FD);
 
 
   88         "NewFPO data should be written via addFrameData()!");
 
   90  DbgStreams[(int)
Type] = DebugStream{};
 
 
   99  return ECNamesBuilder.insert(Name);
 
 
  105         calculateModiSubstreamSize() + calculateSectionContribsStreamSize() +
 
  106         calculateSectionMapStreamSize() + calculateDbgStreamsSize() +
 
  107         ECNamesBuilder.calculateSerializedSize();
 
 
  114      std::make_unique<DbiModuleDescriptorBuilder>(
ModuleName, Index, Msf));
 
  115  return *ModiList.back();
 
 
  120  uint32_t Index = SourceFileNames.size();
 
  121  SourceFileNames.insert(std::make_pair(File, Index));
 
  122  Module.addSourceFile(File);
 
 
  127  auto NameIter = SourceFileNames.find(File);
 
  128  if (NameIter == SourceFileNames.end())
 
  130                                "The specified source file was not found");
 
  131  return NameIter->getValue();
 
 
  134uint32_t DbiStreamBuilder::calculateModiSubstreamSize()
 const {
 
  136  for (
const auto &M : ModiList)
 
  137    Size += M->calculateSerializedLength();
 
  141uint32_t DbiStreamBuilder::calculateSectionContribsStreamSize()
 const {
 
  148uint32_t DbiStreamBuilder::calculateSectionMapStreamSize()
 const {
 
  149  if (SectionMap.empty())
 
  154uint32_t DbiStreamBuilder::calculateNamesOffset()
 const {
 
  160  uint32_t NumFileInfos = 0;
 
  161  for (
const auto &M : ModiList)
 
  162    NumFileInfos += 
M->source_files().size();
 
  167uint32_t DbiStreamBuilder::calculateFileInfoSubstreamSize()
 const {
 
  168  uint32_t 
Size = calculateNamesOffset();
 
  169  Size += calculateNamesBufferSize();
 
  173uint32_t DbiStreamBuilder::calculateNamesBufferSize()
 const {
 
  175  for (
const auto &
F : SourceFileNames) {
 
  176    Size += 
F.getKeyLength() + 1; 
 
  181uint32_t DbiStreamBuilder::calculateDbgStreamsSize()
 const {
 
  182  return DbgStreams.size() * 
sizeof(uint16_t);
 
  185Error DbiStreamBuilder::generateFileInfoSubstream() {
 
  186  uint32_t 
Size = calculateFileInfoSubstreamSize();
 
  187  auto Data = Allocator.Allocate<uint8_t>(
Size);
 
  188  uint32_t NamesOffset = calculateNamesOffset();
 
  190  FileInfoBuffer = MutableBinaryByteStream(MutableArrayRef<uint8_t>(
Data, 
Size),
 
  193  WritableBinaryStreamRef MetadataBuffer =
 
  194      WritableBinaryStreamRef(FileInfoBuffer).keep_front(NamesOffset);
 
  195  BinaryStreamWriter MetadataWriter(MetadataBuffer);
 
  197  uint16_t ModiCount = std::min<uint32_t>(UINT16_MAX, ModiList.size());
 
  198  uint16_t FileCount = std::min<uint32_t>(UINT16_MAX, SourceFileNames.size());
 
  199  if (
auto EC = MetadataWriter.writeInteger(ModiCount)) 
 
  201  if (
auto EC = MetadataWriter.writeInteger(FileCount)) 
 
  203  for (uint16_t 
I = 0; 
I < ModiCount; ++
I) {
 
  204    if (
auto EC = MetadataWriter.writeInteger(
I)) 
 
  207  for (
const auto &
MI : ModiList) {
 
  208    FileCount = 
static_cast<uint16_t
>(
MI->source_files().
size());
 
  209    if (
auto EC = MetadataWriter.writeInteger(FileCount)) 
 
  217  NamesBuffer = WritableBinaryStreamRef(FileInfoBuffer).drop_front(NamesOffset);
 
  218  BinaryStreamWriter NameBufferWriter(NamesBuffer);
 
  219  for (
auto &Name : SourceFileNames) {
 
  220    Name.second = NameBufferWriter.getOffset();
 
  221    if (
auto EC = NameBufferWriter.writeCString(
Name.getKey()))
 
  225  for (
const auto &
MI : ModiList) {
 
  226    for (StringRef Name : 
MI->source_files()) {
 
  227      auto Result = SourceFileNames.find(Name);
 
  228      if (Result == SourceFileNames.end())
 
  230                                    "The source file was not found.");
 
  231      if (
auto EC = MetadataWriter.writeInteger(
Result->second))
 
  236  if (
auto EC = NameBufferWriter.padToAlignment(
sizeof(uint32_t)))
 
  239  if (NameBufferWriter.bytesRemaining() > 0)
 
  241                                "The names buffer contained unexpected data.");
 
  243  if (MetadataWriter.bytesRemaining() > 
sizeof(uint32_t))
 
  246        "The metadata buffer contained unexpected data.");
 
  251Error DbiStreamBuilder::finalize() {
 
  255  for (
auto &
MI : ModiList)
 
  258  if (
auto EC = generateFileInfoSubstream())
 
  261  DbiStreamHeader *
H = Allocator.Allocate<DbiStreamHeader>();
 
  262  ::memset(
H, 0, 
sizeof(DbiStreamHeader));
 
  263  H->VersionHeader = *VerHeader;
 
  264  H->VersionSignature = -1;
 
  266  H->BuildNumber = BuildNumber;
 
  268  H->PdbDllRbld = PdbDllRbld;
 
  269  H->PdbDllVersion = PdbDllVersion;
 
  270  H->MachineType = 
static_cast<uint16_t
>(MachineType);
 
  272  H->ECSubstreamSize = ECNamesBuilder.calculateSerializedSize();
 
  273  H->FileInfoSize = FileInfoBuffer.getLength();
 
  274  H->ModiSubstreamSize = calculateModiSubstreamSize();
 
  275  H->OptionalDbgHdrSize = DbgStreams.size() * 
sizeof(uint16_t);
 
  276  H->SecContrSubstreamSize = calculateSectionContribsStreamSize();
 
  277  H->SectionMapSize = calculateSectionMapStreamSize();
 
  278  H->TypeServerSize = 0;
 
  279  H->SymRecordStreamIndex = SymRecordStreamIndex;
 
  280  H->PublicSymbolStreamIndex = PublicsStreamIndex;
 
  281  H->MFCTypeServerIndex = 0; 
 
  282  H->GlobalSymbolStreamIndex = GlobalsStreamIndex;
 
  292        NewFpoData->calculateSerializedSize();
 
  295          return NewFpoData->commit(Writer);
 
  299  if (!OldFpoData.empty()) {
 
  309  for (
auto &S : DbgStreams) {
 
  312    auto ExpectedIndex = Msf.addStream(S->Size);
 
  314      return ExpectedIndex.takeError();
 
  315    S->StreamNumber = *ExpectedIndex;
 
  318  for (
auto &
MI : ModiList) {
 
  319    if (
auto EC = 
MI->finalizeMsfLayout())
 
 
  356    SectionMap.emplace_back();
 
  357    auto &Entry = SectionMap.back();
 
  358    memset(&Entry, 0, 
sizeof(Entry));
 
  360    Entry.Frame = Idx + 1;
 
  363    Entry.SecName = UINT16_MAX;
 
  364    Entry.ClassName = UINT16_MAX;
 
  369  for (
auto &Hdr : SecHdrs) {
 
  372    Entry.SecByteLength = Hdr.VirtualSize;
 
  380  Entry.SecByteLength = UINT32_MAX;
 
 
  390      Layout, MsfBuffer, 
StreamDBI, Allocator);
 
  396  for (
auto &M : ModiList) {
 
  397    if (
auto EC = M->commit(Writer))
 
  403          ModiList, [&](std::unique_ptr<DbiModuleDescriptorBuilder> &M) {
 
  404            return M->commitSymbolStream(Layout, MsfBuffer);
 
  408  if (!SectionContribs.empty()) {
 
  415  if (!SectionMap.empty()) {
 
  427  if (
auto EC = ECNamesBuilder.commit(Writer))
 
  430  for (
auto &Stream : DbgStreams) {
 
  433      StreamNumber = Stream->StreamNumber;
 
  438  for (
auto &Stream : DbgStreams) {
 
  444        Layout, MsfBuffer, Stream->StreamNumber, Allocator);
 
  447    if (
auto EC = Stream->WriteFn(DbgStreamWriter))
 
  453                                "Unexpected bytes found in DBI Stream");
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
 
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
 
static uint16_t toSecMapFlags(uint32_t Flags)
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
Provides write only access to a subclass of WritableBinaryStream.
 
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
 
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
 
uint64_t bytesRemaining() const
 
LLVM_ABI Error writeStreamRef(BinaryStreamRef Ref)
Efficiently reads all data from Ref, and writes it to this stream.
 
Error writeEnum(T Num)
Similar to writeInteger.
 
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
 
Lightweight error class with error context and mandatory checking.
 
static ErrorSuccess success()
Create a success value.
 
Tagged union holding either a T or a Error.
 
A Module instance is used to store all the information related to an LLVM module.
 
StringRef - Represent a constant reference to a string, i.e.
 
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
 
static std::unique_ptr< WritableMappedBlockStream > createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
 
LLVM_ABI void createSectionMap(ArrayRef< llvm::object::coff_section > SecHdrs)
 
LLVM_ABI void addOldFpoData(const object::FpoData &Fpo)
 
LLVM_ABI void setPublicsStreamIndex(uint32_t Index)
 
LLVM_ABI void setFlags(uint16_t F)
 
LLVM_ABI Error addModuleSourceFile(DbiModuleDescriptorBuilder &Module, StringRef File)
 
LLVM_ABI ~DbiStreamBuilder()
 
LLVM_ABI void setAge(uint32_t A)
 
LLVM_ABI void setGlobalsStreamIndex(uint32_t Index)
 
LLVM_ABI Expected< uint32_t > getSourceFileNameIndex(StringRef FileName)
 
LLVM_ABI Error finalizeMsfLayout()
 
LLVM_ABI void setSymbolRecordStreamIndex(uint32_t Index)
 
LLVM_ABI void addNewFpoData(const codeview::FrameData &FD)
 
LLVM_ABI void setVersionHeader(PdbRaw_DbiVer V)
 
LLVM_ABI Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef MsfBuffer)
 
LLVM_ABI Expected< DbiModuleDescriptorBuilder & > addModuleInfo(StringRef ModuleName)
 
LLVM_ABI uint32_t calculateSerializedLength() const
 
LLVM_ABI Error addDbgStream(pdb::DbgHeaderType Type, ArrayRef< uint8_t > Data)
 
LLVM_ABI uint32_t addECName(StringRef Name)
 
LLVM_ABI void setBuildNumber(uint16_t B)
 
LLVM_ABI void setPdbDllVersion(uint16_t V)
 
LLVM_ABI void setMachineType(PDB_Machine M)
 
LLVM_ABI void setPdbDllRbld(uint16_t R)
 
LLVM_ABI DbiStreamBuilder(msf::MSFBuilder &Msf)
 
const uint16_t kInvalidStreamIndex
 
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
 
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
 
This is an optimization pass for GlobalISel generic memory operations.
 
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
 
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
 
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
 
ArrayRef(const T &OneElt) -> ArrayRef< T >
 
Error parallelForEachError(RangeTy &&R, FuncTy Fn)
 
Data in the SUBSEC_FRAMEDATA subection.
 
static const uint16_t BuildMajorShift
 
static const uint16_t NewVersionFormatMask
 
static const uint16_t BuildMajorMask
 
static const uint16_t BuildMinorMask
uint16_t MinorVersion : 8; uint16_t MajorVersion : 7; uint16_t NewVersionFormat : 1;
 
static const uint16_t BuildMinorShift