1//===- InfoStream.h - PDB Info Stream (Stream 1) Access ---------*- 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_PDBINFOSTREAM_H
11#define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAM_H
12
13#include "llvm/ADT/BitmaskEnum.h"
14#include "llvm/ADT/StringMap.h"
15#include "llvm/DebugInfo/CodeView/GUID.h"
16#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
17#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h"
18#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
19#include "llvm/DebugInfo/PDB/PDBTypes.h"
20
21#include "llvm/Support/Endian.h"
22#include "llvm/Support/Error.h"
23
24namespace llvm {
25namespace pdb {
26class InfoStreamBuilder;
27class PDBFile;
28
29class InfoStream {
30  friend class InfoStreamBuilder;
31
32public:
33  InfoStream(std::unique_ptr<msf::MappedBlockStream> Stream);
34
35  Error reload();
36
37  uint32_t getStreamSize() const;
38
39  bool containsIdStream() const;
40  PdbRaw_ImplVer getVersion() const;
41  uint32_t getSignature() const;
42  uint32_t getAge() const;
43  codeview::GUID getGuid() const;
44  uint32_t getNamedStreamMapByteSize() const;
45
46  PdbRaw_Features getFeatures() const;
47  ArrayRef<PdbRaw_FeatureSig> getFeatureSignatures() const;
48
49  const NamedStreamMap &getNamedStreams() const;
50
51  BinarySubstreamRef getNamedStreamsBuffer() const;
52
53  uint32_t getNamedStreamIndex(llvm::StringRef Name) const;
54  iterator_range<StringMapConstIterator<uint32_t>> named_streams() const;
55
56private:
57  std::unique_ptr<msf::MappedBlockStream> Stream;
58
59  // PDB file format version.  We only support VC70.  See the enumeration
60  // `PdbRaw_ImplVer` for the other possible values.
61  uint32_t Version;
62
63  // A 32-bit signature unique across all PDBs.  This is generated with
64  // a call to time() when the PDB is written, but obviously this is not
65  // universally unique.
66  uint32_t Signature;
67
68  // The number of times the PDB has been written.  Might also be used to
69  // ensure that the PDB matches the executable.
70  uint32_t Age;
71
72  // Due to the aforementioned limitations with `Signature`, this is a new
73  // signature present on VC70 and higher PDBs which is guaranteed to be
74  // universally unique.
75  codeview::GUID Guid;
76
77  BinarySubstreamRef SubNamedStreams;
78
79  std::vector<PdbRaw_FeatureSig> FeatureSignatures;
80  PdbRaw_Features Features = PdbFeatureNone;
81
82  uint32_t NamedStreamMapByteSize = 0;
83
84  NamedStreamMap NamedStreams;
85};
86}
87}
88
89#endif
90