1 //===- DbiModuleDescriptor.cpp - PDB module information -------------------===//
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
7 //===----------------------------------------------------------------------===//
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"
18 using namespace llvm::pdb
;
19 using namespace llvm::support
;
21 Error
DbiModuleDescriptor::initialize(BinaryStreamRef Stream
,
22 DbiModuleDescriptor
&Info
) {
23 BinaryStreamReader
Reader(Stream
);
24 if (auto EC
= Reader
.readObject(Info
.Layout
))
27 if (auto EC
= Reader
.readCString(Info
.ModuleName
))
30 if (auto EC
= Reader
.readCString(Info
.ObjFileName
))
32 return Error::success();
35 bool DbiModuleDescriptor::hasECInfo() const {
36 return (Layout
->Flags
& ModInfoFlags::HasECFlagMask
) != 0;
39 uint16_t DbiModuleDescriptor::getTypeServerIndex() const {
40 return (Layout
->Flags
& ModInfoFlags::TypeServerIndexMask
) >>
41 ModInfoFlags::TypeServerIndexShift
;
44 const SectionContrib
&DbiModuleDescriptor::getSectionContrib() const {
48 uint16_t DbiModuleDescriptor::getModuleStreamIndex() const {
49 return Layout
->ModDiStream
;
52 uint32_t DbiModuleDescriptor::getSymbolDebugInfoByteSize() const {
53 return Layout
->SymBytes
;
56 uint32_t DbiModuleDescriptor::getC11LineInfoByteSize() const {
57 return Layout
->C11Bytes
;
60 uint32_t DbiModuleDescriptor::getC13LineInfoByteSize() const {
61 return Layout
->C13Bytes
;
64 uint32_t DbiModuleDescriptor::getNumberOfFiles() const {
65 return Layout
->NumFiles
;
68 uint32_t DbiModuleDescriptor::getSourceFileNameIndex() const {
69 return Layout
->SrcFileNameNI
;
72 uint32_t DbiModuleDescriptor::getPdbFilePathNameIndex() const {
73 return Layout
->PdbFilePathNI
;
76 StringRef
DbiModuleDescriptor::getModuleName() const { return ModuleName
; }
78 StringRef
DbiModuleDescriptor::getObjFileName() const { return ObjFileName
; }
80 uint32_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);