1//===- DbiModuleDescriptor.h - PDB module information -----------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H
10#define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H
11
12#include "llvm/ADT/StringRef.h"
13#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
14#include "llvm/Support/BinaryStreamArray.h"
15#include "llvm/Support/BinaryStreamRef.h"
16#include "llvm/Support/Error.h"
17#include <cstdint>
18#include <vector>
19
20namespace llvm {
21
22namespace pdb {
23
24class DbiModuleDescriptor {
25  friend class DbiStreamBuilder;
26
27public:
28  DbiModuleDescriptor() = default;
29  DbiModuleDescriptor(const DbiModuleDescriptor &Info) = default;
30  DbiModuleDescriptor &operator=(const DbiModuleDescriptor &Info) = default;
31
32  static Error initialize(BinaryStreamRef Stream, DbiModuleDescriptor &Info);
33
34  bool hasECInfo() const;
35  uint16_t getTypeServerIndex() const;
36  uint16_t getModuleStreamIndex() const;
37  uint32_t getSymbolDebugInfoByteSize() const;
38  uint32_t getC11LineInfoByteSize() const;
39  uint32_t getC13LineInfoByteSize() const;
40  uint32_t getNumberOfFiles() const;
41  uint32_t getSourceFileNameIndex() const;
42  uint32_t getPdbFilePathNameIndex() const;
43
44  StringRef getModuleName() const;
45  StringRef getObjFileName() const;
46
47  uint32_t getRecordLength() const;
48
49  const SectionContrib &getSectionContrib() const;
50
51private:
52  StringRef ModuleName;
53  StringRef ObjFileName;
54  const ModuleInfoHeader *Layout = nullptr;
55};
56
57} // end namespace pdb
58
59template <> struct VarStreamArrayExtractor<pdb::DbiModuleDescriptor> {
60  Error operator()(BinaryStreamRef Stream, uint32_t &Length,
61                   pdb::DbiModuleDescriptor &Info) {
62    if (auto EC = pdb::DbiModuleDescriptor::initialize(Stream, Info))
63      return EC;
64    Length = Info.getRecordLength();
65    return Error::success();
66  }
67};
68
69} // end namespace llvm
70
71#endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H
72