Line data Source code
1 : //===- ModInfo.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/MSF/StreamReader.h"
11 : #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
12 : #include "llvm/DebugInfo/PDB/Raw/RawTypes.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::msf;
20 : using namespace llvm::pdb;
21 : using namespace llvm::support;
22 :
23 : ModInfo::ModInfo() = default;
24 :
25 : ModInfo::ModInfo(const ModInfo &Info) = default;
26 :
27 : ModInfo::~ModInfo() = default;
28 :
29 65 : Error ModInfo::initialize(ReadableStreamRef Stream, ModInfo &Info) {
30 65 : StreamReader Reader(Stream);
31 195 : if (auto EC = Reader.readObject(Info.Layout))
32 0 : return EC;
33 :
34 195 : if (auto EC = Reader.readZeroString(Info.ModuleName))
35 0 : return EC;
36 :
37 195 : if (auto EC = Reader.readZeroString(Info.ObjFileName))
38 0 : return EC;
39 195 : return Error::success();
40 : }
41 :
42 52 : bool ModInfo::hasECInfo() const {
43 104 : return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
44 : }
45 :
46 52 : uint16_t ModInfo::getTypeServerIndex() const {
47 104 : return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
48 52 : ModInfoFlags::TypeServerIndexShift;
49 : }
50 :
51 240 : uint16_t ModInfo::getModuleStreamIndex() const { return Layout->ModDiStream; }
52 :
53 58 : uint32_t ModInfo::getSymbolDebugInfoByteSize() const {
54 116 : return Layout->SymBytes;
55 : }
56 :
57 116 : uint32_t ModInfo::getLineInfoByteSize() const { return Layout->LineBytes; }
58 :
59 116 : uint32_t ModInfo::getC13LineInfoByteSize() const { return Layout->C13Bytes; }
60 :
61 104 : uint32_t ModInfo::getNumberOfFiles() const { return Layout->NumFiles; }
62 :
63 52 : uint32_t ModInfo::getSourceFileNameIndex() const {
64 104 : return Layout->SrcFileNameNI;
65 : }
66 :
67 52 : uint32_t ModInfo::getPdbFilePathNameIndex() const {
68 104 : return Layout->PdbFilePathNI;
69 : }
70 :
71 76 : StringRef ModInfo::getModuleName() const { return ModuleName; }
72 :
73 56 : StringRef ModInfo::getObjFileName() const { return ObjFileName; }
74 :
75 65 : uint32_t ModInfo::getRecordLength() const {
76 195 : uint32_t M = ModuleName.str().size() + 1;
77 195 : uint32_t O = ObjFileName.str().size() + 1;
78 65 : uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
79 130 : Size = alignTo(Size, 4);
80 65 : return Size;
81 : }
|