1 //===- DbiModuleDescriptor.cpp - PDB module information -------------------===// 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 #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" 10 #include "llvm/DebugInfo/PDB/Native/RawTypes.h" 11 #include "llvm/Support/BinaryStreamReader.h" 12 #include "llvm/Support/Endian.h" 13 #include "llvm/Support/Error.h" 14 #include "llvm/Support/MathExtras.h" 15 #include <cstdint> 16 17 using namespace llvm; 18 using namespace llvm::pdb; 19 using namespace llvm::support; 20 initialize(BinaryStreamRef Stream,DbiModuleDescriptor & Info)21Error DbiModuleDescriptor::initialize(BinaryStreamRef Stream, 22 DbiModuleDescriptor &Info) { 23 BinaryStreamReader Reader(Stream); 24 if (auto EC = Reader.readObject(Info.Layout)) 25 return EC; 26 27 if (auto EC = Reader.readCString(Info.ModuleName)) 28 return EC; 29 30 if (auto EC = Reader.readCString(Info.ObjFileName)) 31 return EC; 32 return Error::success(); 33 } 34 hasECInfo() const35bool DbiModuleDescriptor::hasECInfo() const { 36 return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0; 37 } 38 getTypeServerIndex() const39uint16_t DbiModuleDescriptor::getTypeServerIndex() const { 40 return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >> 41 ModInfoFlags::TypeServerIndexShift; 42 } 43 getSectionContrib() const44const SectionContrib &DbiModuleDescriptor::getSectionContrib() const { 45 return Layout->SC; 46 } 47 getModuleStreamIndex() const48uint16_t DbiModuleDescriptor::getModuleStreamIndex() const { 49 return Layout->ModDiStream; 50 } 51 getSymbolDebugInfoByteSize() const52uint32_t DbiModuleDescriptor::getSymbolDebugInfoByteSize() const { 53 return Layout->SymBytes; 54 } 55 getC11LineInfoByteSize() const56uint32_t DbiModuleDescriptor::getC11LineInfoByteSize() const { 57 return Layout->C11Bytes; 58 } 59 getC13LineInfoByteSize() const60uint32_t DbiModuleDescriptor::getC13LineInfoByteSize() const { 61 return Layout->C13Bytes; 62 } 63 getNumberOfFiles() const64uint32_t DbiModuleDescriptor::getNumberOfFiles() const { 65 return Layout->NumFiles; 66 } 67 getSourceFileNameIndex() const68uint32_t DbiModuleDescriptor::getSourceFileNameIndex() const { 69 return Layout->SrcFileNameNI; 70 } 71 getPdbFilePathNameIndex() const72uint32_t DbiModuleDescriptor::getPdbFilePathNameIndex() const { 73 return Layout->PdbFilePathNI; 74 } 75 getModuleName() const76StringRef DbiModuleDescriptor::getModuleName() const { return ModuleName; } 77 getObjFileName() const78StringRef DbiModuleDescriptor::getObjFileName() const { return ObjFileName; } 79 getRecordLength() const80uint32_t DbiModuleDescriptor::getRecordLength() const { 81 uint32_t M = ModuleName.str().size() + 1; 82 uint32_t O = ObjFileName.str().size() + 1; 83 uint32_t Size = sizeof(ModuleInfoHeader) + M + O; 84 Size = alignTo(Size, 4); 85 return Size; 86 } 87