Zachary Turner | 67c5601 | 2017-04-27 16:11:19 +0000 | [diff] [blame] | 1 | //===- DbiModuleDescriptor.cpp - PDB module information -------------------===// |
| 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 | #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" |
| 11 | #include "llvm/DebugInfo/PDB/Native/RawTypes.h" |
| 12 | #include "llvm/Support/BinaryStreamReader.h" |
| 13 | #include "llvm/Support/Endian.h" |
| 14 | #include "llvm/Support/Error.h" |
| 15 | #include "llvm/Support/MathExtras.h" |
| 16 | #include <cstdint> |
| 17 | |
| 18 | using namespace llvm; |
| 19 | using namespace llvm::pdb; |
| 20 | using namespace llvm::support; |
| 21 | |
| 22 | DbiModuleDescriptor::DbiModuleDescriptor() = default; |
| 23 | |
| 24 | DbiModuleDescriptor::DbiModuleDescriptor(const DbiModuleDescriptor &Info) = |
| 25 | default; |
| 26 | |
| 27 | DbiModuleDescriptor::~DbiModuleDescriptor() = default; |
| 28 | |
| 29 | Error DbiModuleDescriptor::initialize(BinaryStreamRef Stream, |
| 30 | DbiModuleDescriptor &Info) { |
| 31 | BinaryStreamReader Reader(Stream); |
| 32 | if (auto EC = Reader.readObject(Info.Layout)) |
| 33 | return EC; |
| 34 | |
| 35 | if (auto EC = Reader.readCString(Info.ModuleName)) |
| 36 | return EC; |
| 37 | |
| 38 | if (auto EC = Reader.readCString(Info.ObjFileName)) |
| 39 | return EC; |
| 40 | return Error::success(); |
| 41 | } |
| 42 | |
| 43 | bool DbiModuleDescriptor::hasECInfo() const { |
| 44 | return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0; |
| 45 | } |
| 46 | |
| 47 | uint16_t DbiModuleDescriptor::getTypeServerIndex() const { |
| 48 | return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >> |
| 49 | ModInfoFlags::TypeServerIndexShift; |
| 50 | } |
| 51 | |
Zachary Turner | bee6c22 | 2018-04-17 20:06:43 +0000 | [diff] [blame] | 52 | const SectionContrib &DbiModuleDescriptor::getSectionContrib() const { |
| 53 | return Layout->SC; |
| 54 | } |
| 55 | |
Zachary Turner | 67c5601 | 2017-04-27 16:11:19 +0000 | [diff] [blame] | 56 | uint16_t DbiModuleDescriptor::getModuleStreamIndex() const { |
| 57 | return Layout->ModDiStream; |
| 58 | } |
| 59 | |
| 60 | uint32_t DbiModuleDescriptor::getSymbolDebugInfoByteSize() const { |
| 61 | return Layout->SymBytes; |
| 62 | } |
| 63 | |
Zachary Turner | 5b6e4e0 | 2017-04-29 01:13:21 +0000 | [diff] [blame] | 64 | uint32_t DbiModuleDescriptor::getC11LineInfoByteSize() const { |
| 65 | return Layout->C11Bytes; |
Zachary Turner | 67c5601 | 2017-04-27 16:11:19 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | uint32_t DbiModuleDescriptor::getC13LineInfoByteSize() const { |
| 69 | return Layout->C13Bytes; |
| 70 | } |
| 71 | |
| 72 | uint32_t DbiModuleDescriptor::getNumberOfFiles() const { |
| 73 | return Layout->NumFiles; |
| 74 | } |
| 75 | |
| 76 | uint32_t DbiModuleDescriptor::getSourceFileNameIndex() const { |
| 77 | return Layout->SrcFileNameNI; |
| 78 | } |
| 79 | |
| 80 | uint32_t DbiModuleDescriptor::getPdbFilePathNameIndex() const { |
| 81 | return Layout->PdbFilePathNI; |
| 82 | } |
| 83 | |
| 84 | StringRef DbiModuleDescriptor::getModuleName() const { return ModuleName; } |
| 85 | |
| 86 | StringRef DbiModuleDescriptor::getObjFileName() const { return ObjFileName; } |
| 87 | |
| 88 | uint32_t DbiModuleDescriptor::getRecordLength() const { |
| 89 | uint32_t M = ModuleName.str().size() + 1; |
| 90 | uint32_t O = ObjFileName.str().size() + 1; |
| 91 | uint32_t Size = sizeof(ModuleInfoHeader) + M + O; |
| 92 | Size = alignTo(Size, 4); |
| 93 | return Size; |
| 94 | } |