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 DbiModuleDescriptor::DbiModuleDescriptor() = default;
23 DbiModuleDescriptor::DbiModuleDescriptor(const DbiModuleDescriptor
&Info
) =
26 DbiModuleDescriptor::~DbiModuleDescriptor() = default;
28 Error
DbiModuleDescriptor::initialize(BinaryStreamRef Stream
,
29 DbiModuleDescriptor
&Info
) {
30 BinaryStreamReader
Reader(Stream
);
31 if (auto EC
= Reader
.readObject(Info
.Layout
))
34 if (auto EC
= Reader
.readCString(Info
.ModuleName
))
37 if (auto EC
= Reader
.readCString(Info
.ObjFileName
))
39 return Error::success();
42 bool DbiModuleDescriptor::hasECInfo() const {
43 return (Layout
->Flags
& ModInfoFlags::HasECFlagMask
) != 0;
46 uint16_t DbiModuleDescriptor::getTypeServerIndex() const {
47 return (Layout
->Flags
& ModInfoFlags::TypeServerIndexMask
) >>
48 ModInfoFlags::TypeServerIndexShift
;
51 const SectionContrib
&DbiModuleDescriptor::getSectionContrib() const {
55 uint16_t DbiModuleDescriptor::getModuleStreamIndex() const {
56 return Layout
->ModDiStream
;
59 uint32_t DbiModuleDescriptor::getSymbolDebugInfoByteSize() const {
60 return Layout
->SymBytes
;
63 uint32_t DbiModuleDescriptor::getC11LineInfoByteSize() const {
64 return Layout
->C11Bytes
;
67 uint32_t DbiModuleDescriptor::getC13LineInfoByteSize() const {
68 return Layout
->C13Bytes
;
71 uint32_t DbiModuleDescriptor::getNumberOfFiles() const {
72 return Layout
->NumFiles
;
75 uint32_t DbiModuleDescriptor::getSourceFileNameIndex() const {
76 return Layout
->SrcFileNameNI
;
79 uint32_t DbiModuleDescriptor::getPdbFilePathNameIndex() const {
80 return Layout
->PdbFilePathNI
;
83 StringRef
DbiModuleDescriptor::getModuleName() const { return ModuleName
; }
85 StringRef
DbiModuleDescriptor::getObjFileName() const { return ObjFileName
; }
87 uint32_t DbiModuleDescriptor::getRecordLength() const {
88 uint32_t M
= ModuleName
.str().size() + 1;
89 uint32_t O
= ObjFileName
.str().size() + 1;
90 uint32_t Size
= sizeof(ModuleInfoHeader
) + M
+ O
;
91 Size
= alignTo(Size
, 4);