Line data Source code
1 : //===- NamedStreamMap.h - PDB Named Stream Map ------------------*- 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_NATIVE_NAMEDSTREAMMAP_H
11 : #define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
12 :
13 : #include "llvm/ADT/Optional.h"
14 : #include "llvm/ADT/StringMap.h"
15 : #include "llvm/ADT/StringRef.h"
16 : #include "llvm/ADT/iterator_range.h"
17 : #include "llvm/DebugInfo/PDB/Native/HashTable.h"
18 : #include "llvm/Support/Error.h"
19 : #include <cstdint>
20 :
21 : namespace llvm {
22 :
23 : class BinaryStreamReader;
24 : class BinaryStreamWriter;
25 :
26 : namespace pdb {
27 :
28 : class NamedStreamMap;
29 :
30 : struct NamedStreamMapTraits {
31 : NamedStreamMap *NS;
32 :
33 : explicit NamedStreamMapTraits(NamedStreamMap &NS);
34 : uint16_t hashLookupKey(StringRef S) const;
35 : StringRef storageKeyToLookupKey(uint32_t Offset) const;
36 : uint32_t lookupKeyToStorageKey(StringRef S);
37 : };
38 :
39 6122 : class NamedStreamMap {
40 : friend class NamedStreamMapBuilder;
41 :
42 : public:
43 : NamedStreamMap();
44 :
45 : Error load(BinaryStreamReader &Stream);
46 : Error commit(BinaryStreamWriter &Writer) const;
47 : uint32_t calculateSerializedLength() const;
48 :
49 : uint32_t size() const;
50 : bool get(StringRef Stream, uint32_t &StreamNo) const;
51 : void set(StringRef Stream, uint32_t StreamNo);
52 :
53 : uint32_t appendStringData(StringRef S);
54 : StringRef getString(uint32_t Offset) const;
55 : uint32_t hashString(uint32_t Offset) const;
56 :
57 : StringMap<uint32_t> entries() const;
58 :
59 : private:
60 : NamedStreamMapTraits HashTraits;
61 : /// Closed hash table from Offset -> StreamNumber, where Offset is the offset
62 : /// of the stream name in NamesBuffer.
63 : HashTable<support::ulittle32_t, NamedStreamMapTraits> OffsetIndexMap;
64 :
65 : /// Buffer of string data.
66 : std::vector<char> NamesBuffer;
67 : };
68 :
69 : } // end namespace pdb
70 :
71 : } // end namespace llvm
72 :
73 : #endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H
|