LLVM 19.0.0git
GlobalsStream.h
Go to the documentation of this file.
1//===- GlobalsStream.h - PDB Index of Symbols by Name -----------*- 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_NATIVE_GLOBALSSTREAM_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_GLOBALSSTREAM_H
11
12#include "llvm/ADT/iterator.h"
16#include "llvm/Support/Endian.h"
17#include "llvm/Support/Error.h"
18
19namespace llvm {
20class BinaryStreamReader;
21namespace msf {
22class MappedBlockStream;
23}
24namespace pdb {
25class SymbolStream;
26
27/// Iterator over hash records producing symbol record offsets. Abstracts away
28/// the fact that symbol record offsets on disk are off-by-one.
30 : public iterator_adaptor_base<
31 GSIHashIterator, FixedStreamArrayIterator<PSHashRecord>,
32 std::random_access_iterator_tag, const uint32_t> {
33public:
34 template <typename T>
36 : GSIHashIterator::iterator_adaptor_base(std::forward<T &&>(v)) {}
37
39 uint32_t Off = this->I->Off;
40 return --Off;
41 }
42};
43
44/// From https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.cpp
45enum : unsigned { IPHR_HASH = 4096 };
46
47/// A readonly view of a hash table used in the globals and publics streams.
48/// Most clients will only want to iterate this to get symbol record offsets
49/// into the PDB symbol stream.
51public:
56 std::array<int32_t, IPHR_HASH + 1> BucketMap;
57
59
61 uint32_t getVerHeader() const { return HashHdr->VerHdr; }
64
68};
69
71public:
72 explicit GlobalsStream(std::unique_ptr<msf::MappedBlockStream> Stream);
74 const GSIHashTable &getGlobalsTable() const { return GlobalsTable; }
75 Error reload();
76
77 std::vector<std::pair<uint32_t, codeview::CVSymbol>>
79
80private:
81 GSIHashTable GlobalsTable;
82 std::unique_ptr<msf::MappedBlockStream> Stream;
83};
84} // namespace pdb
85}
86
87#endif
Lightweight arrays that are backed by an arbitrary BinaryStream.
std::string Name
Provides read only access to a subclass of BinaryStream.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
FixedStreamArrayIterator< T > begin() const
FixedStreamArrayIterator< T > end() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
CRTP base class for adapting an iterator to a different type.
Definition: iterator.h:237
Iterator over hash records producing symbol record offsets.
Definition: GlobalsStream.h:32
uint32_t operator*() const
Definition: GlobalsStream.h:38
A readonly view of a hash table used in the globals and publics streams.
Definition: GlobalsStream.h:50
const GSIHashHeader * HashHdr
Definition: GlobalsStream.h:52
uint32_t getHashRecordSize() const
Definition: GlobalsStream.h:62
Error read(BinaryStreamReader &Reader)
uint32_t getNumBuckets() const
Definition: GlobalsStream.h:63
std::array< int32_t, IPHR_HASH+1 > BucketMap
Definition: GlobalsStream.h:56
FixedStreamArray< support::ulittle32_t > HashBuckets
Definition: GlobalsStream.h:55
FixedStreamArray< support::ulittle32_t > HashBitmap
Definition: GlobalsStream.h:54
uint32_t getVerSignature() const
Definition: GlobalsStream.h:60
GSIHashHeader iterator
Definition: GlobalsStream.h:65
GSIHashIterator begin() const
Definition: GlobalsStream.h:66
GSIHashIterator end() const
Definition: GlobalsStream.h:67
uint32_t getVerHeader() const
Definition: GlobalsStream.h:61
FixedStreamArray< PSHashRecord > HashRecords
Definition: GlobalsStream.h:53
std::vector< std::pair< uint32_t, codeview::CVSymbol > > findRecordsByName(StringRef Name, const SymbolStream &Symbols) const
const GSIHashTable & getGlobalsTable() const
Definition: GlobalsStream.h:74
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
Header of the hash tables found in the globals and publics sections.
Definition: RawTypes.h:28
support::ulittle32_t HrSize
Definition: RawTypes.h:35
support::ulittle32_t VerHdr
Definition: RawTypes.h:34
support::ulittle32_t VerSignature
Definition: RawTypes.h:33
support::ulittle32_t NumBuckets
Definition: RawTypes.h:36