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