1 //===- DbiModuleDescriptor.cpp - PDB module information -------------------===//
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 #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"
19 using namespace llvm::pdb;
20 using namespace llvm::support;
22 DbiModuleDescriptor::DbiModuleDescriptor() = default;
24 DbiModuleDescriptor::DbiModuleDescriptor(const DbiModuleDescriptor &Info) =
27 DbiModuleDescriptor::~DbiModuleDescriptor() = default;
29 Error DbiModuleDescriptor::initialize(BinaryStreamRef Stream,
30 DbiModuleDescriptor &Info) {
31 BinaryStreamReader Reader(Stream);
32 if (auto EC = Reader.readObject(Info.Layout))
35 if (auto EC = Reader.readCString(Info.ModuleName))
38 if (auto EC = Reader.readCString(Info.ObjFileName))
40 return Error::success();
43 bool DbiModuleDescriptor::hasECInfo() const {
44 return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
47 uint16_t DbiModuleDescriptor::getTypeServerIndex() const {
48 return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
49 ModInfoFlags::TypeServerIndexShift;
52 uint16_t DbiModuleDescriptor::getModuleStreamIndex() const {
53 return Layout->ModDiStream;
56 uint32_t DbiModuleDescriptor::getSymbolDebugInfoByteSize() const {
57 return Layout->SymBytes;
60 uint32_t DbiModuleDescriptor::getC11LineInfoByteSize() const {
61 return Layout->C11Bytes;
64 uint32_t DbiModuleDescriptor::getC13LineInfoByteSize() const {
65 return Layout->C13Bytes;
68 uint32_t DbiModuleDescriptor::getNumberOfFiles() const {
69 return Layout->NumFiles;
72 uint32_t DbiModuleDescriptor::getSourceFileNameIndex() const {
73 return Layout->SrcFileNameNI;
76 uint32_t DbiModuleDescriptor::getPdbFilePathNameIndex() const {
77 return Layout->PdbFilePathNI;
80 StringRef DbiModuleDescriptor::getModuleName() const { return ModuleName; }
82 StringRef DbiModuleDescriptor::getObjFileName() const { return ObjFileName; }
84 uint32_t DbiModuleDescriptor::getRecordLength() const {
85 uint32_t M = ModuleName.str().size() + 1;
86 uint32_t O = ObjFileName.str().size() + 1;
87 uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
88 Size = alignTo(Size, 4);