1 //===- ModInfo.h - PDB module information -----------------------*- C++ -*-===//
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 #ifndef LLVM_DEBUGINFO_PDB_RAW_MODINFO_H
11 #define LLVM_DEBUGINFO_PDB_RAW_MODINFO_H
12 
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/DebugInfo/CodeView/StreamArray.h"
15 #include "llvm/DebugInfo/CodeView/StreamRef.h"
16 #include <cstdint>
17 #include <vector>
18 
19 namespace llvm {
20 namespace pdb {
21 
22 class ModInfo {
23 private:
24   struct FileLayout;
25 
26 public:
27   ModInfo();
28   ModInfo(const ModInfo &Info);
29   ~ModInfo();
30 
31   static Error initialize(codeview::StreamRef Stream, ModInfo &Info);
32 
33   bool hasECInfo() const;
34   uint16_t getTypeServerIndex() const;
35   uint16_t getModuleStreamIndex() const;
36   uint32_t getSymbolDebugInfoByteSize() const;
37   uint32_t getLineInfoByteSize() const;
38   uint32_t getC13LineInfoByteSize() const;
39   uint32_t getNumberOfFiles() const;
40   uint32_t getSourceFileNameIndex() const;
41   uint32_t getPdbFilePathNameIndex() const;
42 
43   StringRef getModuleName() const;
44   StringRef getObjFileName() const;
45 
46   uint32_t getRecordLength() const;
47 
48 private:
49   StringRef ModuleName;
50   StringRef ObjFileName;
51   const FileLayout *Layout;
52 };
53 
54 struct ModuleInfoEx {
ModuleInfoExModuleInfoEx55   ModuleInfoEx(const ModInfo &Info) : Info(Info) {}
ModuleInfoExModuleInfoEx56   ModuleInfoEx(const ModuleInfoEx &Ex)
57       : Info(Ex.Info), SourceFiles(Ex.SourceFiles) {}
58 
59   ModInfo Info;
60   std::vector<StringRef> SourceFiles;
61 };
62 
63 } // end namespace pdb
64 
65 namespace codeview {
66 template <> struct VarStreamArrayExtractor<pdb::ModInfo> {
67   Error operator()(StreamRef Stream, uint32_t &Length,
68                    pdb::ModInfo &Info) const {
69     if (auto EC = pdb::ModInfo::initialize(Stream, Info))
70       return EC;
71     Length = Info.getRecordLength();
72     return Error::success();
73   }
74 };
75 }
76 
77 } // end namespace llvm
78 
79 #endif // LLVM_DEBUGINFO_PDB_RAW_MODINFO_H
80