1 //===- PDBStringTable.h - PDB String Table -----------------------*- 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_PDBSTRINGTABLE_H
10 #define LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLE_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
15 #include "llvm/Support/BinaryStreamArray.h"
16 #include "llvm/Support/BinaryStreamRef.h"
17 #include "llvm/Support/Endian.h"
18 #include "llvm/Support/Error.h"
19 #include <cstdint>
20 
21 namespace llvm {
22 class BinaryStreamReader;
23 
24 namespace msf {
25 class MappedBlockStream;
26 }
27 
28 namespace pdb {
29 
30 struct PDBStringTableHeader;
31 
32 class PDBStringTable {
33 public:
34   Error reload(BinaryStreamReader &Reader);
35 
36   uint32_t getByteSize() const;
37   uint32_t getNameCount() const;
38   uint32_t getHashVersion() const;
39   uint32_t getSignature() const;
40 
41   Expected<StringRef> getStringForID(uint32_t ID) const;
42   Expected<uint32_t> getIDForString(StringRef Str) const;
43 
44   FixedStreamArray<support::ulittle32_t> name_ids() const;
45 
46   const codeview::DebugStringTableSubsectionRef &getStringTable() const;
47 
48 private:
49   Error readHeader(BinaryStreamReader &Reader);
50   Error readStrings(BinaryStreamReader &Reader);
51   Error readHashTable(BinaryStreamReader &Reader);
52   Error readEpilogue(BinaryStreamReader &Reader);
53 
54   const PDBStringTableHeader *Header = nullptr;
55   codeview::DebugStringTableSubsectionRef Strings;
56   FixedStreamArray<support::ulittle32_t> IDs;
57   uint32_t NameCount = 0;
58 };
59 
60 } // end namespace pdb
61 } // end namespace llvm
62 
63 #endif // LLVM_DEBUGINFO_PDB_NATIVE_PDBSTRINGTABLE_H
64